K - the type of Java Key represented by the created Jwk.J - the type of Jwk created by the builderpublic interface DynamicJwkBuilder<K extends Key,J extends Jwk<K>> extends JwkBuilder<K,J,DynamicJwkBuilder<K,J>>
JwkBuilder that coerces to a more type-specific builder based on the Key that will be
represented as a JWK.| Modifier and Type | Method and Description |
|---|---|
<A extends PublicKey,B extends PrivateKey> |
chain(List<X509Certificate> chain)
Ensures the builder will create a
PublicJwk for the specified Java X509Certificate chain. |
EcPublicJwkBuilder |
ecChain(List<X509Certificate> chain)
Ensures the builder will create an
EcPublicJwk for the specified Java X509Certificate chain. |
EcPrivateJwkBuilder |
ecKeyPair(KeyPair keyPair)
Ensures the builder will create an
EcPrivateJwk for the specified Java Elliptic Curve
KeyPair. |
<A extends PublicKey,B extends PrivateKey> |
key(A key)
|
<A extends PublicKey,B extends PrivateKey> |
key(B key)
Ensures the builder will create a
PrivateJwk for the specified Java PrivateKey argument. |
EcPrivateJwkBuilder |
key(ECPrivateKey key)
Ensures the builder will create an
EcPrivateJwk for the specified Java ECPrivateKey. |
EcPublicJwkBuilder |
key(ECPublicKey key)
Ensures the builder will create an
EcPublicJwk for the specified Java ECPublicKey. |
RsaPrivateJwkBuilder |
key(RSAPrivateKey key)
Ensures the builder will create an
RsaPrivateJwk for the specified Java RSAPrivateKey. |
RsaPublicJwkBuilder |
key(RSAPublicKey key)
Ensures the builder will create an
RsaPublicJwk for the specified Java RSAPublicKey. |
SecretJwkBuilder |
key(SecretKey key)
|
<A extends PublicKey,B extends PrivateKey> |
keyPair(KeyPair keyPair)
Ensures the builder will create a
PrivateJwk for the specified Java KeyPair argument. |
<A extends PublicKey,B extends PrivateKey> |
octetChain(List<X509Certificate> chain)
Ensures the builder will create an
OctetPublicJwk for the specified Java X509Certificate chain. |
<A extends PrivateKey,B extends PublicKey> |
octetKey(A key)
Ensures the builder will create an
OctetPrivateJwk for the specified Edwards-curve PrivateKey
argument. |
<A extends PublicKey,B extends PrivateKey> |
octetKey(A key)
Ensures the builder will create an
OctetPublicJwk for the specified Edwards-curve PublicKey
argument. |
<A extends PrivateKey,B extends PublicKey> |
octetKeyPair(KeyPair keyPair)
Ensures the builder will create an
OctetPrivateJwk for the specified Java Edwards-curve
KeyPair. |
RsaPublicJwkBuilder |
rsaChain(List<X509Certificate> chain)
Ensures the builder will create an
RsaPublicJwk for the specified Java X509Certificate chain. |
RsaPrivateJwkBuilder |
rsaKeyPair(KeyPair keyPair)
Ensures the builder will create an
RsaPrivateJwk for the specified Java RSA
KeyPair. |
algorithm, id, idFromThumbprint, idFromThumbprint, operationsadd, add, delete, emptyprovider, randomoperationPolicy<A extends PublicKey,B extends PrivateKey> PublicJwkBuilder<A,B,?,?,?,?> chain(List<X509Certificate> chain) throws UnsupportedKeyException
PublicJwk for the specified Java X509Certificate chain.
The first X509Certificate in the chain (at array index 0) MUST contain a PublicKey
instance when calling the certificate's getPublicKey() method.
This method is provided for congruence with the other chain methods and is expected to be used when
the calling code has a variable PublicKey reference. Based on the argument type, it will
delegate to one of the following methods if possible:
If the specified chain argument is not capable of being supported by one of those methods, an
UnsupportedKeyException will be thrown.
Type Parameters
In addition to the public key type A, the public key's associated private key type
B is parameterized as well. This ensures that any subsequent call to the builder's
privateKey method will be type-safe. For example:
Jwks.builder().<EdECPublicKey, EdECPrivateKey>chain(edECPublicKeyX509CertificateChain)
.privateKey(aPrivateKey) // <-- must be an EdECPrivateKey instance
... etc ...
.build();A - the type of PublicKey provided by the created public JWK.B - the type of PrivateKey that may be paired with the PublicKey to produce a
PrivateJwk if desired.chain - the X509Certificate chain to inspect to find the PublicKey to represent as a
PublicJwk.PublicJwkBuilder for continued method chaining.UnsupportedKeyException - if the specified key is not a supported type and cannot be used to delegate to
other key methods.PublicJwk,
PrivateJwkSecretJwkBuilder key(SecretKey key)
key - the SecretKey to represent as a SecretJwk.SecretJwkBuilder.RsaPublicJwkBuilder key(RSAPublicKey key)
RsaPublicJwk for the specified Java RSAPublicKey.key - the RSAPublicKey to represent as a RsaPublicJwk.RsaPublicJwkBuilder.RsaPrivateJwkBuilder key(RSAPrivateKey key)
RsaPrivateJwk for the specified Java RSAPrivateKey. If
possible, it is recommended to also call the resulting builder's
publicKey method with the private key's matching
PublicKey for better performance. See the
publicKey and PrivateJwk JavaDoc for more
information.key - the RSAPublicKey to represent as a RsaPublicJwk.RsaPrivateJwkBuilder.EcPublicJwkBuilder key(ECPublicKey key)
EcPublicJwk for the specified Java ECPublicKey.key - the ECPublicKey to represent as a EcPublicJwk.EcPublicJwkBuilder.EcPrivateJwkBuilder key(ECPrivateKey key)
EcPrivateJwk for the specified Java ECPrivateKey. If
possible, it is recommended to also call the resulting builder's
publicKey method with the private key's matching
PublicKey for better performance. See the
publicKey and PrivateJwk JavaDoc for more
information.key - the ECPublicKey to represent as an EcPublicJwk.EcPrivateJwkBuilder.<A extends PublicKey,B extends PrivateKey> PublicJwkBuilder<A,B,?,?,?,?> key(A key) throws UnsupportedKeyException
PublicJwk for the specified Java PublicKey argument. This
method is provided for congruence with the other key methods and is expected to be used when
the calling code has an untyped PublicKey reference. Based on the argument type, it will delegate to one
of the following methods if possible:
If the specified key argument is not capable of being supported by one of those methods, an
UnsupportedKeyException will be thrown.
Type Parameters
In addition to the public key type A, the public key's associated private key type
B is parameterized as well. This ensures that any subsequent call to the builder's
privateKey method will be type-safe. For example:
Jwks.builder().<EdECPublicKey, EdECPrivateKey>key(anEdECPublicKey)
.privateKey(aPrivateKey) // <-- must be an EdECPrivateKey instance
... etc ...
.build();A - the type of PublicKey provided by the created public JWK.B - the type of PrivateKey that may be paired with the PublicKey to produce a
PrivateJwk if desired.key - the PublicKey to represent as a PublicJwk.PublicJwkBuilder for continued method chaining.UnsupportedKeyException - if the specified key is not a supported type and cannot be used to delegate to
other key methods.PublicJwk,
PrivateJwk<A extends PublicKey,B extends PrivateKey> PrivateJwkBuilder<B,A,?,?,?> key(B key) throws UnsupportedKeyException
PrivateJwk for the specified Java PrivateKey argument. This
method is provided for congruence with the other key methods and is expected to be used when
the calling code has an untyped PrivateKey reference. Based on the argument type, it will delegate to one
of the following methods if possible:
If the specified key argument is not capable of being supported by one of those methods, an
UnsupportedKeyException will be thrown.
Type Parameters
In addition to the private key type B, the private key's associated public key type
A is parameterized as well. This ensures that any subsequent call to the builder's
publicKey method will be type-safe. For example:
Jwks.builder().<EdECPublicKey, EdECPrivateKey>key(anEdECPrivateKey)
.publicKey(aPublicKey) // <-- must be an EdECPublicKey instance
... etc ...
.build();A - the type of PublicKey paired with the key argument to produce the PrivateJwk.B - the type of the PrivateKey argument.key - the PrivateKey to represent as a PrivateJwk.PrivateJwkBuilder for continued method chaining.UnsupportedKeyException - if the specified key is not a supported type and cannot be used to delegate to
other key methods.PublicJwk,
PrivateJwk<A extends PublicKey,B extends PrivateKey> PrivateJwkBuilder<B,A,?,?,?> keyPair(KeyPair keyPair) throws UnsupportedKeyException
PrivateJwk for the specified Java KeyPair argument. This
method is provided for congruence with the other keyPair methods and is expected to be used when
the calling code has a variable PrivateKey reference. Based on the argument's PrivateKey type,
it will delegate to one of the following methods if possible:
and automatically set the resulting builder's publicKey with
the pair's PublicKey.
If the specified key argument is not capable of being supported by one of those methods, an
UnsupportedKeyException will be thrown.
Type Parameters
In addition to the private key type B, the private key's associated public key type
A is parameterized as well. This ensures that any subsequent call to the builder's
publicKey method will be type-safe. For example:
Jwks.builder().<EdECPublicKey, EdECPrivateKey>keyPair(anEdECKeyPair)
.publicKey(aPublicKey) // <-- must be an EdECPublicKey instance
... etc ...
.build();A - the keyPair argument's PublicKey typeB - the keyPair argument's PrivateKey typekeyPair - the KeyPair containing the public and private keyPrivateJwkBuilder for continued method chaining.UnsupportedKeyException - if the specified KeyPair's keys are not supported and cannot be used to
delegate to other key methods.PublicJwk,
PrivateJwk<A extends PublicKey,B extends PrivateKey> OctetPublicJwkBuilder<A,B> octetKey(A key)
OctetPublicJwk for the specified Edwards-curve PublicKey
argument. The PublicKey must be an instance of one of the following:
PublicKey with a valid Edwards Curve DER encoding, such as those
provided by BouncyCastle on earlier JDKs.Type Parameters
In addition to the public key type A, the public key's associated private key type
B is parameterized as well. This ensures that any subsequent call to the builder's
privateKey method will be type-safe. For example:
Jwks.builder().<EdECPublicKey, EdECPrivateKey>key(anEdECPublicKey)
.privateKey(aPrivateKey) // <-- must be an EdECPrivateKey instance
... etc ...
.build();A - the type of Edwards-curve PublicKey provided by the created public JWK.B - the type of Edwards-curve PrivateKey that may be paired with the PublicKey to produce
an OctetPrivateJwk if desired.key - the Edwards-curve PublicKey to represent as an OctetPublicJwk.OctetPublicJwkBuilder for continued method chaining.UnsupportedKeyException - if the specified key is not a supported Edwards-curve key.<A extends PrivateKey,B extends PublicKey> OctetPrivateJwkBuilder<A,B> octetKey(A key)
OctetPrivateJwk for the specified Edwards-curve PrivateKey
argument. The PrivateKey must be an instance of one of the following:
PrivateKey with a valid Edwards Curve DER encoding, such as those
provided by BouncyCastle on earlier JDKs.Type Parameters
In addition to the private key type B, the private key's associated public key type
A is parameterized as well. This ensures that any subsequent call to the builder's
publicKey method will be type-safe. For example:
Jwks.builder().<EdECPublicKey, EdECPrivateKey>key(anEdECPrivateKey)
.publicKey(aPublicKey) // <-- must be an EdECPublicKey instance
... etc ...
.build();A - the type of the Edwards-curve PrivateKey argument.B - the type of Edwards-curve PublicKey paired with the key argument to produce the
OctetPrivateJwk.key - the Edwards-curve PrivateKey to represent as an OctetPrivateJwk.OctetPrivateJwkBuilder for continued method chaining.UnsupportedKeyException - if the specified key is not a supported Edwards-curve key.<A extends PublicKey,B extends PrivateKey> OctetPublicJwkBuilder<A,B> octetChain(List<X509Certificate> chain)
OctetPublicJwk for the specified Java X509Certificate chain.
The first X509Certificate in the chain (at list index 0) MUST
contain an Edwards-curve public key as defined by
octetKey(PublicKey).A - the type of Edwards-curve PublicKey contained in the first X509Certificate.B - the type of Edwards-curve PrivateKey that may be paired with the PublicKey to produce
an OctetPrivateJwk if desired.chain - the X509Certificate chain to inspect to find the Edwards-curve PublicKey to
represent as an OctetPublicJwk.OctetPublicJwkBuilder for continued method chaining.<A extends PrivateKey,B extends PublicKey> OctetPrivateJwkBuilder<A,B> octetKeyPair(KeyPair keyPair)
OctetPrivateJwk for the specified Java Edwards-curve
KeyPair. The pair's public key MUST be an
Edwards-curve public key as defined by octetKey(PublicKey). The pair's
private key MUST be an Edwards-curve private key as defined by
octetKey(PrivateKey).A - the type of Edwards-curve PublicKey contained in the key pair.B - the type of the Edwards-curve PrivateKey contained in the key pair.keyPair - the Edwards-curve KeyPair to represent as an OctetPrivateJwk.OctetPrivateJwkBuilder for continued method chaining.IllegalArgumentException - if the keyPair does not contain Edwards-curve public and private key
instances.EcPublicJwkBuilder ecChain(List<X509Certificate> chain)
EcPublicJwk for the specified Java X509Certificate chain.
The first X509Certificate in the chain (at list index 0) MUST contain an ECPublicKey
instance when calling the certificate's getPublicKey() method.chain - the X509Certificate chain to inspect to find the ECPublicKey to represent as a
EcPublicJwk.EcPublicJwkBuilder.EcPrivateJwkBuilder ecKeyPair(KeyPair keyPair) throws IllegalArgumentException
EcPrivateJwk for the specified Java Elliptic Curve
KeyPair. The pair's public key MUST be an
ECPublicKey instance. The pair's private key MUST be an
ECPrivateKey instance.keyPair - the EC KeyPair to represent as an EcPrivateJwk.EcPrivateJwkBuilder.IllegalArgumentException - if the keyPair does not contain ECPublicKey and
ECPrivateKey instances.RsaPublicJwkBuilder rsaChain(List<X509Certificate> chain)
RsaPublicJwk for the specified Java X509Certificate chain.
The first X509Certificate in the chain (at list index 0) MUST contain an RSAPublicKey
instance when calling the certificate's getPublicKey() method.chain - the X509Certificate chain to inspect to find the RSAPublicKey to represent as a
RsaPublicJwk.RsaPublicJwkBuilder.RsaPrivateJwkBuilder rsaKeyPair(KeyPair keyPair) throws IllegalArgumentException
RsaPrivateJwk for the specified Java RSA
KeyPair. The pair's public key MUST be an
RSAPublicKey instance. The pair's private key MUST be an
RSAPrivateKey instance.keyPair - the RSA KeyPair to represent as an RsaPrivateJwk.RsaPrivateJwkBuilder.IllegalArgumentException - if the keyPair does not contain RSAPublicKey and
RSAPrivateKey instances.Copyright © 2014–2025 jsonwebtoken.io. All rights reserved.