Class AttributeUtils
- java.lang.Object
-
- se.litsec.eidas.opensaml.ext.attributes.AttributeUtils
-
public class AttributeUtils extends Object
Utility methods for handling attributes and attribute values.- Author:
- Martin Lindström (martin.lindstrom@litsec.se)
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <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 Detail
-
createAttribute
public static Attribute createAttribute(String name, String friendlyName, String nameFormat)
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
public static Attribute createAttribute(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".- Parameters:
name- the attribute namefriendlyName- the attribute friendly name (may benull)- Returns:
- an
Attributeobject - See Also:
createAttribute(String, String, String)
-
createAttributeValueObject
public static <T extends XMLObject> T createAttributeValueObject(Class<T> clazz)
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(QName, Class)
-
createAttributeValueObject
public static <T extends XMLObject> T createAttributeValueObject(QName schemaType, Class<T> clazz)
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:
createAttributeValueObject(Class)
-
addAttributeValue
public static <T extends XMLObject> void addAttributeValue(Attribute attribute, T value)
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
-
-