Class GenericEdECJWK
- All Implemented Interfaces:
AsymmetricJWK<EdECPublicKey,,EdECPrivateKey> JWK,EdECJWK,OKPJWK<EdECPublicKey,,EdECPrivateKey> X509JWK<EdECPublicKey,EdECPrivateKey>
Generic Edward-Curve JSON Web Key implementation.
It supports the following algorithms:
- EdDSA with elliptic curve Ed25519 and Ed448.
- 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
ConstructorsConstructorDescriptionGenericEdECJWK(OKPCurve curve, String x) Creates an untrusted public generic EdEC JWK with the specified curve and public key value.GenericEdECJWK(OKPCurve curve, String x, String d) Creates an untrusted private generic EdEC JWK with the specified curve, public key value and private key value.GenericEdECJWK(OKPCurve curve, String x, String d, X509Certificate certificate) Creates a public generic EdEC JWK with the specified curve, public key value, private key value and certificate.GenericEdECJWK(OKPCurve curve, String x, String d, EdECPrivateKey key, boolean trusted) Creates a private generic EdEC JWK with the specified curve, public key value, private key value and private key.GenericEdECJWK(OKPCurve curve, String x, String d, EdECPrivateKey key, X509Certificate certificate, boolean trusted) Creates a private generic EdEC JWK with the specified curve, public coordinates, private key value, OKP private key and certificate.GenericEdECJWK(OKPCurve curve, String x, X509Certificate certificate) Creates a public generic EdEC JWK with the specified curve, public key value and certificate. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcheckSignature(JWAAlgorithm<?> algorithm) Checks that the key and the specified algorithm supports signature operations.minify()Returns a minified representation of the key only containing required data.voidsetAlgorithm(EdECAlgorithm edecAlg) Sets the Edward-Curve 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.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, cipher, cipher, getAlgorithm, getDefaultThumbprintDigest, getKey, getKeyId, getKeyOperations, getKeyType, getPublicKeyUse, isTrusted, keyManager, keyManager, 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, equals, getAlgorithm, getKeyId, getKeyOperations, getKeyType, getPublicKeyUse, hashCode, isTrusted, keyManager, keyManager, 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
-
GenericEdECJWK
Creates an untrusted public generic EdEC JWK with the specified curve and public key value.
- Parameters:
curve- an elliptic curvex- the public key value encoded as Base64URL without padding
-
GenericEdECJWK
Creates a public generic EdEC 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
-
GenericEdECJWK
Creates an untrusted private generic EdEC 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
-
GenericEdECJWK
Creates a private generic EdEC 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
-
GenericEdECJWK
Creates a public generic EdEC 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
-
GenericEdECJWK
public GenericEdECJWK(OKPCurve curve, String x, String d, EdECPrivateKey key, X509Certificate certificate, boolean trusted) Creates a private generic EdEC 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 Edward-Curve JWA algorithm.
- Parameters:
edecAlg- an EdEC 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<EdECPublicKey,EdECPrivateKey> - Specified by:
trustin interfaceEdECJWK- Specified by:
trustin interfaceJWK- Specified by:
trustin interfaceOKPJWK<EdECPublicKey,EdECPrivateKey> - Specified by:
trustin interfaceX509JWK<EdECPublicKey,EdECPrivateKey> - Returns:
- this JWK
-
toPublicKey
Description copied from interface:AsymmetricJWKConverts the JWK to its corresponding public key.
- Specified by:
toPublicKeyin interfaceAsymmetricJWK<EdECPublicKey,EdECPrivateKey> - 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<EdECPublicKey,EdECPrivateKey> - 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<EdECPublicKey,EdECPrivateKey> - Specified by:
toPublicJWKin interfaceEdECJWK- Specified by:
toPublicJWKin interfaceJWK- Specified by:
toPublicJWKin interfaceOKPJWK<EdECPublicKey,EdECPrivateKey> - Specified by:
toPublicJWKin interfaceX509JWK<EdECPublicKey,EdECPrivateKey> - 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 interfaceEdECJWK- Specified by:
minifyin interfaceJWK- Specified by:
minifyin interfaceOKPJWK<EdECPublicKey,EdECPrivateKey> - 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
-
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
- Throws:
JWKProcessingException- if the JWK does not support signature operations or if the specified algorithm is not a supported signature algorithm
-
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
-