Package com.nimbusds.jose.crypto
Class RSASSASigner
java.lang.Object
com.nimbusds.jose.crypto.impl.BaseJWSProvider
com.nimbusds.jose.crypto.impl.RSASSAProvider
com.nimbusds.jose.crypto.RSASSASigner
- All Implemented Interfaces:
JCAAware<JCAContext>
,JOSEProvider
,JWSProvider
,JWSSigner
RSA Signature-Scheme-with-Appendix (RSASSA) signer of
JWS objects
. Expects a private RSA key.
See RFC 7518, sections 3.3 and 3.5 for more information.
This class is thread-safe.
Supports the following algorithms:
JWSAlgorithm.RS256
JWSAlgorithm.RS384
JWSAlgorithm.RS512
JWSAlgorithm.PS256
JWSAlgorithm.PS384
JWSAlgorithm.PS512
Supports the following options
:
UserAuthenticationRequired
-- to prompt the user to authenticate in order to complete the signing operation. Android applications can use this option to trigger a biometric prompt that is required to unlock a private key created withsetUserAuthenticationRequired(true)
.AllowWeakRSAKey
-- to allow weak RSA keys that are shorter than2048 bits
Supports the BouncyCastle FIPS provider for the PSxxx family of JWS algorithms.
- Version:
- 2023-01-31
- Author:
- Vladimir Dzhuvinov, Omer Levi Hevroni
-
Field Summary
Fields inherited from class com.nimbusds.jose.crypto.impl.RSASSAProvider
SUPPORTED_ALGORITHMS
-
Constructor Summary
ConstructorsConstructorDescriptionRSASSASigner
(RSAKey rsaJWK) Creates a new RSA Signature-Scheme-with-Appendix (RSASSA) signer.RSASSASigner
(RSAKey rsaJWK, boolean allowWeakKey) Deprecated.RSASSASigner
(RSAKey rsaJWK, Set<JWSSignerOption> opts) Creates a new RSA Signature-Scheme-with-Appendix (RSASSA) signer.RSASSASigner
(PrivateKey privateKey) Creates a new RSA Signature-Scheme-with-Appendix (RSASSA) signer.RSASSASigner
(PrivateKey privateKey, boolean allowWeakKey) Deprecated.RSASSASigner
(PrivateKey privateKey, Set<JWSSignerOption> opts) Creates a new RSA Signature-Scheme-with-Appendix (RSASSA) signer. -
Method Summary
Modifier and TypeMethodDescriptionGets the private RSA key.Signs the specifiedinput
of aJWS object
.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
-
RSASSASigner
Creates a new RSA Signature-Scheme-with-Appendix (RSASSA) signer. This constructor can also accept a private RSA key located in a PKCS#11 store that doesn't expose the private key parameters (such as a smart card or HSM).- Parameters:
privateKey
- The private RSA key. Its algorithm must be "RSA" and its length at least 2048 bits. Note that the length of an RSA key in a PKCS#11 store cannot be checked. Must not benull
.
-
RSASSASigner
Deprecated.Creates a new RSA Signature-Scheme-with-Appendix (RSASSA) signer. This constructor can also accept a private RSA key located in a PKCS#11 store that doesn't expose the private key parameters (such as a smart card or HSM).- Parameters:
privateKey
- The private RSA key. Its algorithm must be "RSA" and its length at least 2048 bits. Note that the length of an RSA key in a PKCS#11 store cannot be checked. Must not benull
.allowWeakKey
-true
to allow an RSA key shorter than 2048 bits.
-
RSASSASigner
Creates a new RSA Signature-Scheme-with-Appendix (RSASSA) signer. This constructor can also accept a private RSA key located in a PKCS#11 store that doesn't expose the private key parameters (such as a smart card or HSM).- Parameters:
privateKey
- The private RSA key. Its algorithm must be "RSA" and its length at least 2048 bits. Note that the length of an RSA key in a PKCS#11 store cannot be checked. Must not benull
.opts
- The signing options, empty ornull
if none.
-
RSASSASigner
Creates a new RSA Signature-Scheme-with-Appendix (RSASSA) signer.- Parameters:
rsaJWK
- The RSA JSON Web Key (JWK). Must contain or reference a private part. Its length must be at least 2048 bits. Note that the length of an RSA key in a PKCS#11 store cannot be checked. Must not benull
.- Throws:
JOSEException
- If the RSA JWK doesn't contain a private part or its extraction failed.
-
RSASSASigner
Deprecated.Creates a new RSA Signature-Scheme-with-Appendix (RSASSA) signer.- Parameters:
rsaJWK
- The RSA JSON Web Key (JWK). Must contain or reference a private part. Its length must be at least 2048 bits. Note that the length of an RSA key in a PKCS#11 store cannot be checked. Must not benull
.allowWeakKey
-true
to allow an RSA key shorter than 2048 bits.- Throws:
JOSEException
- If the RSA JWK doesn't contain a private part or its extraction failed.
-
RSASSASigner
Creates a new RSA Signature-Scheme-with-Appendix (RSASSA) signer.- Parameters:
rsaJWK
- The RSA JSON Web Key (JWK). Must contain or reference a private part. Its length must be at least 2048 bits. Note that the length of an RSA key in a PKCS#11 store cannot be checked. Must not benull
.opts
- The signing options, empty ornull
if none.- Throws:
JOSEException
- If the RSA JWK doesn't contain a private part or its extraction failed.
-
-
Method Details
-
getPrivateKey
Gets the private RSA key.- Returns:
- The private RSA key. Casting to
RSAPrivateKey
may not be possible if the key is located in a PKCS#11 store that doesn't expose the private key parameters.
-
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.
-