Package com.nimbusds.jose.jwk.gen
Class JWKGenerator<T extends JWK>
- java.lang.Object
-
- com.nimbusds.jose.jwk.gen.JWKGenerator<T>
-
- Direct Known Subclasses:
ECKeyGenerator
,OctetKeyPairGenerator
,OctetSequenceKeyGenerator
,RSAKeyGenerator
public abstract class JWKGenerator<T extends JWK> extends Object
Abstract JWK generator.- Version:
- 2018-09-07
- Author:
- Vladimir Dzhuvinov
-
-
Field Summary
Fields Modifier and Type Field Description protected Algorithm
alg
The intended JOSE algorithm for the key, optional.protected KeyStore
keyStore
Reference to the underlying key store,null
if none.protected String
kid
The key ID, optional.protected Set<KeyOperation>
ops
The key operations, optional.protected KeyUse
use
The key use, optional.protected boolean
x5tKid
Iftrue
sets the ID of the JWK to the SHA-256 thumbprint of the JWK.
-
Constructor Summary
Constructors Constructor Description JWKGenerator()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description JWKGenerator<T>
algorithm(Algorithm alg)
Sets the intended JOSE algorithm (alg
) for the JWK.abstract T
generate()
Generates the JWK according to the set parameters.JWKGenerator<T>
keyID(String kid)
Sets the ID (kid
) of the JWK.JWKGenerator<T>
keyIDFromThumbprint(boolean x5tKid)
Sets the ID (kid
) of the JWK to its SHA-256 JWK thumbprint (RFC 7638).JWKGenerator<T>
keyOperations(Set<KeyOperation> ops)
Sets the operations (key_ops
) of the JWK.JWKGenerator<T>
keyStore(KeyStore keyStore)
Sets the underlying key store.JWKGenerator<T>
keyUse(KeyUse use)
Sets the use (use
) of the JWK.
-
-
-
Field Detail
-
ops
protected Set<KeyOperation> ops
The key operations, optional.
-
x5tKid
protected boolean x5tKid
Iftrue
sets the ID of the JWK to the SHA-256 thumbprint of the JWK.
-
-
Constructor Detail
-
JWKGenerator
public JWKGenerator()
-
-
Method Detail
-
keyUse
public JWKGenerator<T> keyUse(KeyUse use)
Sets the use (use
) of the JWK.- Parameters:
use
- The key use,null
if not specified or if the key is intended for signing as well as encryption.- Returns:
- This generator.
-
keyOperations
public JWKGenerator<T> keyOperations(Set<KeyOperation> ops)
Sets the operations (key_ops
) of the JWK.- Parameters:
ops
- The key operations,null
if not specified.- Returns:
- This generator.
-
algorithm
public JWKGenerator<T> algorithm(Algorithm alg)
Sets the intended JOSE algorithm (alg
) for the JWK.- Parameters:
alg
- The intended JOSE algorithm,null
if not specified.- Returns:
- This generator.
-
keyID
public JWKGenerator<T> keyID(String kid)
Sets the ID (kid
) of the JWK. The key ID can be used to match a specific key. This can be used, for instance, to choose a key within aJWKSet
during key rollover. The key ID may also correspond to a JWS/JWEkid
header parameter value.- Parameters:
kid
- The key ID,null
if not specified.- Returns:
- This generator.
-
keyIDFromThumbprint
public JWKGenerator<T> keyIDFromThumbprint(boolean x5tKid)
Sets the ID (kid
) of the JWK to its SHA-256 JWK thumbprint (RFC 7638). The key ID can be used to match a specific key. This can be used, for instance, to choose a key within aJWKSet
during key rollover. The key ID may also correspond to a JWS/JWEkid
header parameter value.- Parameters:
x5tKid
- Iftrue
sets the ID of the JWK to the SHA-256 JWK thumbprint.- Returns:
- This generator.
-
keyStore
public JWKGenerator<T> keyStore(KeyStore keyStore)
Sets the underlying key store.- Parameters:
keyStore
- Reference to the underlying key store,null
if none.- Returns:
- This generator.
-
generate
public abstract T generate() throws JOSEException
Generates the JWK according to the set parameters.- Returns:
- The generated JWK.
- Throws:
JOSEException
- If the key generation failed.
-
-