- All Known Subinterfaces:
AsymmetricJWK<A,
,B> ECJWK
,EdECJWK
,OCTJWK
,OKPJWK<A,
,B> PBES2JWK
,RSAJWK
,SymmetricJWK
,X509JWK<A,
,B> XECJWK
A JSON Web Key as defined by RFC7517.
- Since:
- 1.5
- Author:
- Jeremy Kuhn
-
Field Summary
Modifier and TypeFieldDescriptionstatic final MessageDigest
Default JWK thumbprint digest.static final String
Decrypt content and validate decryption operation as defined by RFC7517 Section 4.3.static final String
Derive bits not to be used as a key operation as defined by RFC7517 Section 4.3.static final String
Derive key operation as defined by RFC7517 Section 4.3.static final String
Encrypt content operation as defined by RFC7517 Section 4.3.static final String
Compute digital signature or MAC operation as defined by RFC7517 Section 4.3.static final String
Decrypt key and validate decryption operation as defined by RFC7517 Section 4.3.static final String
Verify digital signature or MAC operation as defined by RFC7517 Section 4.3.static final String
Encrypt key operation as defined by RFC7517 Section 4.3.static final String
Encryption public key use as defined by RFC7517 Section 4.2.static final String
Signature public key use as defined by RFC7517 Section 4.2. -
Method Summary
Modifier and TypeMethodDescriptioncipher()
Returns a cipher using this JWK.Returns a cipher using this JWK and the specified algorithm.boolean
Returns the algorithm intended for use with the key.getKeyId()
Returns the key id.Returns the set of key operations.Returns the key type.Returns the public key use.int
hashCode()
boolean
Determines whether this key is trusted.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.signer()
Returns a signer using this JWK.Returns a signer using this JWK and the specified algorithm.boolean
supportsAlgorithm
(String alg) Determines whether the JWK supports the specified JWA algorithm.default String
Generates and returns the JWK thumbprint using the defaul digest.toJWKThumbprint
(MessageDigest digest) Generates and returns the JWK thumbprint using the specified digest.Returns a public and safe to share representation of the key.trust()
Trusts the key explicitly.
-
Field Details
-
DEFAULT_THUMBPRINT_DIGEST
Default JWK thumbprint digest. -
USE_SIG
Signature public key use as defined by RFC7517 Section 4.2.- See Also:
-
USE_ENC
Encryption public key use as defined by RFC7517 Section 4.2.- See Also:
-
KEY_OP_SIGN
Compute digital signature or MAC operation as defined by RFC7517 Section 4.3.- See Also:
-
KEY_OP_VERIFY
Verify digital signature or MAC operation as defined by RFC7517 Section 4.3.- See Also:
-
KEY_OP_ENCRYPT
Encrypt content operation as defined by RFC7517 Section 4.3.- See Also:
-
KEY_OP_DECRYPT
Decrypt content and validate decryption operation as defined by RFC7517 Section 4.3.- See Also:
-
KEY_OP_WRAP_KEY
Encrypt key operation as defined by RFC7517 Section 4.3.- See Also:
-
KEY_OP_UNWRAP_KEY
Decrypt key and validate decryption operation as defined by RFC7517 Section 4.3.- See Also:
-
KEY_OP_DERIVE_KEY
Derive key operation as defined by RFC7517 Section 4.3.- See Also:
-
KEY_OP_DERIVE_BITS
Derive bits not to be used as a key operation as defined by RFC7517 Section 4.3.- See Also:
-
-
Method Details
-
getKeyType
String getKeyType()Returns the key type.
- Returns:
- the key type
-
getPublicKeyUse
String getPublicKeyUse()Returns the public key use.
- Returns:
- the public key use
-
getKeyOperations
Returns the set of key operations.
- Returns:
- the set of key operations
-
getAlgorithm
String getAlgorithm()Returns the algorithm intended for use with the key.
- Returns:
- the key algorithm
-
getKeyId
String getKeyId()Returns the key id.
- Returns:
- the key id
-
isTrusted
boolean isTrusted()Determines whether this key is trusted.
Untrusted keys are typically resolved from unsecured JOSE headers (e.g. no x5c, no x5u...), the are excluded when reading a JOSE object for obvious security reasons.
Implementations can rely on trust stores or certificate paths validation to determine whether a key is trusted. It is also possible to explicitly trust a key by invoking the
trust()
. method.- Returns:
- true if the key is trusted, false otherwise.
-
trust
JWK trust()Trusts the key explicitly.
This should be used with care when the authenticity of an untrusted key has been established through external means.
- Returns:
- this JWK
-
toPublicJWK
JWK toPublicJWK()Returns a public and safe to share representation of the key.
- Returns:
- a public representation of this JWK
-
minify
JWK minify()Returns a minified representation of the key only containing required data.
Note that the returned JWK may contain private data.
- Returns:
- a minified representation of this JWK
-
toJWKThumbprint
Generates and returns the JWK thumbprint using the defaul digest.
- Returns:
- the JWK thumbprint
-
toJWKThumbprint
Generates and returns the JWK thumbprint using the specified digest.
- Parameters:
digest
- the message digest to use- Returns:
- the JWK thumbprint
-
supportsAlgorithm
Determines whether the JWK supports the specified JWA algorithm.
- Parameters:
alg
- a JWA algorithm- Returns:
- true if the algorithm is supported, false otherwise
-
signer
Returns a signer using this JWK.
- Returns:
- a signer
- Throws:
JWKProcessingException
- if the JWK does not support signature operations (i.e. missing algorithm, algorithm is not a signature algorithm...)
-
signer
Returns a signer using this JWK and the specified algorithm.
- Parameters:
alg
- a JWA signature algorithm- Returns:
- a signer
- Throws:
JWKProcessingException
- if the JWK does not support signature operations or if the specified algorithm is not a supported signature algorithm
-
cipher
Returns a cipher using this JWK.
- Returns:
- a cipher
- Throws:
JWKProcessingException
- if the JWK does not support encryption operations (i.e. missing algorithm, algorithm is not an encryption algorithm...)
-
cipher
Returns a cipher using this JWK and the specified algorithm.
- Parameters:
alg
- a JWA encryption algorithm- Returns:
- a cipher
- Throws:
JWKProcessingException
- if the JWK does not support encryption operations or if the specified algorithm is not a supported encryption algorithm
-
keyManager
Returns a key manager using this JWK.
- 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
Returns a key manager using this JWK and the specified algorithm.
- 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
int hashCode() -
equals
-