Class AttributeUtils
java.lang.Object
se.swedenconnect.opensaml.eidas.ext.attributes.AttributeUtils
Utility methods for handling attributes and attribute values.
- Author:
- Martin Lindström
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends XMLObject>
voidaddAttributeValue(Attribute attribute, T value) Utility method that adds an XML object as a value to anAttribute.static AttributecreateAttribute(String name, String friendlyName) Creates anAttributewith the given name (and friendly name) and with a name format of "urn:oasis:names:tc:SAML:2.0:attrname-format:uri".static AttributecreateAttribute(String name, String friendlyName, String nameFormat) Utility method that creates anAttributegiven its name, friendly name and name format.static <T extends XMLObject>
TcreateAttributeValueObject(Class<T> clazz) Creates anAttributeValueobject of the given class.static <T extends XMLObject>
TcreateAttributeValueObject(QName schemaType, Class<T> clazz) Creates anAttributeValueobject of the given class and schema type.
-
Method Details
-
createAttribute
Utility method that creates anAttributegiven its name, friendly name and name format.- Parameters:
name- the attribute namefriendlyName- the attribute friendly name (may benull)nameFormat- the name format- Returns:
- an
Attributeobject
-
createAttribute
Creates anAttributewith the given name (and friendly name) and with a name format of "urn:oasis:names:tc:SAML:2.0:attrname-format:uri".- Parameters:
name- the attribute namefriendlyName- the attribute friendly name (may benull)- Returns:
- an
Attributeobject - See Also:
-
createAttributeValueObject
Creates anAttributeValueobject of the given class. The type of the attribute value will be the field that is declared asTYPE_NAMEof the given class.After the object has been constructed, its setter methods should be called to setup the value object before adding it to the attribute itself.
- Type Parameters:
T- the type- Parameters:
clazz- the type of attribute value- Returns:
- the attribute value
- See Also:
-
createAttributeValueObject
Creates anAttributeValueobject of the given class and schema type.After the object has been constructed, its setter methods should be called to setup the value object before adding it to the attribute itself.
- Type Parameters:
T- the type- Parameters:
schemaType- the schema type that should be assigned to the attribute value, i.e.,xsi:type="eidas:CurrentFamilyNameType"clazz- the type of the attribute value- Returns:
- the attribute value
- See Also:
-
addAttributeValue
Utility method that adds an XML object as a value to anAttribute.Example:
Attribute attr = AttributeUtils.createAttribute("http://eidas.europa.eu/attributes/naturalperson/CurrentFamilyName", "FamilyName"); CurrentFamilyNameType value = AttributeUtils.createAttributeValueObject(CurrentFamilyNameType.class); value.setValue("Lindström"); AttributeUtils.addAttributeValue(attr, value);- Type Parameters:
T- the type- Parameters:
attribute- the attribute to updatevalue- the value to add
-