Class EPPAuthTokenData

java.lang.Object
com.verisign.epp.codec.authtoken.v01.EPPAuthTokenData
All Implemented Interfaces:
EPPCodecComponent, Serializable, Cloneable

public class EPPAuthTokenData extends Object implements EPPCodecComponent
The EPPAuthTokenData is the EPPCodecComponent that knows how to encode and decode keyData elements from/to XML and object instance.
See Also:
  • Field Details

  • Constructor Details

    • EPPAuthTokenData

      public EPPAuthTokenData()
      Create a new instance of EPPAuthTokenData
    • EPPAuthTokenData

      public EPPAuthTokenData(String aAuthToken) throws EPPDecodeException
      Creates a new instance of EPPAuthTokenData object from the required auth token string. It decodes the given JWS String into header EPPAuthTokenHeader payload EPPAuthTokenPayload and signature String components.

      Throws EPPDecodeException if the string is an invalid JWS
      Throws:
      EPPDecodeException
    • EPPAuthTokenData

      public EPPAuthTokenData(EPPAuthTokenHeader header, EPPAuthTokenPayload payload)
      Create a new instance of EPPAuthTokenData with the required header and payload data. It is required that the caller sets the required signature by invoking sign() method on this instance.
      Parameters:
      header -
      payload -
    • EPPAuthTokenData

      public EPPAuthTokenData(EPPAuthTokenHeader header, EPPAuthTokenPayload payload, String signature)
      Create a new instance of EPPAuthTokenData with the required header, payload and signature data.
      Parameters:
      header -
      payload -
      signature -
  • Method Details

    • encode

      public Element encode(Document aDocument) throws EPPEncodeException
      Append all data from this authToken:authToken to the given DOM Document
      Specified by:
      encode in interface EPPCodecComponent
      Parameters:
      aDocument - The DOM Document to append data to
      Returns:
      Encoded DOM Element
      Throws:
      EPPEncodeException - Thrown when errors occur during the encode attempt or if the instance is invalid.
    • decode

      public void decode(Element aElement) throws EPPDecodeException
      Populate the data of this instance with the data stored in the given Element of the DOM tree
      Specified by:
      decode in interface EPPCodecComponent
      Parameters:
      aElement - The root element of the fragment of XML
      Throws:
      EPPDecodeException - Thrown if any errors occur during decoding.
    • equals

      public boolean equals(Object aObject)
      implements a deep EPPAuthTokenData compare.
      Overrides:
      equals in class Object
      Parameters:
      aObject - EPPAuthTokenData instance to compare with
      Returns:
      true if equal false otherwise
    • clone

      public Object clone() throws CloneNotSupportedException
      Clone EPPAuthTokenData.
      Specified by:
      clone in interface EPPCodecComponent
      Overrides:
      clone in class Object
      Returns:
      clone of EPPAuthTokenData
      Throws:
      CloneNotSupportedException - standard Object.clone exception
    • getValue

      public String getValue()
      Get the signed and encoded auth token value.
      Returns:
      auth token
    • setValue

      public void setValue(String aCompactToken)
      Set the signed and encoded auth token value.
      Parameters:
      aCompactToken - auth token.
    • getHeader

      public EPPAuthTokenHeader getHeader()
      Return EPPAuthTokenHeader instance
      Returns:
    • setHeader

      public void setHeader(EPPAuthTokenHeader header)
      Set EPPAuthTokenHeader instance
      Parameters:
      header -
    • getPayload

      public EPPAuthTokenPayload getPayload()
      Return EPPAuthTokenPayload instance
      Returns:
    • setPayload

      public void setPayload(EPPAuthTokenPayload payload)
      Set EPPAuthTokenPayload instance
      Parameters:
      payload -
    • getSignature

      public String getSignature()
      Return signature value
      Returns:
    • setSignature

      public void setSignature(String signature)
      Set signature value
      Parameters:
      signature -
    • sign

      public String sign(PrivateKey aPrivateKey) throws EPPException
      Digitally sign the signed code using the passed private key and a chain of certificates.
      Parameters:
      aPrivateKey - Private key used to sign the signed code
      Throws:
      EPPException - Error creating the digital signature
    • sign

      public String sign(String aKeyStoreName, String aKeyAliasName, String aPassword) throws Exception
      Digitally sign the auth token with the private key from the given keystore, keyAlias and password.
      Parameters:
      aKeyStoreName -
      aKeyAliasName -
      aPassword -
      Returns:
      Throws:
      Exception
    • sign

      public String sign(String aKeyAliasName) throws EPPException
      Digitally sign the auth token with the private key from the given keyAlias.
      Parameters:
      aKeyAliasName -
      Returns:
      signature value as String
      Throws:
      EPPException
    • sign

      public String sign() throws EPPException
      Digitally sign the auth token with the private key. It derives the private key from the kid in the header.
      Returns:
      signature value as String
      Throws:
      EPPException
    • validate

      public boolean validate() throws EPPException
      Validate the signature attribute using the first valid public key.
      Returns:
      true if the signature is valid otherwise false.
      Throws:
      EPPException
    • validate

      public boolean validate(io.jsonwebtoken.JwtParser aParser)
      Validate the signature attribute.
      Parameters:
      aParser - pre initialized parser to validate the signature
      Returns:
      true if valid; false otherwise.
    • validate

      public boolean validate(PublicKey aPublicKey) throws Exception
      Validate the signature attribute. Since the parser is initialized here, this is expensive.
      Parameters:
      aPublicKey - Public used to validate the signature
      Returns:
      true if valid; false otherwise.
      Throws:
      Exception
    • validate

      public boolean validate(String aKeyStoreName, String aPublicKeyAlias, String aPassword) throws Exception
      Validate the signature attribute.
      Parameters:
      aKeyStoreName - JKS file name
      aPublicKeyAlias - key alias of the key in JKS
      aPassword - password for JKS
      Returns:
      true if valid; false otherwise.
      Throws:
      Exception - Error while loading the key or validating the signature
    • toString

      public String toString()
      Implementation of Object.toString, which will result in an indented XML String representation of the concrete EPPCodecComponent.
      Overrides:
      toString in class Object
      Returns:
      Indented XML String if successful; ERROR otherwise.
    • getNamespace

      public String getNamespace()
      Returns the XML namespace associated with the EPPCodecComponent.
      Specified by:
      getNamespace in interface EPPCodecComponent
      Returns:
      XML namespace for the EPPCodecComponent.
    • loadPrivateKey

      public PrivateKey loadPrivateKey(String aKeyStoreName, String aKeyAliasName, String aPassword) throws Exception
      Loads the private key used to digitally sign from a Java KeyStore with the aKeyAliasName alias and the aPassword password to access the Keystore and the key.
      Parameters:
      aKeyStoreName - Java Keystore to load the key from
      aKeyAliasName - Java Keystore alias of key
      aPassword - Password to access Java Keystore and key
      Returns:
      Loaded KeyStore.PrivateKeyEntry that can be used to get the private key and it's associated certificate chain.
      Throws:
      Exception - Error loading private key