Class AttributeBuilder
java.lang.Object
se.swedenconnect.opensaml.common.builder.AbstractSAMLObjectBuilder<Attribute>
se.swedenconnect.opensaml.saml2.attribute.AttributeBuilder
- All Implemented Interfaces:
SAMLObjectBuilder<Attribute>
Implements the build pattern to create
Attribute objects.- Author:
- Martin Lindström (martin@idsec.se)
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe default name format for the attribute being built. -
Constructor Summary
ConstructorsConstructorDescriptionAttributeBuilder(InputStream resource) Constructor setting up the builder with a template attribute that is read from an input stream.AttributeBuilder(String name) Constructor setting the attribute name.AttributeBuilder(Attribute template) Constructor setting up the builder given an attribute template. -
Method Summary
Modifier and TypeMethodDescriptionbuild()Returns theAttributeobject that has been built.static AttributeBuilderbuilder(InputStream resource) Static utility method that creates aAttributeBuildergiven a template attribute read from an input stream.static AttributeBuilderStatic utility method that creates a defaultAttributeBuilder.static AttributeBuilderStatic utility method that creates aAttributeBuildergiven a template attribute.static <T extends XMLObject>
TcreateValueObject(Class<T> clazz) Creates anAttributeValueobject of the given class.static <T extends XMLObject>
TcreateValueObject(QName schemaType, Class<T> clazz) Creates anAttributeValueobject of the given class and schema type.friendlyName(String friendlyName) Assigns the attribute friendly name.Returns the object type.Assigns the attribute name.nameFormat(String nameFormat) Assigns the attribute name format.Assigns one (or more) attribute string values.<T extends XMLObject>
AttributeBuildervalue(T value) Assigns an attribute value.Methods inherited from class se.swedenconnect.opensaml.common.builder.AbstractSAMLObjectBuilder
getDefaultElementName, object
-
Field Details
-
DEFAULT_NAME_FORMAT
The default name format for the attribute being built.- See Also:
-
-
Constructor Details
-
AttributeBuilder
Constructor setting the attribute name.- Parameters:
name- the attribute name
-
AttributeBuilder
Constructor setting up the builder given an attribute template.- Parameters:
template- the attribute template- Throws:
UnmarshallingException- for unmarshalling errorsMarshallingException- for marshalling errors- See Also:
-
AttributeBuilder
Constructor setting up the builder with a template attribute that is read from an input stream.- Parameters:
resource- the attribute template- Throws:
UnmarshallingException- for unmarshalling errorsXMLParserException- for XML parsing errors- See Also:
-
-
Method Details
-
builder
Static utility method that creates a defaultAttributeBuilder.- Parameters:
name- the attribute name- Returns:
- an AttributeBuilder instance.
- See Also:
-
builder
public static AttributeBuilder builder(Attribute attribute) throws MarshallingException, UnmarshallingException Static utility method that creates aAttributeBuildergiven a template attribute.- Parameters:
attribute- the attribute template- Returns:
- an attribute builder
- Throws:
UnmarshallingException- for unmarshalling errorsMarshallingException- for marshalling errors
-
builder
public static AttributeBuilder builder(InputStream resource) throws XMLParserException, UnmarshallingException Static utility method that creates aAttributeBuildergiven a template attribute read from an input stream.- Parameters:
resource- the attribute template- Returns:
- an attribute builder
- Throws:
UnmarshallingException- for unmarshalling errorsXMLParserException- for XML parsing errors
-
build
Returns theAttributeobject that has been built. If theNameFormatattribute has not been assigned, the method will inject the default value ("urn:oasis:names:tc:SAML:2.0:attrname-format:uri").- Specified by:
buildin interfaceSAMLObjectBuilder<Attribute>- Overrides:
buildin classAbstractSAMLObjectBuilder<Attribute>- Returns:
- the built object
-
name
Assigns the attribute name.- Parameters:
name- the attribute name- Returns:
- the builder
-
friendlyName
Assigns the attribute friendly name.- Parameters:
friendlyName- the friendly name- Returns:
- the builder
-
nameFormat
Assigns the attribute name format.- Parameters:
nameFormat- the name format URI- Returns:
- the builder
-
value
Assigns one (or more) attribute string values.Note: if
nullis passed as a parameter, any previous attribute values are cleared.- Parameters:
values- the string value(s) to add- Returns:
- the builder
-
value
- Parameters:
values- the string value(s) to add- Returns:
- the builder
- See Also:
-
value
Assigns an attribute value.- Type Parameters:
T- the value type- Parameters:
value- the value to add- Returns:
- the builder
-
createValueObject
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.
Note: For attribute having string values, there is no need to explictly create an attribute value. Instead the
value(String...)method may be used directly.- Type Parameters:
T- the type- Parameters:
clazz- the type of attribute value- Returns:
- the attribute value
- See Also:
-
createValueObject
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.
Note: For attribute having string values, there is no need to explictly create an attribute value. Instead the
value(String...)method may be used directly.- Type Parameters:
T- the type- Parameters:
schemaType- the schema type that should be assigned to the attribute value, i.e.,xsi:type="ns:ValueType"clazz- the type of the attribute value- Returns:
- the attribute value
- See Also:
-
getObjectType
Returns the object type.- Specified by:
getObjectTypein classAbstractSAMLObjectBuilder<Attribute>- Returns:
- the object type
-