Package com.nimbusds.jose.crypto
Class MACSigner
java.lang.Object
com.nimbusds.jose.crypto.impl.BaseJWSProvider
com.nimbusds.jose.crypto.impl.MACProvider
com.nimbusds.jose.crypto.MACSigner
- All Implemented Interfaces:
JCAAware<JCAContext>
,JOSEProvider
,JWSProvider
,JWSSigner
Message Authentication Code (MAC) signer of
JWS objects
. Expects a secret key.
See RFC 7518 section 3.2 for more information.
This class is thread-safe.
Supports the following algorithms:
Tested with the AWS CloudHSM JCE provider.
- Version:
- 2024-10-28
- Author:
- Vladimir Dzhuvinov, Ulrich Winter
-
Field Summary
Fields inherited from class com.nimbusds.jose.crypto.impl.MACProvider
SUPPORTED_ALGORITHMS
-
Constructor Summary
ConstructorsConstructorDescriptionMACSigner
(byte[] secret) Creates a new Message Authentication (MAC) signer.Creates a new Message Authentication (MAC) signer.Creates a new Message Authentication (MAC) signer.Creates a new Message Authentication (MAC) signer. -
Method Summary
Methods inherited from class com.nimbusds.jose.crypto.impl.MACProvider
ensureSecretLengthSatisfiesAlgorithm, getCompatibleAlgorithms, getJCAAlgorithmName, getMinRequiredSecretLength, getSecret, getSecretKey, getSecretString
Methods inherited from class com.nimbusds.jose.crypto.impl.BaseJWSProvider
getJCAContext, supportedJWSAlgorithms
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.nimbusds.jose.jca.JCAAware
getJCAContext
Methods inherited from interface com.nimbusds.jose.JWSProvider
supportedJWSAlgorithms
-
Constructor Details
-
MACSigner
Creates a new Message Authentication (MAC) signer.- Parameters:
secret
- The secret. Must be at least 256 bits long and notnull
.- Throws:
KeyLengthException
- If the secret length is shorter than the minimum 256-bit requirement.
-
MACSigner
Creates a new Message Authentication (MAC) signer.- Parameters:
secretString
- The secret as a UTF-8 encoded string. Must be at least 256 bits long and notnull
.- Throws:
KeyLengthException
- If the secret length is shorter than the minimum 256-bit requirement.
-
MACSigner
Creates a new Message Authentication (MAC) signer.- Parameters:
secretKey
- The secret key. Must be at least 256 bits long and notnull
.- Throws:
KeyLengthException
- If the secret length is shorter than the minimum 256-bit requirement.
-
MACSigner
Creates a new Message Authentication (MAC) signer.- Parameters:
jwk
- The secret as a JWK. Must be at least 256 bits long and notnull
.- Throws:
KeyLengthException
- If the secret length is shorter than the minimum 256-bit requirement.
-
-
Method Details
-
sign
Description copied from interface:JWSSigner
Signs the specifiedinput
of aJWS object
.- Specified by:
sign
in interfaceJWSSigner
- Parameters:
header
- The JSON Web Signature (JWS) header. Must specify a supported JWS algorithm and must not benull
.signingInput
- The input to sign. Must not benull
.- Returns:
- The resulting signature part (third part) of the JWS object.
- Throws:
JOSEException
- If the JWS algorithm is not supported, if a critical header parameter is not supported or marked for deferral to the application, or if signing failed for some other internal reason.
-