Class AbstractDOMSignatureMethod
java.lang.Object
org.apache.jcp.xml.dsig.internal.dom.DOMStructure
org.apache.jcp.xml.dsig.internal.dom.AbstractDOMSignatureMethod
- All Implemented Interfaces:
AlgorithmMethod, SignatureMethod, XMLStructure
- Direct Known Subclasses:
DOMHMACSignatureMethod, DOMSignatureMethod
An abstract class representing a SignatureMethod. Subclasses implement
a specific XML DSig signature algorithm.
-
Nested Class Summary
Nested Classes -
Field Summary
Fields inherited from interface SignatureMethod
DSA_SHA1, HMAC_SHA1, RSA_SHA1 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) voidChecks if the specified parameters are valid for this algorithm.boolean(package private) abstract AbstractDOMSignatureMethod.TypeReturns the type of signature algorithm.(package private) abstract StringReturns the java.security.Signature or javax.crypto.Mac standard algorithm name.inthashCode()voidmarshal(Node parent, String dsPrefix, DOMCryptoContext context) This method invokes themarshalParamsmethod to marshal any algorithm-specific parameters.(package private) voidmarshalParams(Element parent, String paramsPrefix) Marshals the algorithm-specific parameters to an Element and appends it to the specified parent element.(package private) booleanReturns true if parameters are equal; false otherwise.(package private) abstract byte[]sign(Key key, SignedInfo si, XMLSignContext context) Signs the bytes with the specified key, using the underlying Signature or Mac algorithm.(package private) SignatureMethodParameterSpecunmarshalParams(Element paramsElem) UnmarshalsSignatureMethodParameterSpecfrom the specifiedElement.(package private) abstract booleanverify(Key key, SignedInfo si, byte[] sig, XMLValidateContext context) Verifies the passed-in signature with the specified key, using the underlying Signature or Mac algorithm.Methods inherited from class DOMStructure
isFeatureSupportedMethods inherited from class Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface AlgorithmMethod
getAlgorithmMethods inherited from interface SignatureMethod
getParameterSpecMethods inherited from interface XMLStructure
isFeatureSupported
-
Constructor Details
-
AbstractDOMSignatureMethod
AbstractDOMSignatureMethod()
-
-
Method Details
-
verify
abstract boolean verify(Key key, SignedInfo si, byte[] sig, XMLValidateContext context) throws InvalidKeyException, SignatureException, XMLSignatureException Verifies 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:
NullPointerException- ifkey,siorsigarenullInvalidKeyException- if the key is improperly encoded, of the wrong type, or parameters are missing, etcSignatureException- if an unexpected error occurs, such as the passed in signature is improperly encodedXMLSignatureException- if an unexpected error occurs
-
sign
abstract byte[] sign(Key key, SignedInfo si, XMLSignContext context) throws InvalidKeyException, XMLSignatureException Signs 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:
NullPointerException- ifkeyorsiarenullInvalidKeyException- if the key is improperly encoded, of the wrong type, or parameters are missing, etcXMLSignatureException- if an unexpected error occurs
-
getJCAAlgorithm
Returns the java.security.Signature or javax.crypto.Mac standard algorithm name. -
getAlgorithmType
Returns the type of signature algorithm. -
marshal
This method invokes themarshalParamsmethod to marshal any algorithm-specific parameters.- Specified by:
marshalin classDOMStructure- Throws:
MarshalException
-
marshalParams
Marshals 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:
MarshalException- if the parameters cannot be marshalled
-
unmarshalParams
UnmarshalsSignatureMethodParameterSpecfrom 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:
MarshalException- if the parameters cannot be unmarshalled
-
checkParams
Checks 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:
InvalidAlgorithmParameterException- if the parameters are not appropriate for this signature method
-
equals
-
hashCode
-
paramsEqual
Returns true if parameters are equal; false otherwise. Subclasses should override this method to compare algorithm-specific parameters.
-