简体   繁体   English

使用 authzforce 在包中添加多个值

[英]Add multiple values in bag using authzforce

I'm aware there is already a question here on stackoverflow where this is discussed, but I still have trouble to send the correct values to Bag.newAttributeBag and was hoping for some help.我知道这里已经在 stackoverflow 上讨论了一个问题,但是我仍然无法将正确的值发送到 Bag.newAttributeBag 并希望得到一些帮助。

final Collection<StringValue> subjectList = new ArrayList<>();

    subjectList.add("123456");
    subjectList.add("John Smith");

final AttributeFqn subjectIdAttributeId = AttributeFqns.newInstance(XACML_1_0_ACCESS_SUBJECT.value(), Optional.empty(), XacmlAttributeId.XACML_1_0_SUBJECT_ID.value());
final AttributeBag<?> subjectIdAttributeValues = Bags.newAttributeBag(StandardDatatypes.STRING, subjectList);
requestBuilder.putNamedAttributeIfAbsent(subjectIdAttributeId, subjectIdAttributeValues);

If I use Collection StringValue I get an error on subjectList.add如果我使用 Collection StringValue,我会收到关于 subjectList.add 的错误

The method add(StringValue) in the type Collection is not applicable for the arguments (String)类型 Collection 中的方法 add(StringValue) 不适用于参数 (String)

If I use Collection<String> I get an error on newAttributeBag.如果我使用Collection<String>我会在 newAttributeBag 上得到一个错误。 How can I add multiple values to my Bag.newAttributeBag?如何向 Bag.newAttributeBag 添加多个值?

The method newAttributeBag(Datatype, Collection) in the type Bags is not applicable for the arguments (AttributeDatatype, Collection) Bags 类型中的 newAttributeBag(Datatype, Collection) 方法不适用于参数 (AttributeDatatype, Collection)

You should do:你应该做:

subjectList.add(new StringValue("123456"));
subjectList.add(new StringValue("John Smith"));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM