Class EPPSignedCode
- java.lang.Object
-
- com.verisign.epp.codec.verificationcode.EPPSignedCode
-
- All Implemented Interfaces:
EPPCodecComponent
,java.io.Serializable
,java.lang.Cloneable
- Direct Known Subclasses:
EPPEncodedSignedCodeValue
public class EPPSignedCode extends java.lang.Object implements EPPCodecComponent
Class for the signed code, which contains the verification code and theXMLSignature
.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ELM_SIGNED_CODE
Constant for the code tag for signedCode elementstatic java.lang.String
ELM_SIGNED_CODE_LOCALNAME
Constant for the code local name for signedCode element
-
Constructor Summary
Constructors Constructor Description EPPSignedCode()
Create anEPPSignedCode
instance.EPPSignedCode(byte[] aSignedCodeArray)
Create theEPPSignedCode
object from the inputbyte[]
(XML).EPPSignedCode(EPPEncodedSignedCodeValue aEncodedSignedCode)
Convert anEPPEncodedSignedCode
into anEPPSignedCode
.EPPSignedCode(EPPVerificationCode aCode)
Create anEPPSignedCode
with the code of the signed code.EPPSignedCode(java.lang.String aCode, java.lang.String aType)
Create anEPPSignedCode
with the type and code of the signed code.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
clone()
CloneEPPSignedCode
.void
decode(byte[] aSignedCodeArray)
Create a DOM document from byte array.void
decode(org.w3c.dom.Element aElement)
Decode theEPPSignedCode
componentbyte[]
encode()
Encode the signed code to abyte[]
.org.w3c.dom.Element
encode(org.w3c.dom.Document aDocument)
Sets all this instance's data in the given XML documentboolean
equals(java.lang.Object aObject)
implements a deepEPPSignedCode
compare.java.lang.String
getAttrIdValue()
Gets the "id" attribute value.EPPVerificationCode
getCode()
Gets the code value associated with the signed code.java.lang.String
getCodeType()
Gets the code type of the contained code.java.lang.String
getCodeValue()
Gets the code value of the contained code.java.lang.String
getLocalName()
Gets the XML local name for the signed code.java.lang.String
getNamespace()
Returns the XML namespace associated with theEPPCodecComponent
.java.security.cert.TrustAnchor
getTrustAnchor()
Gets the Trust Anchor associated with the validated signed code.boolean
hasTrustAnchor()
Has the Trust Anchor been set?void
sign(java.security.PrivateKey aPrivateKey)
Digitally sign the signed code using the passed private key.void
sign(java.security.PrivateKey aPrivateKey, java.security.cert.Certificate[] aCertChain)
Digitally sign the signed code using the passed private key and a chain of certificates.java.lang.String
toString()
Implementation ofObject.toString
, which will result in an indented XMLString
representation of the concreteEPPCodecComponent
.boolean
validate(java.security.cert.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 theXMLSignature
with using the passed PKIX parameters to the PKIXCertPathValidator
algorithm.boolean
validate(java.security.cert.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 theXMLSignature
with using the passed PKIX parameters to the PKIXCertPathValidator
algorithm.boolean
validate(java.security.PublicKey aPublicKey)
Validate the signature attribute against the signed code attributes.
-
-
-
Field Detail
-
ELM_SIGNED_CODE_LOCALNAME
public static final java.lang.String ELM_SIGNED_CODE_LOCALNAME
Constant for the code local name for signedCode element- See Also:
- Constant Field Values
-
ELM_SIGNED_CODE
public static final java.lang.String ELM_SIGNED_CODE
Constant for the code tag for signedCode element- See Also:
- Constant Field Values
-
-
Constructor Detail
-
EPPSignedCode
public EPPSignedCode()
Create anEPPSignedCode
instance.
-
EPPSignedCode
public EPPSignedCode(EPPEncodedSignedCodeValue aEncodedSignedCode)
Convert anEPPEncodedSignedCode
into anEPPSignedCode
.- Parameters:
aEncodedSignedCode
-EPPEncodedSignedCode
to convert from.
-
EPPSignedCode
public EPPSignedCode(EPPVerificationCode aCode) throws EPPEncodeException
Create anEPPSignedCode
with the code of the signed code. The default encoding is XML and the signature must be generated by callingsign(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(java.lang.String aCode, java.lang.String aType) throws EPPEncodeException
Create anEPPSignedCode
with the type and code of the signed code. The default encoding is XML and the signature must be generated by callingsign(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 codeaType
- Type of the verification code- Throws:
EPPEncodeException
- Thrown if any errors prevent encoding.
-
EPPSignedCode
public EPPSignedCode(byte[] aSignedCodeArray) throws EPPDecodeException
Create theEPPSignedCode
object from the inputbyte[]
(XML).- Parameters:
aSignedCodeArray
-byte[]
to decode the attribute values- Throws:
EPPDecodeException
- Error decoding thebyte[]
.
-
-
Method Detail
-
decode
public void decode(org.w3c.dom.Element aElement) throws EPPDecodeException
Decode theEPPSignedCode
component- Specified by:
decode
in interfaceEPPCodecComponent
- Parameters:
aElement
- Root element of theEPPSignedCode
- Throws:
EPPDecodeException
- Error decoding theEPPSignedCode
-
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 thebyte[]
.
-
encode
public byte[] encode() throws EPPEncodeException
Encode the signed code to abyte[]
.- Returns:
byte[]
representing signed code- Throws:
EPPEncodeException
- Error encoding the signed code
-
encode
public org.w3c.dom.Element encode(org.w3c.dom.Document aDocument) throws EPPEncodeException
Sets all this instance's data in the given XML document- Specified by:
encode
in interfaceEPPCodecComponent
- 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 java.lang.Object clone() throws java.lang.CloneNotSupportedException
CloneEPPSignedCode
. Signature element is not cloned.- Specified by:
clone
in interfaceEPPCodecComponent
- Overrides:
clone
in classjava.lang.Object
- Returns:
- clone of
EPPSignedCode
- Throws:
java.lang.CloneNotSupportedException
- standard Object.clone exception
-
sign
public void sign(java.security.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 usesign(PrivateKey, Certificate[])
.- Parameters:
aPrivateKey
- Private key used to sign the signed code- Throws:
EPPException
- Error creating the digital signature
-
sign
public void sign(java.security.PrivateKey aPrivateKey, java.security.cert.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 codeaCertChain
- Certificate chain to include in the XMLSignature associated with the private key. Passnull
to not include the certificate chain in the XMLSignature.- Throws:
EPPException
- Error creating the digital signature
-
validate
public boolean validate(java.security.cert.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 theXMLSignature
with using the passed PKIX parameters to the PKIXCertPathValidator
algorithm. The trust store can be loaded and used to create an instance ofPKIXParameters
to verify the certificate chain included in theXMLSignature
with the trust anchors included in the trust store. This method will automatically synchronize theaPKIXParameters
parameter when used, since it is not thread-safe. Usevalidate(PKIXParameters, boolean)
to explicitly set theaPKIXParameters
synchronization setting.- Parameters:
aPKIXParameters
- Parameters used as input for the PKIXCertPathValidator
algorithm.- Returns:
true
if valid;false
otherwise.
-
validate
public boolean validate(java.security.cert.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 theXMLSignature
with using the passed PKIX parameters to the PKIXCertPathValidator
algorithm. The trust store can be loaded and used to create an instance ofPKIXParameters
to verify the certificate chain included in theXMLSignature
with the trust anchors included in the trust store.- Parameters:
aPKIXParameters
- Parameters used as input for the PKIXCertPathValidator
algorithm.aSynchronizePKIXParameters
- Should theaPKIXParameters
be synchronized inside the method? If there is no reason to synchronize, thenfalse
can be passed to increase performance.- Returns:
true
if valid;false
otherwise.
-
validate
public boolean validate(java.security.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(java.lang.Object aObject)
implements a deepEPPSignedCode
compare.- Overrides:
equals
in classjava.lang.Object
- Parameters:
aObject
-EPPSignedCode
instance to compare with- Returns:
- true if equal false otherwise
-
getLocalName
public java.lang.String getLocalName()
Gets the XML local name for the signed code.- Returns:
- Either
ELM_SIGNED_MARK_LOCALNAME
orELM_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 java.lang.String getCodeValue()
Gets the code value of the contained code.- Returns:
- Verification code value
-
getCodeType
public java.lang.String getCodeType()
Gets the code type of the contained code.- Returns:
- Verification code type
-
getAttrIdValue
public java.lang.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 java.security.cert.TrustAnchor getTrustAnchor()
Gets the Trust Anchor associated with the validated signed code.- Returns:
- Trust Anchor if defined;
null
otherwise.
-
toString
public java.lang.String toString()
Implementation ofObject.toString
, which will result in an indented XMLString
representation of the concreteEPPCodecComponent
.- Overrides:
toString
in classjava.lang.Object
- Returns:
- Indented XML
String
if successful;ERROR
otherwise.
-
getNamespace
public java.lang.String getNamespace()
Returns the XML namespace associated with theEPPCodecComponent
.- Specified by:
getNamespace
in interfaceEPPCodecComponent
- Returns:
- XML namespace for the
EPPCodecComponent
.
-
-