Class Attributes
Object
se.curity.identityserver.sdk.attribute.Attributes
- All Implemented Interfaces:
Iterable<Attribute>,AttributeContainer<Attributes>,SerializableAsMap
- Direct Known Subclasses:
AttributeAdditions,AttributeReplacements,AuthenticationAttributes,AuthorizationAttributes,ConsentAttributes,ConsentorResultAttributes,ResourceAttributes,TokenAttributes
Collection of
Attribute instances that can be efficiently located by name.- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAppends the given attribute to a copy of this, returning the result.Appends the given attribute to a copy of this, returning the result.asMap()booleanA flag indicating that this container has an Attribute with the given name.static Attributesempty()booleanstatic Attributesstatic AttributesCreate anAttributesobject from a map of values.Get the attribute with the given name if it exists, or null otherwise.Get a collection containing all attributes with the given name and distinct authorities.getMandatoryAttribute(String name) Convenience method to get a mandatory attribute.<T extends Comparable<?>>
TgetMandatoryValue(String name, Class<T> type) Convenience method to get the value of a mandatory attribute.<T extends Comparable<T>>
List<T>getValuesOfType(Class<T> type, String name) Lenient method to get all Attribute values of a certain type.inthashCode()booleanisEmpty()iterator()keys()static Attributesstatic Attributesof(String name, Comparable<?> value) static Attributesof(String name1, Comparable<?> value1, String name2, Comparable<?> value2) static Attributesof(String name1, Comparable<?> value1, String name2, Comparable<?> value2, String name3, Comparable<?> value3) static Attributesof(String name1, Comparable<?> value1, String name2, Comparable<?> value2, String name3, Comparable<?> value3, String name4, Comparable<?> value4) static Attributesof(String name1, Comparable<?> value1, String name2, Comparable<?> value2, String name3, Comparable<?> value3, String name4, Comparable<?> value4, String name5, Comparable<?> value5) static AttributesremoveAttributes(Set<String> exclusionNames) Remove all top-level attributes whose names are in the given Set.retainAttributes(Set<String> inclusionNames) Retain all attributes whose names are in the given Set.intsize()stream()Returns a stream of the Attributes in the container.toMap()toString()Add the given attributes if not present, or replace the attribute if it already exists.Add the given attribute if not present, or replace the attribute if it already exists.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface se.curity.identityserver.sdk.attribute.AttributeContainer
contains, getOptionalValue, getOptionalValue, removeAttribute, retainAttributeMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
Attributes
-
-
Method Details
-
empty
-
of
-
of
-
of
public static Attributes of(String name1, Comparable<?> value1, String name2, Comparable<?> value2, String name3, Comparable<?> value3) -
of
public static Attributes of(String name1, Comparable<?> value1, String name2, Comparable<?> value2, String name3, Comparable<?> value3, String name4, Comparable<?> value4) -
of
public static Attributes of(String name1, Comparable<?> value1, String name2, Comparable<?> value2, String name3, Comparable<?> value3, String name4, Comparable<?> value4, String name5, Comparable<?> value5) -
of
-
of
-
fromMap
-
fromMap
Create anAttributesobject from a map of values.- Parameters:
map- the names of the attributes to be added and their associated valuesnameFormat- the format of the name attribute- Returns:
- the new
Attributesobject - Since:
- 2.1.0
-
toMap
- Returns:
- a Map from Strings to primitive values, Maps and Lists.
-
asMap
- Specified by:
asMapin interfaceSerializableAsMap- Returns:
- representation of this Object as a Map containing only Java primitive types, plus instances of
Collection,StringandMap.It should be possible to fully re-construct this Object from a Map obtained by calling this method.
Unfortunately, in Java it is quite hard to make the type system enforce this condition, so implementators must be especially careful about this.
-
append
Description copied from interface:AttributeContainerAppends the given attribute to a copy of this, returning the result.- Specified by:
appendin interfaceAttributeContainer<Attributes>- Parameters:
attribute- to append- Returns:
- copy of this with the provided attribute appended to it
-
append
Description copied from interface:AttributeContainerAppends the given attribute to a copy of this, returning the result.- Specified by:
appendin interfaceAttributeContainer<Attributes>- Parameters:
attributes- to append- Returns:
- copy of this with the provided attribute appended to it
-
get
Description copied from interface:AttributeContainerGet the attribute with the given name if it exists, or null otherwise. If multiple attributes with the same name exist (e.g. with different authorities), then one of those attributes will be returned.- Specified by:
getin interfaceAttributeContainer<Attributes>- Parameters:
name- of attribute- Returns:
- one of the attributes with the given name if any, or null otherwise.
-
getAll
Description copied from interface:AttributeContainerGet a collection containing all attributes with the given name and distinct authorities.- Specified by:
getAllin interfaceAttributeContainer<Attributes>- Parameters:
name- of attribute- Returns:
- an unmodifiable collection with all the contained attributes with the given name.
-
getValuesOfType
Lenient method to get all Attribute values of a certain type.- Type Parameters:
T- type of attribute values- Parameters:
type- of attribute valuesname- name of the attribute- Returns:
- all attribute values of the given type, or an empty list if the attribute does not have any values or does not exist.
-
getMandatoryAttribute
Convenience method to get a mandatory attribute. Throws exception if not found- Parameters:
name- name- Returns:
- attribute
- Throws:
NoSuchElementException- when attribute is not found
-
getMandatoryValue
Convenience method to get the value of a mandatory attribute.- Type Parameters:
T- type of the value- Parameters:
name- nametype- type- Returns:
- attribute
- Throws:
NoSuchElementException- Throws exception if the attibute is not found, or if the attribute does not have a value of the type
-
contains
Description copied from interface:AttributeContainerA flag indicating that this container has an Attribute with the given name.- Specified by:
containsin interfaceAttributeContainer<Attributes>- Parameters:
name- of the attribute- Returns:
- true if an
Attributewith the given name exists, false otherwise. Notice that even if an Attribute exists, it may have no value. The safe way to get a single value from an Attribute you are not sure exists is as follows:
To avoid querying the Map twice, call get() directly and check that the result is not null.Attributes attributes = ... ; if (attributes.contains("name") { Attribute attribute = attributes.get("name"); if (attribute.hasValue()) { return attribute.getValue(); } else { // no value is present } }
-
removeAttributes
Description copied from interface:AttributeContainerRemove all top-level attributes whose names are in the given Set.- Specified by:
removeAttributesin interfaceAttributeContainer<Attributes>- Parameters:
exclusionNames- names of attributes to exclude.- Returns:
- this Attributes without the excluded top-level attributes
-
retainAttributes
Description copied from interface:AttributeContainerRetain all attributes whose names are in the given Set. All attributes that are not named in the set are removed.- Specified by:
retainAttributesin interfaceAttributeContainer<Attributes>- Parameters:
inclusionNames- names of attributes to retain.- Returns:
- this Attributes with only the included attributes
-
iterator
-
stream
Description copied from interface:AttributeContainerReturns a stream of the Attributes in the container.- Specified by:
streamin interfaceAttributeContainer<Attributes>- Returns:
- a Stream of the Attributes contained in the container.
-
with
Description copied from interface:AttributeContainerAdd the given attributes if not present, or replace the attribute if it already exists. Note that two attributes with the same name and different authorities are considered distinct.- Specified by:
within interfaceAttributeContainer<Attributes>- Parameters:
attributes- attribute to add or to override- Returns:
- a copy of this which contains the given Attributes
-
with
Description copied from interface:AttributeContainerAdd the given attribute if not present, or replace the attribute if it already exists. Note that two attributes with the same name and different authorities are considered distinct.- Specified by:
within interfaceAttributeContainer<Attributes>- Parameters:
attribute- attribute to add or to override- Returns:
- a copy of this which contains the given Attribute
-
equals
-
hashCode
public int hashCode() -
toString
-
size
public int size() -
isEmpty
public boolean isEmpty() -
keys
-