Class DOMHMACSignatureMethod
java.lang.Object
org.apache.jcp.xml.dsig.internal.dom.DOMStructure
org.apache.jcp.xml.dsig.internal.dom.AbstractDOMSignatureMethod
org.apache.jcp.xml.dsig.internal.dom.DOMHMACSignatureMethod
- All Implemented Interfaces:
AlgorithmMethod
,SignatureMethod
,XMLStructure
- Direct Known Subclasses:
DOMHMACSignatureMethod.RIPEMD160
,DOMHMACSignatureMethod.SHA1
,DOMHMACSignatureMethod.SHA224
,DOMHMACSignatureMethod.SHA256
,DOMHMACSignatureMethod.SHA384
,DOMHMACSignatureMethod.SHA512
DOM-based implementation of HMAC SignatureMethod.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final class
(package private) static final class
(package private) static final class
(package private) static final class
(package private) static final class
(package private) static final class
Nested classes/interfaces inherited from class org.apache.jcp.xml.dsig.internal.dom.AbstractDOMSignatureMethod
AbstractDOMSignatureMethod.Type
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final String
private Mac
(package private) static final String
(package private) static final String
(package private) static final String
(package private) static final String
(package private) static final String
private static final org.slf4j.Logger
private int
private boolean
private SignatureMethodParameterSpec
Fields inherited from interface javax.xml.crypto.dsig.SignatureMethod
DSA_SHA1, DSA_SHA256, ECDSA_SHA1, ECDSA_SHA224, ECDSA_SHA256, ECDSA_SHA384, ECDSA_SHA512, HMAC_SHA1, RSA_PSS, RSA_SHA1, RSA_SHA224, RSA_SHA256, RSA_SHA384, RSA_SHA512, SHA1_RSA_MGF1, SHA224_RSA_MGF1, SHA256_RSA_MGF1, SHA384_RSA_MGF1, SHA512_RSA_MGF1
-
Constructor Summary
ConstructorsConstructorDescriptionCreates aDOMHMACSignatureMethod
with the specified paramsDOMHMACSignatureMethod
(Element smElem) Creates aDOMHMACSignatureMethod
from an element. -
Method Summary
Modifier and TypeMethodDescription(package private) void
Checks if the specified parameters are valid for this algorithm.(package private) AbstractDOMSignatureMethod.Type
Returns the type of signature algorithm.(package private) abstract int
Returns the output length of the hash/digest.final AlgorithmParameterSpec
(package private) void
marshalParams
(Element parent, String prefix) Marshals the algorithm-specific parameters to an Element and appends it to the specified parent element.(package private) boolean
Returns true if parameters are equal; false otherwise.(package private) byte[]
sign
(Key key, SignedInfo si, XMLSignContext context) Signs the bytes with the specified key, using the underlying Signature or Mac algorithm.(package private) SignatureMethodParameterSpec
unmarshalParams
(Element paramsElem) UnmarshalsSignatureMethodParameterSpec
from the specifiedElement
.(package private) boolean
verify
(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 org.apache.jcp.xml.dsig.internal.dom.AbstractDOMSignatureMethod
equals, getJCAAlgorithm, hashCode, marshal
Methods inherited from class org.apache.jcp.xml.dsig.internal.dom.DOMStructure
isFeatureSupported
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface javax.xml.crypto.AlgorithmMethod
getAlgorithm
Methods inherited from interface javax.xml.crypto.XMLStructure
isFeatureSupported
-
Field Details
-
DOM_SIGNATURE_PROVIDER
- See Also:
-
LOG
private static final org.slf4j.Logger LOG -
HMAC_SHA224
- See Also:
-
HMAC_SHA256
- See Also:
-
HMAC_SHA384
- See Also:
-
HMAC_SHA512
- See Also:
-
HMAC_RIPEMD160
- See Also:
-
hmac
-
outputLength
private int outputLength -
outputLengthSet
private boolean outputLengthSet -
params
-
-
Constructor Details
-
DOMHMACSignatureMethod
DOMHMACSignatureMethod(AlgorithmParameterSpec params) throws InvalidAlgorithmParameterException Creates aDOMHMACSignatureMethod
with the specified params- Parameters:
params
- algorithm-specific parameters (may benull
)- Throws:
InvalidAlgorithmParameterException
- if params are inappropriate
-
DOMHMACSignatureMethod
DOMHMACSignatureMethod(Element smElem) throws MarshalException Creates aDOMHMACSignatureMethod
from an element.- Parameters:
smElem
- a SignatureMethod element- Throws:
MarshalException
-
-
Method Details
-
checkParams
Description copied from class:AbstractDOMSignatureMethod
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.- Overrides:
checkParams
in classAbstractDOMSignatureMethod
- Parameters:
params
- the algorithm-specific params (may benull
)- Throws:
InvalidAlgorithmParameterException
- if the parameters are not appropriate for this signature method
-
getParameterSpec
-
unmarshalParams
Description copied from class:AbstractDOMSignatureMethod
UnmarshalsSignatureMethodParameterSpec
from 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.- Overrides:
unmarshalParams
in classAbstractDOMSignatureMethod
- Parameters:
paramsElem
- theElement
holding the input params- Returns:
- the algorithm-specific
SignatureMethodParameterSpec
- Throws:
MarshalException
- if the parameters cannot be unmarshalled
-
marshalParams
Description copied from class:AbstractDOMSignatureMethod
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.- Overrides:
marshalParams
in classAbstractDOMSignatureMethod
- Parameters:
parent
- the parent element to append the parameters toprefix
- the algorithm parameters prefix to use- Throws:
MarshalException
- if the parameters cannot be marshalled
-
verify
boolean verify(Key key, SignedInfo si, byte[] sig, XMLValidateContext context) throws InvalidKeyException, SignatureException, XMLSignatureException Description copied from class:AbstractDOMSignatureMethod
Verifies the passed-in signature with the specified key, using the underlying Signature or Mac algorithm.- Specified by:
verify
in classAbstractDOMSignatureMethod
- Parameters:
key
- the verification keysi
- the SignedInfosig
- the signature bytes to be verifiedcontext
- the XMLValidateContext- Returns:
true
if the signature verified successfully,false
if not- Throws:
InvalidKeyException
- 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
byte[] sign(Key key, SignedInfo si, XMLSignContext context) throws InvalidKeyException, XMLSignatureException Description copied from class:AbstractDOMSignatureMethod
Signs the bytes with the specified key, using the underlying Signature or Mac algorithm.- Specified by:
sign
in classAbstractDOMSignatureMethod
- Parameters:
key
- the signing keysi
- the SignedInfocontext
- the XMLSignContext- Returns:
- the signature
- Throws:
InvalidKeyException
- if the key is improperly encoded, of the wrong type, or parameters are missing, etcXMLSignatureException
- if an unexpected error occurs
-
paramsEqual
Description copied from class:AbstractDOMSignatureMethod
Returns true if parameters are equal; false otherwise. Subclasses should override this method to compare algorithm-specific parameters.- Overrides:
paramsEqual
in classAbstractDOMSignatureMethod
-
getAlgorithmType
AbstractDOMSignatureMethod.Type getAlgorithmType()Description copied from class:AbstractDOMSignatureMethod
Returns the type of signature algorithm.- Specified by:
getAlgorithmType
in classAbstractDOMSignatureMethod
-
getDigestLength
abstract int getDigestLength()Returns the output length of the hash/digest.
-