Class EPPSignedCode

java.lang.Object
com.verisign.epp.codec.verificationcode.EPPSignedCode
All Implemented Interfaces:
EPPCodecComponent, Serializable, Cloneable
Direct Known Subclasses:
EPPEncodedSignedCodeValue

public class EPPSignedCode extends Object implements EPPCodecComponent
Class for the signed code, which contains the verification code and the XMLSignature.
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Constant for the code tag for signedCode element
    static final String
    Constant for the code local name for signedCode element
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create an EPPSignedCode instance.
    EPPSignedCode(byte[] aSignedCodeArray)
    Create the EPPSignedCode object from the input byte[] (XML).
    Convert an EPPEncodedSignedCode into an EPPSignedCode.
    Create an EPPSignedCode with the code of the signed code.
    EPPSignedCode(String aCode, String aType)
    Create an EPPSignedCode with the type and code of the signed code.
  • Method Summary

    Modifier and Type
    Method
    Description
    Clone EPPSignedCode.
    void
    decode(byte[] aSignedCodeArray)
    Create a DOM document from byte array.
    void
    decode(Element aElement)
    Decode the EPPSignedCode component
    byte[]
    Encode the signed code to a byte[].
    encode(Document aDocument)
    Sets all this instance's data in the given XML document
    boolean
    equals(Object aObject)
    implements a deep EPPSignedCode compare.
    Gets the "id" attribute value.
    Gets the code value associated with the signed code.
    Gets the code type of the contained code.
    Gets the code value of the contained code.
    Gets the XML local name for the signed code.
    Returns the XML namespace associated with the EPPCodecComponent.
    Gets the Trust Anchor associated with the validated signed code.
    boolean
    Has the Trust Anchor been set?
    void
    sign(PrivateKey aPrivateKey)
    Digitally sign the signed code using the passed private key.
    void
    sign(PrivateKey aPrivateKey, Certificate[] aCertChain)
    Digitally sign the signed code using the passed private key and a chain of certificates.
    Implementation of Object.toString, which will result in an indented XML String representation of the concrete EPPCodecComponent.
    boolean
    validate(PKIXParameters aPKIXParameters)
    Validate the signature attribute against the signed code attributes by using the public key of the certificate or the top certificate in the certificate chain contained in the XMLSignature with using the passed PKIX parameters to the PKIX CertPathValidator algorithm.
    boolean
    validate(PKIXParameters aPKIXParameters, boolean aSynchronizePKIXParameters)
    Validate the signature attribute against the signed code attributes by using the public key of the certificate or the top certificate in the certificate chain contained in the XMLSignature with using the passed PKIX parameters to the PKIX CertPathValidator algorithm.
    boolean
    validate(PublicKey aPublicKey)
    Validate the signature attribute against the signed code attributes.

    Methods inherited from class java.lang.Object

    finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • ELM_SIGNED_CODE_LOCALNAME

      public static final String ELM_SIGNED_CODE_LOCALNAME
      Constant for the code local name for signedCode element
      See Also:
    • ELM_SIGNED_CODE

      public static final String ELM_SIGNED_CODE
      Constant for the code tag for signedCode element
      See Also:
  • Constructor Details

    • EPPSignedCode

      public EPPSignedCode()
      Create an EPPSignedCode instance.
    • EPPSignedCode

      public EPPSignedCode(EPPEncodedSignedCodeValue aEncodedSignedCode)
      Convert an EPPEncodedSignedCode into an EPPSignedCode.
      Parameters:
      aEncodedSignedCode - EPPEncodedSignedCode to convert from.
    • EPPSignedCode

      public EPPSignedCode(EPPVerificationCode aCode) throws EPPEncodeException
      Create an EPPSignedCode with the code of the signed code. The default encoding is XML and the signature must be generated by calling sign(PrivateKey). Once the object is created using this constructor, one should not update the object. In the case the object gets updated, changes will not be included in XML/signature.
      Parameters:
      aCode - Verification code
      Throws:
      EPPEncodeException - Thrown if any errors prevent encoding.
    • EPPSignedCode

      public EPPSignedCode(String aCode, String aType) throws EPPEncodeException
      Create an EPPSignedCode with the type and code of the signed code. The default encoding is XML and the signature must be generated by calling sign(PrivateKey). Once the object is created using this constructor, one should not update the object. In the case the object gets updated, changes will not be included in XML/signature.
      Parameters:
      aCode - Verification code
      aType - Type of the verification code
      Throws:
      EPPEncodeException - Thrown if any errors prevent encoding.
    • EPPSignedCode

      public EPPSignedCode(byte[] aSignedCodeArray) throws EPPDecodeException
      Create the EPPSignedCode object from the input byte[] (XML).
      Parameters:
      aSignedCodeArray - byte[] to decode the attribute values
      Throws:
      EPPDecodeException - Error decoding the byte[].
  • Method Details

    • decode

      public void decode(Element aElement) throws EPPDecodeException
      Decode the EPPSignedCode component
      Specified by:
      decode in interface EPPCodecComponent
      Parameters:
      aElement - Root element of the EPPSignedCode
      Throws:
      EPPDecodeException - Error decoding the EPPSignedCode
    • decode

      public void decode(byte[] aSignedCodeArray) throws EPPDecodeException
      Create a DOM document from byte array. Initialized the instance variables like code, issuer etc. Sets the signedCodeElement.
      Parameters:
      aSignedCodeArray - byte[] to decode the attribute values
      Throws:
      EPPDecodeException - Error decoding the byte[].
    • encode

      public byte[] encode() throws EPPEncodeException
      Encode the signed code to a byte[].
      Returns:
      byte[] representing signed code
      Throws:
      EPPEncodeException - Error encoding the signed code
    • encode

      public Element encode(Document aDocument) throws EPPEncodeException
      Sets all this instance's data in the given XML document
      Specified by:
      encode in interface EPPCodecComponent
      Parameters:
      aDocument - a DOM Document to attach data to.
      Returns:
      The root element of this component.
      Throws:
      EPPEncodeException - Thrown if any errors prevent encoding.
    • clone

      public Object clone() throws CloneNotSupportedException
      Clone EPPSignedCode. Signature element is not cloned.
      Specified by:
      clone in interface EPPCodecComponent
      Overrides:
      clone in class Object
      Returns:
      clone of EPPSignedCode
      Throws:
      CloneNotSupportedException - standard Object.clone exception
    • sign

      public void sign(PrivateKey aPrivateKey) throws EPPException
      Digitally sign the signed code using the passed private key. No certificates will be added using this method. If certificates need to be added use sign(PrivateKey, Certificate[]).
      Parameters:
      aPrivateKey - Private key used to sign the signed code
      Throws:
      EPPException - Error creating the digital signature
    • sign

      public void sign(PrivateKey aPrivateKey, Certificate[] aCertChain) 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
      aCertChain - Certificate chain to include in the XMLSignature associated with the private key. Pass null to not include the certificate chain in the XMLSignature.
      Throws:
      EPPException - Error creating the digital signature
    • validate

      public boolean validate(PKIXParameters aPKIXParameters)
      Validate the signature attribute against the signed code attributes by using the public key of the certificate or the top certificate in the certificate chain contained in the XMLSignature with using the passed PKIX parameters to the PKIX CertPathValidator algorithm. The trust store can be loaded and used to create an instance of PKIXParameters to verify the certificate chain included in the XMLSignature with the trust anchors included in the trust store. This method will automatically synchronize the aPKIXParameters parameter when used, since it is not thread-safe. Use validate(PKIXParameters, boolean) to explicitly set the aPKIXParameters synchronization setting.
      Parameters:
      aPKIXParameters - Parameters used as input for the PKIX CertPathValidator algorithm.
      Returns:
      true if valid; false otherwise.
    • validate

      public boolean validate(PKIXParameters aPKIXParameters, boolean aSynchronizePKIXParameters)
      Validate the signature attribute against the signed code attributes by using the public key of the certificate or the top certificate in the certificate chain contained in the XMLSignature with using the passed PKIX parameters to the PKIX CertPathValidator algorithm. The trust store can be loaded and used to create an instance of PKIXParameters to verify the certificate chain included in the XMLSignature with the trust anchors included in the trust store.
      Parameters:
      aPKIXParameters - Parameters used as input for the PKIX CertPathValidator algorithm.
      aSynchronizePKIXParameters - Should the aPKIXParameters be synchronized inside the method? If there is no reason to synchronize, then false can be passed to increase performance.
      Returns:
      true if valid; false otherwise.
    • validate

      public boolean validate(PublicKey aPublicKey)
      Validate the signature attribute against the signed code attributes.
      Parameters:
      aPublicKey - Public used to validate the signature
      Returns:
      true if valid; false otherwise.
    • equals

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

      public String getLocalName()
      Gets the XML local name for the signed code.
      Returns:
      Either ELM_SIGNED_MARK_LOCALNAME or ELM_ENCODED_SIGNED_MARK_LOCALNAME
    • getCode

      public EPPVerificationCode getCode()
      Gets the code value associated with the signed code.
      Returns:
      The code associated with the signed code if defined: null otherwise.
    • getCodeValue

      public String getCodeValue()
      Gets the code value of the contained code.
      Returns:
      Verification code value
    • getCodeType

      public String getCodeType()
      Gets the code type of the contained code.
      Returns:
      Verification code type
    • getAttrIdValue

      public String getAttrIdValue()
      Gets the "id" attribute value.
      Returns:
      Value of the "id" attribute value.
    • hasTrustAnchor

      public boolean hasTrustAnchor()
      Has the Trust Anchor been set?
      Returns:
      true if the Trust Anchor has been set; false otherwise.
    • getTrustAnchor

      public TrustAnchor getTrustAnchor()
      Gets the Trust Anchor associated with the validated signed code.
      Returns:
      Trust Anchor if defined; null otherwise.
    • 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.