简体   繁体   中英

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.

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

The method add(StringValue) in the type Collection is not applicable for the arguments (String)

If I use Collection<String> I get an error on newAttributeBag. How can I add multiple values to my Bag.newAttributeBag?

The method newAttributeBag(Datatype, Collection) in the type Bags is not applicable for the arguments (AttributeDatatype, Collection)

You should do:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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