Class AttributeImpl

  • All Implemented Interfaces:
    Attribute

    public class AttributeImpl
    extends Object
    implements Attribute
    This is a default implementation of interface Attribute. The Attribute element identifies an attribute by name and optionally includes its value(s). It has the AttributeType complex type.

     <complexType name="AttributeType">
       <complexContent>
         <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
           <sequence>
             <element ref="{urn:oasis:names:tc:SAML:2.0:assertion}
             AttributeValue" maxOccurs="unbounded" minOccurs="0"/>
            </sequence>
            <attribute name="FriendlyName"
            type="{http://www.w3.org/2001/XMLSchema}string" />
            <attribute name="Name" use="required"
            type="{http://www.w3.org/2001/XMLSchema}string" />
            <attribute name="NameFormat"
            type="{http://www.w3.org/2001/XMLSchema}anyURI" />
         </restriction>
       </complexContent>
     </complexType>
     
    • Constructor Detail

      • AttributeImpl

        public AttributeImpl()
        Class constructor. Caller may need to call setters to populate the object.
    • Method Detail

      • makeImmutable

        public void makeImmutable()
        Makes the object immutable.
        Specified by:
        makeImmutable in interface Attribute
      • isMutable

        public boolean isMutable()
        Returns the mutability of the object.
        Specified by:
        isMutable in interface Attribute
        Returns:
        true if the object is mutable; false otherwise.
      • getAttributeValue

        public List getAttributeValue()
        Returns the AttributeValue(s) of the Attribute.
        Specified by:
        getAttributeValue in interface Attribute
        Returns:
        List of xml String representing AttributeValue(s) of the Attribute.
        See Also:
        setAttributeValue(List)
      • setAttributeValue

        public void setAttributeValue​(List value)
                               throws SAML2Exception
        Sets the AttributeValue(s) of the Attribute.
        Specified by:
        setAttributeValue in interface Attribute
        Parameters:
        value - List of xml String representing the new AttributeValue element(s).
        Throws:
        SAML2Exception - if the object is immutable or the input can not be converted to AttributeValue element.
        See Also:
        getAttributeValue()
      • getAnyAttribute

        public Map getAnyAttribute()
        Returns the anyAttribute of the attribute.
        Specified by:
        getAnyAttribute in interface Attribute
        Returns:
        A Map containing name/value pairs of anyAttribute. Both the name and value are String object types.
        See Also:
        setAnyAttribute(Map)
      • setAnyAttribute

        public void setAnyAttribute​(Map value)
                             throws SAML2Exception
        Sets the anyAttribute of the attribute.
        Specified by:
        setAnyAttribute in interface Attribute
        Parameters:
        value - Map of name/value pairs to be set. Both the name and value are String object types.
        Throws:
        SAML2Exception - if the object is immutable.
        See Also:
        getAnyAttribute()
      • encrypt

        public EncryptedAttribute encrypt​(Key recipientPublicKey,
                                          String dataEncAlgorithm,
                                          int dataEncStrength,
                                          String recipientEntityID)
                                   throws SAML2Exception
        Returns an EncryptedAttribute object.
        Specified by:
        encrypt in interface Attribute
        Parameters:
        recipientPublicKey - Public key used to encrypt the data encryption (secret) key, it is the public key of the recipient of the XML document to be encrypted.
        dataEncAlgorithm - Data encryption algorithm.
        dataEncStrength - Data encryption strength.
        recipientEntityID - Unique identifier of the recipient, it is used as the index to the cached secret key so that the key can be reused for the same recipient; It can be null in which case the secret key will be generated every time and will not be cached and reused. Note that the generation of a secret key is a relatively expensive operation.
        Returns:
        EncryptedAttribute object
        Throws:
        SAML2Exception - if error occurs during the encryption process.
      • toXMLString

        public String toXMLString()
                           throws SAML2Exception
        Returns a String representation of the element.
        Specified by:
        toXMLString in interface Attribute
        Returns:
        A string containing the valid XML for this element. By default name space name is prepended to the element name.
        Throws:
        SAML2Exception - if the object does not conform to the schema.
      • toXMLString

        public String toXMLString​(boolean includeNS,
                                  boolean declareNS)
                           throws SAML2Exception
        Returns a String representation of the element.
        Specified by:
        toXMLString in interface Attribute
        Parameters:
        includeNS - Determines whether or not the namespace qualifier is prepended to the Element when converted
        declareNS - Determines whether or not the namespace is declared within the Element.
        Returns:
        A string containing the valid XML for this element
        Throws:
        SAML2Exception - if the object does not conform to the schema.