Class GenericRSAJWK
- All Implemented Interfaces:
AsymmetricJWK<RSAPublicKey,,RSAPrivateKey> JWK,RSAJWK,X509JWK<RSAPublicKey,RSAPrivateKey>
Generic RSA JSON Web Key implementation.
It supports the following algorithms:
- RS1
- RS256
- RS384
- RS512
- PS256
- PS384
- PS512
- RSA1_5
- RSA-OAEP
- RSA-OAEP-256
- RSA-OAEP-384
- RSA-OAEP-512
- Since:
- 1.5
- Author:
- Jeremy Kuhn
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classGenericRSAJWK.OtherPrimeInfoimplementation.Nested classes/interfaces inherited from interface io.inverno.mod.security.jose.jwk.rsa.RSAJWK
RSAJWK.OtherPrimeInfo -
Field Summary
Fields inherited from class io.inverno.mod.security.jose.internal.jwk.AbstractX509JWK
certificate, x5c, x5t, x5t_S256, x5uFields inherited from class io.inverno.mod.security.jose.internal.jwk.AbstractJWK
alg, key, key_ops, kid, kty, trusted, useFields inherited from interface io.inverno.mod.security.jose.jwk.JWK
DEFAULT_THUMBPRINT_DIGEST, KEY_OP_DECRYPT, KEY_OP_DERIVE_BITS, KEY_OP_DERIVE_KEY, KEY_OP_ENCRYPT, KEY_OP_SIGN, KEY_OP_UNWRAP_KEY, KEY_OP_VERIFY, KEY_OP_WRAP_KEY, USE_ENC, USE_SIG -
Constructor Summary
ConstructorsConstructorDescriptionGenericRSAJWK(String n, String e) Creates an untrusted public generic RSA JWK with the specified public key parameters.GenericRSAJWK(String n, String e, String d) Creates an untrusted private generic RSA JWK with the specified public key parameters and private exponent.GenericRSAJWK(String n, String e, String d, X509Certificate certificate) Creates a public generic RSA JWK with the specified public key parameters, private exponent and certificate.GenericRSAJWK(String n, String e, String d, RSAPrivateKey key, boolean trusted) Creates a private generic RSA JWK with the specified public key parameters, private exponent and RSA private key.GenericRSAJWK(String n, String e, String d, RSAPrivateKey key, X509Certificate certificate, boolean trusted) Creates a private generic RSA JWK with the specified public key parameters, private exponent, RSA private key and certificate.GenericRSAJWK(String n, String e, X509Certificate certificate) Creates a public generic RSA JWK with the specified public key parameters and certificate. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns the first coefficient encoded as Base64URL.Returns the first factor exponent encoded as Base64URL.Returns the first prime factor encoded as Base64URL.Returns the modulus encoded as Base64URL.Returns the list of other primes info.Returns the private exponent encoded as Base64URL.Returns the public exponent encoded as Base64URL.Returns the second factor exponent encoded as Base64URL.Returns the second prime factor encoded as Base64URL.inthashCode()Returns a key manager using this JWK.keyManager(String alg) Returns a key manager using this JWK and the specified algorithm.minify()Returns a minified representation of the key only containing required data.voidsetAlgorithm(RSAAlgorithm rsaAlg) Sets the RSA JWA algorithm.voidsetAlgorithm(String alg) Sets the algorithm intended for use with the key.voidSets the first coefficient encoded as Base64URL.voidSets the first factor exponent encoded as Base64URL.voidSets the first prime factor encoded as Base64URL.voidSets other prime info.voidSets the second factor exponent encoded as Base64URL.voidSets the second prime factor encoded as Base64URL.signer()Returns a signer using this JWK.Returns a signer using this JWK and the specified algorithm.booleansupportsAlgorithm(String alg) Determines whether the JWK supports the specified JWA algorithm.toJWKThumbprint(MessageDigest digest) Generates and returns the JWK thumbprint using the specified digest.Converts the JWK to its corresponding private key.Returns a public and safe to share representation of the key.Converts the JWK to its corresponding public key.trust()Trusts the key explicitly.Methods inherited from class io.inverno.mod.security.jose.internal.jwk.AbstractX509JWK
getX509Certificate, getX509CertificateChain, getX509CertificateSHA1Thumbprint, getX509CertificateSHA256Thumbprint, getX509CertificateURL, setX509CertificateChain, setX509CertificateSHA1Thumbprint, setX509CertificateSHA256Thumbprint, setX509CertificateURL, toStringMethods inherited from class io.inverno.mod.security.jose.internal.jwk.AbstractJWK
checkEncryption, checkKeyManagement, checkSignature, cipher, cipher, getAlgorithm, getDefaultThumbprintDigest, getKey, getKeyId, getKeyOperations, getKeyType, getPublicKeyUse, isTrusted, setKeyId, setKeyOperations, setPublicKeyUseMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface io.inverno.mod.security.jose.jwk.JWK
cipher, cipher, getAlgorithm, getKeyId, getKeyOperations, getKeyType, getPublicKeyUse, isTrusted, toJWKThumbprintMethods inherited from interface io.inverno.mod.security.jose.jwk.X509JWK
getX509Certificate, getX509CertificateChain, getX509CertificateSHA1Thumbprint, getX509CertificateSHA256Thumbprint, getX509CertificateURL
-
Constructor Details
-
GenericRSAJWK
Creates an untrusted public generic RSA JWK with the specified public key parameters.
- Parameters:
n- the modulus encoded as Base64URL without paddinge- the public exponent encoded as Base64URL without padding
-
GenericRSAJWK
Creates a public generic RSA JWK with the specified public key parameters and certificate.
The JWK is considered trusted if the specified certificate, which is assumed to be validated, is not null.
- Parameters:
n- the modulus encoded as Base64URL without paddinge- the public exponent encoded as Base64URL without paddingcertificate- an X.509 certificate
-
GenericRSAJWK
Creates an untrusted private generic RSA JWK with the specified public key parameters and private exponent.
- Parameters:
n- the modulus encoded as Base64URL without paddinge- the public exponent encoded as Base64URL without paddingd- the private exponent encoded as Base64URL without padding
-
GenericRSAJWK
Creates a private generic RSA JWK with the specified public key parameters, private exponent and RSA private key.
- Parameters:
n- the modulus encoded as Base64URL without paddinge- the public exponent encoded as Base64URL without paddingd- the private exponent encoded as Base64URL without paddingkey- an EC private keytrusted- true to create a trusted JWK, false otherwise
-
GenericRSAJWK
Creates a public generic RSA JWK with the specified public key parameters, private exponent and certificate.
The JWK is considered trusted if the specified certificate, which is assumed to be validated, is not null.
- Parameters:
n- the modulus encoded as Base64URL without paddinge- the public exponent encoded as Base64URL without paddingd- the private exponent encoded as Base64URL without paddingcertificate- an X.509 certificate
-
GenericRSAJWK
public GenericRSAJWK(String n, String e, String d, RSAPrivateKey key, X509Certificate certificate, boolean trusted) Creates a private generic RSA JWK with the specified public key parameters, private exponent, RSA private key and certificate.
- Parameters:
n- the modulus encoded as Base64URL without paddinge- the public exponent encoded as Base64URL without paddingd- the private exponent encoded as Base64URL without paddingkey- an RSA private keycertificate- an X.509 certificatetrusted- true to create a trusted JWK, false otherwise
-
-
Method Details
-
setAlgorithm
Sets the RSA JWA algorithm.
- Parameters:
rsaAlg- an RSA algorithm
-
setAlgorithm
Description copied from class:AbstractJWKSets the algorithm intended for use with the key.
- Overrides:
setAlgorithmin classAbstractJWK- Parameters:
alg- the JWA algorithm
-
getModulus
Description copied from interface:RSAJWKReturns the modulus encoded as Base64URL.
- Specified by:
getModulusin interfaceRSAJWK- Returns:
- the Base64URL encoded modulus with no padding.
-
getPublicExponent
Description copied from interface:RSAJWKReturns the public exponent encoded as Base64URL.
- Specified by:
getPublicExponentin interfaceRSAJWK- Returns:
- the Base64URL encoded public exponent with no padding.
-
getPrivateExponent
Description copied from interface:RSAJWKReturns the private exponent encoded as Base64URL.
- Specified by:
getPrivateExponentin interfaceRSAJWK- Returns:
- the Base64URL encoded private exponent with no padding.
-
setFirstPrimeFactor
Sets the first prime factor encoded as Base64URL.
- Parameters:
p- a Base64URL encoded first prime factor without padding
-
getFirstPrimeFactor
Description copied from interface:RSAJWKReturns the first prime factor encoded as Base64URL.
- Specified by:
getFirstPrimeFactorin interfaceRSAJWK- Returns:
- the Base64URL encoded first prime factor with no padding.
-
setSecondPrimeFactor
Sets the second prime factor encoded as Base64URL.
- Parameters:
q- a Base64URL encoded second prime factor without padding
-
getSecondPrimeFactor
Description copied from interface:RSAJWKReturns the second prime factor encoded as Base64URL.
- Specified by:
getSecondPrimeFactorin interfaceRSAJWK- Returns:
- the Base64URL encoded second prime factor with no padding.
-
setFirstFactorExponent
Sets the first factor exponent encoded as Base64URL.
- Parameters:
dp- a Base64URL encoded first factor exponent without padding
-
getFirstFactorExponent
Description copied from interface:RSAJWKReturns the first factor exponent encoded as Base64URL.
- Specified by:
getFirstFactorExponentin interfaceRSAJWK- Returns:
- the Base64URL encoded first factor exponent with no padding.
-
setSecondFactorExponent
Sets the second factor exponent encoded as Base64URL.
- Parameters:
dq- a Base64URL encoded second factor exponent without padding
-
getSecondFactorExponent
Description copied from interface:RSAJWKReturns the second factor exponent encoded as Base64URL.
- Specified by:
getSecondFactorExponentin interfaceRSAJWK- Returns:
- the Base64URL encoded second factor exponent with no padding.
-
setFirstCoefficient
Sets the first coefficient encoded as Base64URL.
- Parameters:
qi- a Base64URL encoded first coefficient without padding
-
getFirstCoefficient
Description copied from interface:RSAJWKReturns the first coefficient encoded as Base64URL.
- Specified by:
getFirstCoefficientin interfaceRSAJWK- Returns:
- the Base64URL encoded first coefficient with no padding.
-
setOtherPrimesInfo
Sets other prime info.
- Parameters:
oth- a list of other prime info
-
getOtherPrimesInfo
Description copied from interface:RSAJWKReturns the list of other primes info.
- Specified by:
getOtherPrimesInfoin interfaceRSAJWK- Returns:
- the list of other primes info or null
-
trust
Description copied from interface:JWKTrusts the key explicitly.
This should be used with care when the authenticity of an untrusted key has been established through external means.
- Specified by:
trustin interfaceAsymmetricJWK<RSAPublicKey,RSAPrivateKey> - Specified by:
trustin interfaceJWK- Specified by:
trustin interfaceRSAJWK- Specified by:
trustin interfaceX509JWK<RSAPublicKey,RSAPrivateKey> - Returns:
- this JWK
-
toPublicKey
Description copied from interface:AsymmetricJWKConverts the JWK to its corresponding public key.
- Specified by:
toPublicKeyin interfaceAsymmetricJWK<RSAPublicKey,RSAPrivateKey> - Returns:
- a public key
- Throws:
JWKProcessingException- if there was an error converting the JWK to a public key
-
toPrivateKey
Description copied from interface:AsymmetricJWKConverts the JWK to its corresponding private key.
- Specified by:
toPrivateKeyin interfaceAsymmetricJWK<RSAPublicKey,RSAPrivateKey> - Returns:
- an optional containing the private key or an empty optional if the key does not contain private information
- Throws:
JWKProcessingException- if there was an error converting the JWK to a private key
-
toPublicJWK
Description copied from interface:JWKReturns a public and safe to share representation of the key.
- Specified by:
toPublicJWKin interfaceAsymmetricJWK<RSAPublicKey,RSAPrivateKey> - Specified by:
toPublicJWKin interfaceJWK- Specified by:
toPublicJWKin interfaceRSAJWK- Specified by:
toPublicJWKin interfaceX509JWK<RSAPublicKey,RSAPrivateKey> - Returns:
- a public representation of this JWK
-
minify
Description copied from interface:JWKReturns a minified representation of the key only containing required data.
Note that the returned JWK may contain private data.
-
toJWKThumbprint
Description copied from interface:JWKGenerates and returns the JWK thumbprint using the specified digest.
- Specified by:
toJWKThumbprintin interfaceJWK- Parameters:
digest- the message digest to use- Returns:
- the JWK thumbprint
-
supportsAlgorithm
Description copied from interface:JWKDetermines whether the JWK supports the specified JWA algorithm.
- Specified by:
supportsAlgorithmin interfaceJWK- Parameters:
alg- a JWA algorithm- Returns:
- true if the algorithm is supported, false otherwise
-
signer
Description copied from interface:JWKReturns a signer using this JWK.
- Specified by:
signerin interfaceJWK- Overrides:
signerin classAbstractJWK- Returns:
- a signer
- Throws:
JWKProcessingException- if the JWK does not support signature operations (i.e. missing algorithm, algorithm is not a signature algorithm...)
-
signer
Description copied from interface:JWKReturns a signer using this JWK and the specified algorithm.
- Specified by:
signerin interfaceJWK- Overrides:
signerin classAbstractJWK- Parameters:
alg- a JWA signature algorithm- Returns:
- a signer
-
keyManager
Description copied from interface:JWKReturns a key manager using this JWK.
- Specified by:
keyManagerin interfaceJWK- Overrides:
keyManagerin classAbstractJWK- Returns:
- a key manager
- Throws:
JWKProcessingException- if the JWK does not support key management operations (i.e. missing algorithm, algorithm is not a key management algorithm...)
-
keyManager
Description copied from interface:JWKReturns a key manager using this JWK and the specified algorithm.
- Specified by:
keyManagerin interfaceJWK- Overrides:
keyManagerin classAbstractJWK- Parameters:
alg- a JWA key management algorithm- Returns:
- a key manager
- Throws:
JWKProcessingException- if the JWK does not support key management operations or if the specified algorithm is not a supported key management algorithm
-
hashCode
public int hashCode()- Specified by:
hashCodein interfaceJWK- Overrides:
hashCodein classAbstractX509JWK<RSAPublicKey,RSAPrivateKey>
-
equals
- Specified by:
equalsin interfaceJWK- Overrides:
equalsin classAbstractX509JWK<RSAPublicKey,RSAPrivateKey>
-