Class GenericPBES2JWK
- All Implemented Interfaces:
JWK,PBES2JWK,SymmetricJWK
Generic Password-based JSON Web Key implementation.
It supports the following algorithms
- PBES2-HS256+A128KW
- PBES2-HS384+A192KW
- PBES2-HS512+A256KW
- Since:
- 1.5
- Author:
- Jeremy Kuhn
-
Field Summary
Fields 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
ConstructorsConstructorDescriptionCreates an untrusted PBES2 JWK.Creates an untrusted generic PBES2 JWK with the specified password value.GenericPBES2JWK(String p, SecretKey key, boolean trusted) Creates a generic PBES2 JWK with the specified key value and secret key. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcheckKeyManagement(JWAAlgorithm<?> algorithm) Checks that the key and the specified algorithm supports key management operations.booleanReturns the password 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(PBES2Algorithm pbes2Alg) Sets the PBES2 JWA algorithm.voidsetAlgorithm(String alg) Sets the algorithm intended for use with the key.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.Returns a public and safe to share representation of the key.Converts the JWK to its corresponding secret key.trust()Trusts the key explicitly.Methods inherited from class io.inverno.mod.security.jose.internal.jwk.AbstractJWK
checkEncryption, checkSignature, cipher, cipher, getAlgorithm, getDefaultThumbprintDigest, getKey, getKeyId, getKeyOperations, getKeyType, getPublicKeyUse, isTrusted, setKeyId, setKeyOperations, setPublicKeyUse, signer, signer, toStringMethods 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, signer, signer, toJWKThumbprint
-
Constructor Details
-
GenericPBES2JWK
public GenericPBES2JWK()Creates an untrusted PBES2 JWK.
-
GenericPBES2JWK
Creates an untrusted generic PBES2 JWK with the specified password value.
- Parameters:
p- the password value encoded as Base64URL without padding
-
GenericPBES2JWK
Creates a generic PBES2 JWK with the specified key value and secret key.
- Parameters:
p- the password value encoded as Base64URL without paddingkey- a secret keytrusted- true to create a trusted JWK, false otherwise
-
-
Method Details
-
setAlgorithm
Sets the PBES2 JWA algorithm.
- Parameters:
pbes2Alg- a PBES2 algorithm
-
setAlgorithm
Description copied from class:AbstractJWKSets the algorithm intended for use with the key.
- Overrides:
setAlgorithmin classAbstractJWK- Parameters:
alg- the JWA algorithm
-
getPassword
Description copied from interface:PBES2JWKReturns the password encoded as Base64URL.
- Specified by:
getPasswordin interfacePBES2JWK- Returns:
- the Base64URL encoded password with no padding.
-
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.
-
toSecretKey
Description copied from interface:SymmetricJWKConverts the JWK to its corresponding secret key.
- Specified by:
toSecretKeyin interfaceSymmetricJWK- Returns:
- an optional containing the secret key or an empty optional if the key does not contain secret information
- Throws:
JWKProcessingException- if there was an error converting the JWK to a secret key
-
toPublicJWK
Description copied from interface:JWKReturns a public and safe to share representation of the key.
- Specified by:
toPublicJWKin interfaceJWK- Specified by:
toPublicJWKin interfacePBES2JWK- Specified by:
toPublicJWKin interfaceSymmetricJWK- 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
-
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
-
checkKeyManagement
Description copied from class:AbstractJWKChecks that the key and the specified algorithm supports key management operations.
- Overrides:
checkKeyManagementin classAbstractJWK- Parameters:
algorithm- a JWA algorithm- Throws:
JWAKeyManagerException
-
hashCode
public int hashCode()- Specified by:
hashCodein interfaceJWK- Overrides:
hashCodein classAbstractJWK
-
equals
- Specified by:
equalsin interfaceJWK- Overrides:
equalsin classAbstractJWK
-