Package org.forgerock.json.jose.jws
Class SigningManager
java.lang.Object
org.forgerock.json.jose.jws.SigningManager
A service to get the appropriate SigningHandler for a specific Java Cryptographic signing algorithm.
For details of all supported signing algorithms see JwsAlgorithm
- Since:
- 2.0.0
-
Constructor Summary
ConstructorDescriptionDeprecated.SigningManager
(SecretsProvider provider) Builds a new SigningManager that can buildSigningHandler
based on asynchronously retrieved Secrets from the givenprovider
. -
Method Summary
Modifier and TypeMethodDescriptionDeprecated.usenewEcdsaSigningHandler(SigningKey)
} insteadDeprecated.usenewEcdsaSigningHandler(SigningKey)
} insteadConstructs a new handler for signing ES256 signatures.Deprecated.usenewEcdsaVerificationHandler(VerificationKey)
insteadConstructs a new handler for verifying ES256 signatures.newEdDsaSigningHandler
(byte[] privateKey) Deprecated.UsenewEdDsaSigningHandler(SigningKey)
insteadnewEdDsaSigningHandler
(SigningKey signingKey) Constructs a new handler for signing EdDSA signatures.newEdDsaVerificationHandler
(byte[] publicKey) Deprecated.UsenewEdDsaVerificationHandler(VerificationKey)
instead.newEdDsaVerificationHandler
(VerificationKey verificationKey) Constructs a new handler for verifying EdDSA signatures.newHmacSigningHandler
(byte[] sharedSecret) Deprecated.usenewHmacSigningHandler(SigningKey)
insteadnewHmacSigningHandler
(SecretKey secretKey) Deprecated.usenewHmacSigningHandler(SigningKey)
insteadConstructs a new SecretHmacSigningHandler configured for signature validation.Constructs a new SecretHmacSigningHandler configured for signature validation.Deprecated.This method is inherently insecure and shouldn't be used.newRsaSigningHandler
(Key key) Deprecated.usenewRsaVerificationHandler(VerificationKey)
insteadConstructs a new SecretRSASigningHandler configured for signature validation.Constructs a new SecretRSASigningHandler configured for signature validation.newSigningHandler
(Key key) Deprecated.UsenewSigningHandler(SigningKey)
insteadnewSigningHandler
(JWK jwk) Returns a signing handler from the given JSON Web Key (JWK) which will be used to sign a JWT.newSigningHandler
(JWK jwk, Purpose<SigningKey> purpose) Returns a signing handler from the given JSON Web Key (JWK) which will be used to sign a JWT.newSigningHandler
(JWK jwk, Purpose<SigningKey> purpose, Instant expiry) Returns a signing handler from the given JSON Web Key (JWK) which will be used to sign a JWT.Returns the signing handler from the given SigningKey which will be used to sign the JWT.newSigningHandler
(Purpose<SigningKey> purpose) Constructs a new SigningHandler configured for signing with the provided secret purpose.newSigningHandler
(SecretReference<SigningKey> secretReference) Constructs a new SigningHandler configured for signing with the provided secret reference.Deprecated.UsenewVerificationHandler(VerificationKey)
insteadReturns the signing handler from the given JSON Web Key (JWK) which will be used to verify the JWT.newVerificationHandler
(JWK jwk, Purpose<VerificationKey> purpose) Returns a signing handler from the given JSON Web Key (JWK) which will be used to verify a JWT.newVerificationHandler
(JWK jwk, Purpose<VerificationKey> purpose, Instant expiry) Returns a signing handler from the given JSON Web Key (JWK) which will be used to verify a JWT.Returns the signing handler from the given VerificationKey which will be used to verify the JWT.newVerificationHandler
(Purpose<VerificationKey> purpose, String keyId) Constructs a new SigningHandler configured for verifying with the provided secret purpose.Constructs a new SigningHandler configured for verifying with the provided valid secrets reference.
-
Constructor Details
-
SigningManager
Deprecated.useSigningManager(SecretsProvider)
instead- See Also:
-
SigningManager
Builds a new SigningManager that can buildSigningHandler
based on asynchronously retrieved Secrets from the givenprovider
.- Parameters:
provider
- providers of secrets- See Also:
-
-
Method Details
-
newNopSigningHandler
Deprecated.This method is inherently insecure and shouldn't be used.Constructs an implementation of the SigningHandler which does not perform any signing or verifying.- Returns:
- an implementation of the SigningHandler which does not perform any signing or verifying.
-
newHmacSigningHandler
Deprecated.usenewHmacSigningHandler(SigningKey)
insteadConstructs a new HmacSigningHandler. Callers should prefer to usenewHmacSigningHandler(SecretKey)
in most cases.- Parameters:
sharedSecret
- The shared secret to use to sign the data.- Returns:
- a new HmacSigningHandler.
-
newHmacSigningHandler
Deprecated.usenewHmacSigningHandler(SigningKey)
insteadConstructs a new HmacSigningHandler.- Parameters:
secretKey
- The secret key to use to sign the data.- Returns:
- a new HmacSigningHandler.
-
newRsaSigningHandler
Deprecated.usenewRsaVerificationHandler(VerificationKey)
insteadConstructs a new RSASigningHandler, with a SignatureUtil instance to delegate the signing and verifying calls to.- Parameters:
key
- The key used to sign and verify the signature.- Returns:
- a new RSASigningHandler, with a SignatureUtil instance to delegate the signing and verifying calls to.
-
newEcdsaSigningHandler
Deprecated.usenewEcdsaSigningHandler(SigningKey)
} insteadConstructs a new handler for signing ES256 signatures.- Parameters:
key
- the elliptic curve private key. Should use the required curve for the given signing algorithm (P-256 for ES256).- Returns:
- the signing handler.
-
newEcdsaSigningHandler
Deprecated.usenewEcdsaSigningHandler(SigningKey)
} insteadConstructs a new handler for signing ES256 signatures.- Parameters:
key
- the elliptic curve private key. Should use the required curve for the given signing algorithm (P-256 for ES256).- Returns:
- the signing handler.
-
newEcdsaVerificationHandler
Deprecated.usenewEcdsaVerificationHandler(VerificationKey)
insteadConstructs a new handler for verifying ES256 signatures.- Parameters:
key
- the elliptic curve public key. Should use the required curve for the given signing algorithm (P-256 for ES256).- Returns:
- the signing handler configured for verification.
-
newEdDsaSigningHandler
Deprecated.UsenewEdDsaSigningHandler(SigningKey)
insteadConstructs a new handler for signing EdDSA signatures.- Parameters:
privateKey
- the raw private key bytes.- Returns:
- the signing handler.
-
newEdDsaVerificationHandler
Deprecated.UsenewEdDsaVerificationHandler(VerificationKey)
instead.Constructs a new handler for verifying EdDSA signatures.- Parameters:
publicKey
- the raw public key bytes.- Returns:
- the signing handler.
-
newEdDsaSigningHandler
Constructs a new handler for signing EdDSA signatures.- Parameters:
signingKey
- the EdDSA signing key.- Returns:
- the signing handler.
-
newEdDsaVerificationHandler
Constructs a new handler for verifying EdDSA signatures.- Parameters:
verificationKey
- EdDSA public verification key.- Returns:
- the signing handler.
-
newSigningHandler
Constructs a new SigningHandler configured for signing with the provided secret purpose.Note that the current implementation doesn't support EdDSA. If needed, use directly
newSigningHandler(JWK)
ornewEdDsaSigningHandler(byte[])
.- Parameters:
purpose
- Signing secret purpose (cannot be null)- Returns:
- a promise of a new SigningHandler
-
newSigningHandler
public Promise<SigningHandler,NoSuchSecretException> newSigningHandler(SecretReference<SigningKey> secretReference) Constructs a new SigningHandler configured for signing with the provided secret reference.Note that the current implementation doesn't support EdDSA. If needed, use directly
newSigningHandler(JWK)
ornewEdDsaSigningHandler(byte[])
.- Parameters:
secretReference
- Signing secret reference (cannot be null)- Returns:
- a promise of a new SigningHandler
-
newVerificationHandler
public Promise<SigningHandler,NeverThrowsException> newVerificationHandler(Purpose<VerificationKey> purpose, String keyId) Constructs a new SigningHandler configured for verifying with the provided secret purpose.Note that the current implementation doesn't support EdDSA. If needed, use directly
newVerificationHandler(JWK)
ornewEdDsaVerificationHandler(byte[])
.- Parameters:
purpose
- Verification key purpose (cannot be null)keyId
- optional key identifier- Returns:
- a promise of a new SigningHandler
-
newVerificationHandler
public Promise<SigningHandler,NeverThrowsException> newVerificationHandler(ValidSecretsReference<VerificationKey, NeverThrowsException> validSecrets) Constructs a new SigningHandler configured for verifying with the provided valid secrets reference.Note that the current implementation doesn't support EdDSA. If needed, use directly
newVerificationHandler(JWK)
ornewEdDsaVerificationHandler(byte[])
.- Parameters:
validSecrets
- a reference to the valid secrets.- Returns:
- a promise of a new SigningHandler
-
newSigningHandler
Returns the signing handler from the given SigningKey which will be used to sign the JWT.- Parameters:
key
- The SigningKey use to sign the JWT.- Returns:
- the signing handler to use for signing the JWT.
- Throws:
IllegalArgumentException
- if no handler can be determined for the given key.
-
newVerificationHandler
Returns the signing handler from the given VerificationKey which will be used to verify the JWT.- Parameters:
key
- The VerificationKey use to verify the JWT.- Returns:
- the signing handler to use for verifying the JWT.
- Throws:
IllegalArgumentException
- if no handler can be determined for the given key.
-
newRsaSigningHandler
Constructs a new SecretRSASigningHandler configured for signature validation.- Parameters:
key
- Key to use for signing- Returns:
- a new SigningHandler that can only do signing
-
newRsaVerificationHandler
Constructs a new SecretRSASigningHandler configured for signature validation.- Parameters:
key
- Key to use for signature verification- Returns:
- a new SigningHandler that can only do verification
-
newHmacSigningHandler
Constructs a new SecretHmacSigningHandler configured for signature validation.- Parameters:
key
- Key to use for signing- Returns:
- a new SigningHandler that can only do signing
-
newHmacVerificationHandler
Constructs a new SecretHmacSigningHandler configured for signature validation.- Parameters:
key
- Key to use for signature verification- Returns:
- a new SigningHandler that can only do verification
-
newEcdsaSigningHandler
Constructs a new handler for signing ES256 signatures.- Parameters:
key
- the elliptic curve signing key. Should use the required curve for the given signing algorithm (P-256 for ES256).- Returns:
- the signing handler.
-
newEcdsaVerificationHandler
Constructs a new handler for verifying ES256 signatures.- Parameters:
key
- the elliptic curve verification key. Should use the required curve for the given signing algorithm (P-256 for ES256).- Returns:
- the signing handler configured for verification.
-
newSigningHandler
Deprecated.UsenewSigningHandler(SigningKey)
insteadReturns the signing handler from the given Key which will be used to verify the JWT.- Parameters:
key
- The Key use to sign the JWT.- Returns:
- the signing handler to use for signing the JWT.
- Throws:
IllegalArgumentException
- if no handler can be determined for the given key.
-
newSigningHandler
Returns a signing handler from the given JSON Web Key (JWK) which will be used to sign a JWT.- Parameters:
jwk
- The JSON Web Key (JWK).- Returns:
- the signing handler to use for signing the JWT.
- Throws:
IllegalArgumentException
- if the jwk cannot be converted to an appropriate signing key.
-
newSigningHandler
Returns a signing handler from the given JSON Web Key (JWK) which will be used to sign a JWT.- Parameters:
jwk
- The JSON Web Key (JWK).purpose
- The purpose for which the JWT is being signed.- Returns:
- the signing handler to use for signing the JWT.
- Throws:
IllegalArgumentException
- if the jwk cannot be converted to an appropriate signing key.
-
newSigningHandler
Returns a signing handler from the given JSON Web Key (JWK) which will be used to sign a JWT.- Parameters:
jwk
- The JSON Web Key (JWK).purpose
- The purpose for which the JWT is being signed.expiry
- The time at which the signing handler should expire and no longer be used.- Returns:
- the signing handler to use for signing the JWT.
- Throws:
IllegalArgumentException
- if the jwk cannot be converted to an appropriate signing key.
-
newVerificationHandler
Deprecated.UsenewVerificationHandler(VerificationKey)
insteadReturns the signing handler from the given Key which will be used to verify the JWT.- Parameters:
key
- The Key use to verify the JWT.- Returns:
- the signing handler to use for verifying the JWT.
- Throws:
IllegalArgumentException
- if no handler can be determined for the given key.
-
newVerificationHandler
Returns the signing handler from the given JSON Web Key (JWK) which will be used to verify the JWT. The resulting handler will be constructed for the genericPurpose.VERIFY
purpose and will not expire.- Parameters:
jwk
- The JSON Web Key (JWK).- Returns:
- the signing handler to use for verifying the JWT.
- Throws:
IllegalArgumentException
- if the jwk cannot be converted to an appropriate verification key.
-
newVerificationHandler
Returns a signing handler from the given JSON Web Key (JWK) which will be used to verify a JWT. The resulting handler will never expire.- Parameters:
jwk
- The JSON Web Key (JWK).purpose
- ThePurpose
for which verification is being performed.- Returns:
- the signing handler to use for verifying the JWT.
- Throws:
IllegalArgumentException
- if the jwk cannot be converted to an appropriate verification key.
-
newVerificationHandler
public SigningHandler newVerificationHandler(JWK jwk, Purpose<VerificationKey> purpose, Instant expiry) Returns a signing handler from the given JSON Web Key (JWK) which will be used to verify a JWT.- Parameters:
jwk
- The JSON Web Key (JWK).purpose
- ThePurpose
for which verification is being performed.expiry
- The time at which the verification handler should expire and no longer be used.- Returns:
- the signing handler to use for verifying the JWT.
- Throws:
IllegalArgumentException
- if the jwk cannot be converted to an appropriate verification key.
-
SigningManager(SecretsProvider)
instead