Class AbstractDOMSignatureMethod
- java.lang.Object
-
- org.apache.jcp.xml.dsig.internal.dom.DOMStructure
-
- org.apache.jcp.xml.dsig.internal.dom.AbstractDOMSignatureMethod
-
- All Implemented Interfaces:
javax.xml.crypto.AlgorithmMethod,javax.xml.crypto.dsig.SignatureMethod,javax.xml.crypto.XMLStructure
- Direct Known Subclasses:
DOMHMACSignatureMethod,DOMSignatureMethod
abstract class AbstractDOMSignatureMethod extends DOMStructure implements javax.xml.crypto.dsig.SignatureMethod
An abstract class representing a SignatureMethod. Subclasses implement a specific XML DSig signature algorithm.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classAbstractDOMSignatureMethod.Type
-
Constructor Summary
Constructors Constructor Description AbstractDOMSignatureMethod()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description (package private) voidcheckParams(javax.xml.crypto.dsig.spec.SignatureMethodParameterSpec params)Checks if the specified parameters are valid for this algorithm.booleanequals(java.lang.Object o)(package private) abstract AbstractDOMSignatureMethod.TypegetAlgorithmType()Returns the type of signature algorithm.(package private) abstract java.lang.StringgetJCAAlgorithm()Returns the java.security.Signature or javax.crypto.Mac standard algorithm name.inthashCode()voidmarshal(org.w3c.dom.Node parent, java.lang.String dsPrefix, javax.xml.crypto.dom.DOMCryptoContext context)This method invokes themarshalParamsmethod to marshal any algorithm-specific parameters.(package private) voidmarshalParams(org.w3c.dom.Element parent, java.lang.String paramsPrefix)Marshals the algorithm-specific parameters to an Element and appends it to the specified parent element.(package private) booleanparamsEqual(java.security.spec.AlgorithmParameterSpec spec)Returns true if parameters are equal; false otherwise.(package private) abstract byte[]sign(java.security.Key key, javax.xml.crypto.dsig.SignedInfo si, javax.xml.crypto.dsig.XMLSignContext context)Signs the bytes with the specified key, using the underlying Signature or Mac algorithm.(package private) javax.xml.crypto.dsig.spec.SignatureMethodParameterSpecunmarshalParams(org.w3c.dom.Element paramsElem)UnmarshalsSignatureMethodParameterSpecfrom the specifiedElement.(package private) abstract booleanverify(java.security.Key key, javax.xml.crypto.dsig.SignedInfo si, byte[] sig, javax.xml.crypto.dsig.XMLValidateContext context)Verifies the passed-in signature with the specified key, using the underlying Signature or Mac algorithm.-
Methods inherited from class org.apache.jcp.xml.dsig.internal.dom.DOMStructure
isFeatureSupported
-
-
-
-
Method Detail
-
verify
abstract boolean verify(java.security.Key key, javax.xml.crypto.dsig.SignedInfo si, byte[] sig, javax.xml.crypto.dsig.XMLValidateContext context) throws java.security.InvalidKeyException, java.security.SignatureException, javax.xml.crypto.dsig.XMLSignatureExceptionVerifies the passed-in signature with the specified key, using the underlying Signature or Mac algorithm.- Parameters:
key- the verification keysi- the SignedInfosig- the signature bytes to be verifiedcontext- the XMLValidateContext- Returns:
trueif the signature verified successfully,falseif not- Throws:
java.lang.NullPointerException- ifkey,siorsigarenulljava.security.InvalidKeyException- if the key is improperly encoded, of the wrong type, or parameters are missing, etcjava.security.SignatureException- if an unexpected error occurs, such as the passed in signature is improperly encodedjavax.xml.crypto.dsig.XMLSignatureException- if an unexpected error occurs
-
sign
abstract byte[] sign(java.security.Key key, javax.xml.crypto.dsig.SignedInfo si, javax.xml.crypto.dsig.XMLSignContext context) throws java.security.InvalidKeyException, javax.xml.crypto.dsig.XMLSignatureExceptionSigns the bytes with the specified key, using the underlying Signature or Mac algorithm.- Parameters:
key- the signing keysi- the SignedInfocontext- the XMLSignContext- Returns:
- the signature
- Throws:
java.lang.NullPointerException- ifkeyorsiarenulljava.security.InvalidKeyException- if the key is improperly encoded, of the wrong type, or parameters are missing, etcjavax.xml.crypto.dsig.XMLSignatureException- if an unexpected error occurs
-
getJCAAlgorithm
abstract java.lang.String getJCAAlgorithm()
Returns the java.security.Signature or javax.crypto.Mac standard algorithm name.
-
getAlgorithmType
abstract AbstractDOMSignatureMethod.Type getAlgorithmType()
Returns the type of signature algorithm.
-
marshal
public void marshal(org.w3c.dom.Node parent, java.lang.String dsPrefix, javax.xml.crypto.dom.DOMCryptoContext context) throws javax.xml.crypto.MarshalExceptionThis method invokes themarshalParamsmethod to marshal any algorithm-specific parameters.- Specified by:
marshalin classDOMStructure- Throws:
javax.xml.crypto.MarshalException
-
marshalParams
void marshalParams(org.w3c.dom.Element parent, java.lang.String paramsPrefix) throws javax.xml.crypto.MarshalExceptionMarshals the algorithm-specific parameters to an Element and appends it to the specified parent element. By default, this method throws an exception since most SignatureMethod algorithms do not have parameters. Subclasses should override it if they have parameters.- Parameters:
parent- the parent element to append the parameters toparamsPrefix- the algorithm parameters prefix to use- Throws:
javax.xml.crypto.MarshalException- if the parameters cannot be marshalled
-
unmarshalParams
javax.xml.crypto.dsig.spec.SignatureMethodParameterSpec unmarshalParams(org.w3c.dom.Element paramsElem) throws javax.xml.crypto.MarshalExceptionUnmarshalsSignatureMethodParameterSpecfrom the specifiedElement. By default, this method throws an exception since most SignatureMethod algorithms do not have parameters. Subclasses should override it if they have parameters.- Parameters:
paramsElem- theElementholding the input params- Returns:
- the algorithm-specific
SignatureMethodParameterSpec - Throws:
javax.xml.crypto.MarshalException- if the parameters cannot be unmarshalled
-
checkParams
void checkParams(javax.xml.crypto.dsig.spec.SignatureMethodParameterSpec params) throws java.security.InvalidAlgorithmParameterExceptionChecks if the specified parameters are valid for this algorithm. By default, this method throws an exception if parameters are specified since most SignatureMethod algorithms do not have parameters. Subclasses should override it if they have parameters.- Parameters:
params- the algorithm-specific params (may benull)- Throws:
java.security.InvalidAlgorithmParameterException- if the parameters are not appropriate for this signature method
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
paramsEqual
boolean paramsEqual(java.security.spec.AlgorithmParameterSpec spec)
Returns true if parameters are equal; false otherwise. Subclasses should override this method to compare algorithm-specific parameters.
-
-