Class GenericOCTJWK
- All Implemented Interfaces:
JWK,OCTJWK,SymmetricJWK
Generic Octet JSON Web Key implementation.
It supports the following algorithms
- HS256
- HS384
- HS512
- A128KW
- A256KW
- A512KW
- A128GCMKW
- A192GCMKW
- A256GCMKW
- A128GCM
- A192GCM
- A256GCM
- A128CBC-HS256
- A192CBC-HS384
- A256CBC-HS512
- 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 OCT JWK.Creates an untrusted generic OCT JWK with the specified key value.GenericOCTJWK(String k, SecretKey key, boolean trusted) Creates a generic OCT JWK with the specified key value and secret key. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcheckEncryption(JWAAlgorithm<?> algorithm) Checks that the key and the specified algorithm supports encryption operations.protected voidcheckKeyManagement(JWAAlgorithm<?> algorithm) Checks that the key and the specified algorithm supports key management operations.protected voidcheckSignature(JWAAlgorithm<?> algorithm) Checks that the key and the specified algorithm supports signature operations.cipher()Returns a cipher using this JWK.Returns a cipher using this JWK and the specified algorithm.booleanReturns the key value 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(OCTAlgorithm octAlg) Sets the Octet JWA algorithm.voidsetAlgorithm(String alg) Sets the algorithm intended for use with the key.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.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
getAlgorithm, getDefaultThumbprintDigest, getKey, getKeyId, getKeyOperations, getKeyType, getPublicKeyUse, isTrusted, setKeyId, setKeyOperations, setPublicKeyUse, 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
getAlgorithm, getKeyId, getKeyOperations, getKeyType, getPublicKeyUse, isTrusted, toJWKThumbprint
-
Constructor Details
-
GenericOCTJWK
public GenericOCTJWK()Creates an untrusted OCT JWK.
-
GenericOCTJWK
Creates an untrusted generic OCT JWK with the specified key value.
- Parameters:
k- the key value encoded as Base64URL without padding
-
GenericOCTJWK
Creates a generic OCT JWK with the specified key value and secret key.
- Parameters:
k- the key value encoded as Base64URL without paddingkey- a secret keytrusted- true to create a trusted JWK, false otherwise
-
-
Method Details
-
setAlgorithm
Sets the Octet JWA algorithm.
- Parameters:
octAlg- an OCT algorithm
-
setAlgorithm
Description copied from class:AbstractJWKSets the algorithm intended for use with the key.
- Overrides:
setAlgorithmin classAbstractJWK- Parameters:
alg- the JWA algorithm
-
getKeyValue
Description copied from interface:OCTJWKReturns the key value encoded as Base64URL.
- Specified by:
getKeyValuein interfaceOCTJWK- Returns:
- the Base64URL encoded key value 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 interfaceOCTJWK- 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
-
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
-
checkSignature
Description copied from class:AbstractJWKChecks that the key and the specified algorithm supports signature operations.
- Overrides:
checkSignaturein classAbstractJWK- Parameters:
algorithm- a JWA algorithm- Throws:
JWKProcessingException- if the key and/or the specified algorithm do not support signature operations
-
cipher
Description copied from interface:JWKReturns a cipher using this JWK.
- Specified by:
cipherin interfaceJWK- Overrides:
cipherin classAbstractJWK- Returns:
- a cipher
- Throws:
JWKProcessingException- if the JWK does not support encryption operations (i.e. missing algorithm, algorithm is not an encryption algorithm...)
-
cipher
Description copied from interface:JWKReturns a cipher using this JWK and the specified algorithm.
- Specified by:
cipherin interfaceJWK- Overrides:
cipherin classAbstractJWK- 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
-
checkEncryption
Description copied from class:AbstractJWKChecks that the key and the specified algorithm supports encryption operations.
- Overrides:
checkEncryptionin classAbstractJWK- Parameters:
algorithm- a JWA algorithm- Throws:
JWKProcessingException- if the key and/or the specified algorithm do not support encryption operations
-
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
-