Class GenericXECJWK
- All Implemented Interfaces:
AsymmetricJWK<XECPublicKey,,XECPrivateKey> JWK,OKPJWK<XECPublicKey,,XECPrivateKey> XECJWK,X509JWK<XECPublicKey,XECPrivateKey>
Generic Extended Elliptic Curve JSON Web Key implementation.
It supports the following algorithms:
- ECDH-ES with extended elliptic curve X25519 or X448
- ECDH-ES+A128KW with extended elliptic curve X25519 or X448
- ECDH-ES+A192KW with extended elliptic curve X25519 or X448
- ECDH-ES+A256KW with extended elliptic curve X25519 or X448
- Since:
- 1.5
- Author:
- Jeremy Kuhn
-
Field Summary
FieldsModifier and TypeFieldDescriptionThe set of curves supported by the JWK.Fields inherited from class io.inverno.mod.security.jose.internal.jwk.okp.AbstractOKPJWK
curve, d, privateKey, publicKey, xFields 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
ConstructorsConstructorDescriptionGenericXECJWK(OKPCurve curve, String x) Creates an untrusted public generic XEC JWK with the specified curve and public key value.GenericXECJWK(OKPCurve curve, String x, String d) Creates an untrusted private generic XEC JWK with the specified curve, public key value and private key value.GenericXECJWK(OKPCurve curve, String x, String d, X509Certificate certificate) Creates a public generic XEC JWK with the specified curve, public key value, private key value and certificate.GenericXECJWK(OKPCurve curve, String x, String d, XECPrivateKey key, boolean trusted) Creates a private generic XEC JWK with the specified curve, public key value, private key value and private key.GenericXECJWK(OKPCurve curve, String x, String d, XECPrivateKey key, X509Certificate certificate, boolean trusted) Creates a private generic XEC JWK with the specified curve, public coordinates, private key value, OKP private key and certificate.GenericXECJWK(OKPCurve curve, String x, X509Certificate certificate) Creates a public generic XEC JWK with the specified curve, public key value and certificate. -
Method Summary
Modifier and TypeMethodDescriptionReturns 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(XECAlgorithm xecAlg) Sets the extended Elliptic Curve 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.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.okp.AbstractOKPJWK
equals, getCurve, getPrivateKey, getPublicKey, hashCode, reverse, swap, toJWKThumbprintMethods 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, setPublicKeyUse, signer, signerMethods 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, equals, getAlgorithm, getKeyId, getKeyOperations, getKeyType, getPublicKeyUse, hashCode, isTrusted, signer, signer, toJWKThumbprint, toJWKThumbprintMethods inherited from interface io.inverno.mod.security.jose.jwk.okp.OKPJWK
getCurve, getPrivateKey, getPublicKeyMethods inherited from interface io.inverno.mod.security.jose.jwk.X509JWK
getX509Certificate, getX509CertificateChain, getX509CertificateSHA1Thumbprint, getX509CertificateSHA256Thumbprint, getX509CertificateURL
-
Field Details
-
SUPPORTED_CURVES
The set of curves supported by the JWK.
-
-
Constructor Details
-
GenericXECJWK
Creates an untrusted public generic XEC JWK with the specified curve and public key value.
- Parameters:
curve- an elliptic curvex- the public key value encoded as Base64URL without padding
-
GenericXECJWK
Creates a public generic XEC JWK with the specified curve, public key value and certificate.
The JWK is considered trusted if the specified certificate, which is assumed to be validated, is not null.
- Parameters:
curve- an elliptic curvex- the public key encoded as Base64URL without paddingcertificate- an X.509 certificate
-
GenericXECJWK
Creates an untrusted private generic XEC JWK with the specified curve, public key value and private key value.
- Parameters:
curve- an elliptic curvex- the public key value encoded as Base64URL without paddingd- the private key value encoded as Base64URL without padding
-
GenericXECJWK
Creates a private generic XEC JWK with the specified curve, public key value, private key value and private key.
- Parameters:
curve- an elliptic curvex- the public key value encoded as Base64URL without paddingd- the private key value encoded as Base64URL without paddingkey- a private keytrusted- true to create a trusted JWK, false otherwise
-
GenericXECJWK
Creates a public generic XEC JWK with the specified curve, public key value, private key value and certificate.
The JWK is considered trusted if the specified certificate, which is assumed to be validated, is not null.
- Parameters:
curve- an elliptic curvex- the public key value encoded as Base64URL without paddingd- the private key value encoded as Base64URL without paddingcertificate- an X.509 certificate
-
GenericXECJWK
public GenericXECJWK(OKPCurve curve, String x, String d, XECPrivateKey key, X509Certificate certificate, boolean trusted) Creates a private generic XEC JWK with the specified curve, public coordinates, private key value, OKP private key and certificate.
- Parameters:
curve- an elliptic curvex- the public key value encoded as Base64URL without paddingd- the private key value encoded as Base64URL without paddingkey- a private keycertificate- an X.509 certificatetrusted- true to create a trusted JWK, false otherwise
-
-
Method Details
-
setAlgorithm
Sets the extended Elliptic Curve JWA algorithm.
- Parameters:
xecAlg- an XEC algorithm
-
setAlgorithm
Description copied from class:AbstractJWKSets the algorithm intended for use with the key.
- Overrides:
setAlgorithmin classAbstractJWK- Parameters:
alg- the JWA algorithm
-
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<XECPublicKey,XECPrivateKey> - Specified by:
trustin interfaceJWK- Specified by:
trustin interfaceOKPJWK<XECPublicKey,XECPrivateKey> - Specified by:
trustin interfaceX509JWK<XECPublicKey,XECPrivateKey> - Specified by:
trustin interfaceXECJWK- Returns:
- this JWK
-
toPublicKey
Description copied from interface:AsymmetricJWKConverts the JWK to its corresponding public key.
- Specified by:
toPublicKeyin interfaceAsymmetricJWK<XECPublicKey,XECPrivateKey> - 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<XECPublicKey,XECPrivateKey> - 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<XECPublicKey,XECPrivateKey> - Specified by:
toPublicJWKin interfaceJWK- Specified by:
toPublicJWKin interfaceOKPJWK<XECPublicKey,XECPrivateKey> - Specified by:
toPublicJWKin interfaceX509JWK<XECPublicKey,XECPrivateKey> - Specified by:
toPublicJWKin interfaceXECJWK- 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.
- Specified by:
minifyin interfaceJWK- Specified by:
minifyin interfaceOKPJWK<XECPublicKey,XECPrivateKey> - Specified by:
minifyin interfaceXECJWK- Returns:
- a minified representation of this JWK
-
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
-