Class SecurityTokenReference


  • public class SecurityTokenReference
    extends Object
    Security Token Reference.
    • Constructor Detail

      • SecurityTokenReference

        public SecurityTokenReference​(Document doc)
        Constructor.
        Parameters:
        doc - The Document
    • Method Detail

      • addWSSENamespace

        public void addWSSENamespace()
        Add the WSSE Namespace to this STR. The namespace is not added by default for efficiency purposes.
      • addWSUNamespace

        public void addWSUNamespace()
        Add the WSU Namespace to this STR. The namespace is not added by default for efficiency purposes.
      • addTokenType

        public void addTokenType​(String tokenType)
        Add a wsse11:TokenType attribute to this SecurityTokenReference
        Parameters:
        tokenType - the wsse11:TokenType attribute to add
      • getTokenType

        public String getTokenType()
        Get the wsse11:TokenType attribute of this SecurityTokenReference
        Returns:
        the value of the wsse11:TokenType attribute
      • setReference

        public void setReference​(Reference ref)
        set the reference.
        Parameters:
        ref -
      • setKeyIdentifier

        public void setKeyIdentifier​(X509Certificate cert)
                              throws WSSecurityException
        Sets the KeyIdentifier Element as a X509 certificate. Takes a X509 certificate, converts its data into base 64 and inserts it into a wsse:KeyIdentifier element, which is placed in the wsse:SecurityTokenReference element.
        Parameters:
        cert - is the X509 certificate to be inserted as key identifier
        Throws:
        WSSecurityException
      • setKeyIdentifierSKI

        public void setKeyIdentifierSKI​(X509Certificate cert,
                                        Crypto crypto)
                                 throws WSSecurityException
        Sets the KeyIdentifier Element as a X509 Subject-Key-Identifier (SKI). Takes a X509 certificate, gets the SKI data, converts it into base 64 and inserts it into a wsse:KeyIdentifier element, which is placed in the wsse:SecurityTokenReference element.
        Parameters:
        cert - is the X509 certificate to get the SKI
        crypto - is the Crypto implementation. Used to read SKI info bytes from certificate
        Throws:
        WSSecurityException
      • setKeyIdentifierThumb

        public void setKeyIdentifierThumb​(X509Certificate cert)
                                   throws WSSecurityException
        Sets the KeyIdentifier Element as a Thumbprint. Takes a X509 certificate, computes its thumbprint using SHA-1, converts into base 64 and inserts it into a wsse:KeyIdentifier element, which is placed in the wsse:SecurityTokenReference element.
        Parameters:
        cert - is the X509 certificate to get the thumbprint
        Throws:
        WSSecurityException
      • getFirstElement

        public Element getFirstElement()
        get the first child element.
        Returns:
        the first Element child node
      • getKeyIdentifierValue

        public String getKeyIdentifierValue()
      • getKeyIdentifierValueType

        public String getKeyIdentifierValueType()
      • getKeyIdentifierEncodingType

        public String getKeyIdentifierEncodingType()
      • getSKIBytes

        public byte[] getSKIBytes()
      • setUnknownElement

        public void setUnknownElement​(Element unknownElement)
        Set an unknown element.
        Parameters:
        unknownElement - the org.w3c.dom.Element to put into this SecurityTokenReference
      • containsReference

        public boolean containsReference()
        Method containsReference
        Returns:
        true if the SecurityTokenReference contains a wsse:Reference element
      • containsX509IssuerSerial

        public boolean containsX509IssuerSerial()
        Method containsX509IssuerSerial
        Returns:
        true if the SecurityTokenReference contains a ds:IssuerSerial element
      • containsX509Data

        public boolean containsX509Data()
        Method containsX509Data
        Returns:
        true if the SecurityTokenReference contains a ds:X509Data element
      • containsKeyIdentifier

        public boolean containsKeyIdentifier()
        Method containsKeyIdentifier.
        Returns:
        true if the SecurityTokenReference contains a wsse:KeyIdentifier element
      • getElement

        public Element getElement()
        Get the DOM element.
        Returns:
        the DOM element
      • setID

        public void setID​(String id)
        set the id.
        Parameters:
        id -
      • getID

        public String getID()
        Get the id
        Returns:
        the wsu ID of the element
      • toString

        public String toString()
        return the string representation.
        Overrides:
        toString in class Object
        Returns:
        a representation of this SecurityTokenReference element as a String
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object