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:
javax.xml.crypto.AlgorithmMethod,javax.xml.crypto.dsig.SignatureMethod,javax.xml.crypto.XMLStructure
- Direct Known Subclasses:
DOMHMACSignatureMethod.RIPEMD160,DOMHMACSignatureMethod.SHA1,DOMHMACSignatureMethod.SHA224,DOMHMACSignatureMethod.SHA256,DOMHMACSignatureMethod.SHA384,DOMHMACSignatureMethod.SHA512
public abstract class DOMHMACSignatureMethod extends AbstractDOMSignatureMethod
DOM-based implementation of HMAC SignatureMethod.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classDOMHMACSignatureMethod.RIPEMD160(package private) static classDOMHMACSignatureMethod.SHA1(package private) static classDOMHMACSignatureMethod.SHA224(package private) static classDOMHMACSignatureMethod.SHA256(package private) static classDOMHMACSignatureMethod.SHA384(package private) static classDOMHMACSignatureMethod.SHA512-
Nested classes/interfaces inherited from class org.apache.jcp.xml.dsig.internal.dom.AbstractDOMSignatureMethod
AbstractDOMSignatureMethod.Type
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.StringDOM_SIGNATURE_PROVIDERprivate javax.crypto.Machmac(package private) static java.lang.StringHMAC_RIPEMD160(package private) static java.lang.StringHMAC_SHA224(package private) static java.lang.StringHMAC_SHA256(package private) static java.lang.StringHMAC_SHA384(package private) static java.lang.StringHMAC_SHA512private static org.slf4j.LoggerLOGprivate intoutputLengthprivate booleanoutputLengthSetprivate javax.xml.crypto.dsig.spec.SignatureMethodParameterSpecparams
-
Constructor Summary
Constructors Constructor Description DOMHMACSignatureMethod(java.security.spec.AlgorithmParameterSpec params)Creates aDOMHMACSignatureMethodwith the specified paramsDOMHMACSignatureMethod(org.w3c.dom.Element smElem)Creates aDOMHMACSignatureMethodfrom an element.
-
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.(package private) AbstractDOMSignatureMethod.TypegetAlgorithmType()Returns the type of signature algorithm.(package private) abstract intgetDigestLength()Returns the output length of the hash/digest.java.security.spec.AlgorithmParameterSpecgetParameterSpec()(package private) voidmarshalParams(org.w3c.dom.Element parent, java.lang.String prefix)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) 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) 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.AbstractDOMSignatureMethod
equals, getJCAAlgorithm, hashCode, marshal
-
Methods inherited from class org.apache.jcp.xml.dsig.internal.dom.DOMStructure
isFeatureSupported
-
-
-
-
Field Detail
-
DOM_SIGNATURE_PROVIDER
private static final java.lang.String DOM_SIGNATURE_PROVIDER
- See Also:
- Constant Field Values
-
LOG
private static final org.slf4j.Logger LOG
-
HMAC_SHA224
static final java.lang.String HMAC_SHA224
- See Also:
- Constant Field Values
-
HMAC_SHA256
static final java.lang.String HMAC_SHA256
- See Also:
- Constant Field Values
-
HMAC_SHA384
static final java.lang.String HMAC_SHA384
- See Also:
- Constant Field Values
-
HMAC_SHA512
static final java.lang.String HMAC_SHA512
- See Also:
- Constant Field Values
-
HMAC_RIPEMD160
static final java.lang.String HMAC_RIPEMD160
- See Also:
- Constant Field Values
-
hmac
private javax.crypto.Mac hmac
-
outputLength
private int outputLength
-
outputLengthSet
private boolean outputLengthSet
-
params
private javax.xml.crypto.dsig.spec.SignatureMethodParameterSpec params
-
-
Constructor Detail
-
DOMHMACSignatureMethod
DOMHMACSignatureMethod(java.security.spec.AlgorithmParameterSpec params) throws java.security.InvalidAlgorithmParameterExceptionCreates aDOMHMACSignatureMethodwith the specified params- Parameters:
params- algorithm-specific parameters (may benull)- Throws:
java.security.InvalidAlgorithmParameterException- if params are inappropriate
-
DOMHMACSignatureMethod
DOMHMACSignatureMethod(org.w3c.dom.Element smElem) throws javax.xml.crypto.MarshalExceptionCreates aDOMHMACSignatureMethodfrom an element.- Parameters:
smElem- a SignatureMethod element- Throws:
javax.xml.crypto.MarshalException
-
-
Method Detail
-
checkParams
void checkParams(javax.xml.crypto.dsig.spec.SignatureMethodParameterSpec params) throws java.security.InvalidAlgorithmParameterExceptionDescription copied from class:AbstractDOMSignatureMethodChecks 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:
checkParamsin classAbstractDOMSignatureMethod- Parameters:
params- the algorithm-specific params (may benull)- Throws:
java.security.InvalidAlgorithmParameterException- if the parameters are not appropriate for this signature method
-
getParameterSpec
public final java.security.spec.AlgorithmParameterSpec getParameterSpec()
-
unmarshalParams
javax.xml.crypto.dsig.spec.SignatureMethodParameterSpec unmarshalParams(org.w3c.dom.Element paramsElem) throws javax.xml.crypto.MarshalExceptionDescription copied from class:AbstractDOMSignatureMethodUnmarshalsSignatureMethodParameterSpecfrom 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:
unmarshalParamsin classAbstractDOMSignatureMethod- Parameters:
paramsElem- theElementholding the input params- Returns:
- the algorithm-specific
SignatureMethodParameterSpec - Throws:
javax.xml.crypto.MarshalException- if the parameters cannot be unmarshalled
-
marshalParams
void marshalParams(org.w3c.dom.Element parent, java.lang.String prefix) throws javax.xml.crypto.MarshalExceptionDescription copied from class:AbstractDOMSignatureMethodMarshals 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:
marshalParamsin classAbstractDOMSignatureMethod- Parameters:
parent- the parent element to append the parameters toprefix- the algorithm parameters prefix to use- Throws:
javax.xml.crypto.MarshalException- if the parameters cannot be marshalled
-
verify
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.XMLSignatureExceptionDescription copied from class:AbstractDOMSignatureMethodVerifies the passed-in signature with the specified key, using the underlying Signature or Mac algorithm.- Specified by:
verifyin classAbstractDOMSignatureMethod- 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.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
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.XMLSignatureExceptionDescription copied from class:AbstractDOMSignatureMethodSigns the bytes with the specified key, using the underlying Signature or Mac algorithm.- Specified by:
signin classAbstractDOMSignatureMethod- Parameters:
key- the signing keysi- the SignedInfocontext- the XMLSignContext- Returns:
- the signature
- Throws:
java.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
-
paramsEqual
boolean paramsEqual(java.security.spec.AlgorithmParameterSpec spec)
Description copied from class:AbstractDOMSignatureMethodReturns true if parameters are equal; false otherwise. Subclasses should override this method to compare algorithm-specific parameters.- Overrides:
paramsEqualin classAbstractDOMSignatureMethod
-
getAlgorithmType
AbstractDOMSignatureMethod.Type getAlgorithmType()
Description copied from class:AbstractDOMSignatureMethodReturns the type of signature algorithm.- Specified by:
getAlgorithmTypein classAbstractDOMSignatureMethod
-
getDigestLength
abstract int getDigestLength()
Returns the output length of the hash/digest.
-
-