Class GenericECJWK
- All Implemented Interfaces:
AsymmetricJWK<ECPublicKey,,ECPrivateKey> ECJWK,JWK,X509JWK<ECPublicKey,ECPrivateKey>
Generic Elliptic Curve JSON Web Key implementation.
It supports the following algorithms:
- ES256
- ES384
- ES512
- ES256K (deprecated)
- ECDH-ES with elliptic curve P-256, P-384 or P-521
- ECDH-ES+A128KW with elliptic curve P-256, P-384 or P-521
- ECDH-ES+A192KW with elliptic curve P-256, P-384 or P-521
- ECDH-ES+A256KW with elliptic curve P-256, P-384 or P-521
- Since:
- 1.5
- Author:
- Jeremy Kuhn
-
Field Summary
Fields 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
ConstructorsConstructorDescriptionGenericECJWK(ECCurve curve, String x, String y) Creates an untrusted public generic EC JWK with the specified curve and public coordinates.GenericECJWK(ECCurve curve, String x, String y, String d) Creates an untrusted private generic EC JWK with the specified curve, public coordinates and private key value.GenericECJWK(ECCurve curve, String x, String y, String d, X509Certificate certificate) Creates a public generic EC JWK with the specified curve, public coordinates, private key value and certificate.GenericECJWK(ECCurve curve, String x, String y, String d, ECPrivateKey key, boolean trusted) Creates a private generic EC JWK with the specified curve, public coordinates, private key value and EC private key.GenericECJWK(ECCurve curve, String x, String y, String d, ECPrivateKey key, X509Certificate certificate, boolean trusted) Creates a private generic EC JWK with the specified curve, public coordinates, private key value, EC private key and certificate.GenericECJWK(ECCurve curve, String x, String y, X509Certificate certificate) Creates a public generic EC JWK with the specified curve, public coordinates and certificate. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcheckSignature(JWAAlgorithm<?> algorithm) Checks that the key and the specified algorithm supports signature operations.booleangetCurve()Returns the JWA Elliptic curve name.Returns the ECC private key encoded as Base64URL.Returns the X coordinate encoded as Base64URL.Returns the Y coordinate 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(ECAlgorithm ecAlg) Sets the Elliptic 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.toJWKThumbprint(MessageDigest digest) Generates and returns the JWK thumbprint using the specified digest.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.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, 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, getAlgorithm, getKeyId, getKeyOperations, getKeyType, getPublicKeyUse, isTrusted, toJWKThumbprintMethods inherited from interface io.inverno.mod.security.jose.jwk.X509JWK
getX509Certificate, getX509CertificateChain, getX509CertificateSHA1Thumbprint, getX509CertificateSHA256Thumbprint, getX509CertificateURL
-
Constructor Details
-
GenericECJWK
Creates an untrusted public generic EC JWK with the specified curve and public coordinates.
- Parameters:
curve- an elliptic curvex- the x coordinate encoded as Base64URL without paddingy- the y coordinate encoded as Base64URL without padding
-
GenericECJWK
Creates a public generic EC JWK with the specified curve, public coordinates 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 x coordinate encoded as Base64URL without paddingy- the y coordinate encoded as Base64URL without paddingcertificate- an X.509 certificate
-
GenericECJWK
Creates an untrusted private generic EC JWK with the specified curve, public coordinates and private key value.
- Parameters:
curve- an elliptic curvex- the x coordinate encoded as Base64URL without paddingy- the y coordinate encoded as Base64URL without paddingd- the private key value encoded as Base64URL without padding
-
GenericECJWK
Creates a private generic EC JWK with the specified curve, public coordinates, private key value and EC private key.
- Parameters:
curve- an elliptic curvex- the x coordinate encoded as Base64URL without paddingy- the y coordinate encoded as Base64URL without paddingd- the private key value encoded as Base64URL without paddingkey- an EC private keytrusted- true to create a trusted JWK, false otherwise
-
GenericECJWK
Creates a public generic EC JWK with the specified curve, public coordinates, 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 x coordinate encoded as Base64URL without paddingy- the y coordinate encoded as Base64URL without paddingd- the private key value encoded as Base64URL without paddingcertificate- an X.509 certificate
-
GenericECJWK
public GenericECJWK(ECCurve curve, String x, String y, String d, ECPrivateKey key, X509Certificate certificate, boolean trusted) Creates a private generic EC JWK with the specified curve, public coordinates, private key value, EC private key and certificate.
- Parameters:
curve- an elliptic curvex- the x coordinate encoded as Base64URL without paddingy- the y coordinate encoded as Base64URL without paddingd- the private key value encoded as Base64URL without paddingkey- an EC private keycertificate- an X.509 certificatetrusted- true to create a trusted JWK, false otherwise
-
-
Method Details
-
setAlgorithm
Sets the Elliptic Curve JWA algorithm.
- Parameters:
ecAlg- an EC algorithm
-
setAlgorithm
Description copied from class:AbstractJWKSets the algorithm intended for use with the key.
- Overrides:
setAlgorithmin classAbstractJWK- Parameters:
alg- the JWA algorithm
-
getCurve
Description copied from interface:ECJWKReturns the JWA Elliptic curve name.
-
getXCoordinate
Description copied from interface:ECJWKReturns the X coordinate encoded as Base64URL.
- Specified by:
getXCoordinatein interfaceECJWK- Returns:
- the Base64URL encoded X coordinate with no padding.
-
getYCoordinate
Description copied from interface:ECJWKReturns the Y coordinate encoded as Base64URL.
- Specified by:
getYCoordinatein interfaceECJWK- Returns:
- the Base64URL encoded Y coordinate with no padding.
-
getEccPrivateKey
Description copied from interface:ECJWKReturns the ECC private key encoded as Base64URL.
- Specified by:
getEccPrivateKeyin interfaceECJWK- Returns:
- the Base64URL encoded ECC private key 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.
- Specified by:
trustin interfaceAsymmetricJWK<ECPublicKey,ECPrivateKey> - Specified by:
trustin interfaceECJWK- Specified by:
trustin interfaceJWK- Specified by:
trustin interfaceX509JWK<ECPublicKey,ECPrivateKey> - Returns:
- this JWK
-
toPublicKey
Description copied from interface:AsymmetricJWKConverts the JWK to its corresponding public key.
- Specified by:
toPublicKeyin interfaceAsymmetricJWK<ECPublicKey,ECPrivateKey> - 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<ECPublicKey,ECPrivateKey> - 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<ECPublicKey,ECPrivateKey> - Specified by:
toPublicJWKin interfaceECJWK- Specified by:
toPublicJWKin interfaceJWK- Specified by:
toPublicJWKin interfaceX509JWK<ECPublicKey,ECPrivateKey> - 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
-
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
-
hashCode
public int hashCode()- Specified by:
hashCodein interfaceJWK- Overrides:
hashCodein classAbstractX509JWK<ECPublicKey,ECPrivateKey>
-
equals
- Specified by:
equalsin interfaceJWK- Overrides:
equalsin classAbstractX509JWK<ECPublicKey,ECPrivateKey>
-