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
Abstract JWK generator.
- Version:
- 2023-01-29
- Author:
- Vladimir Dzhuvinov, Justin Cranford
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AlgorithmThe intended JOSE algorithm for the key, optional.protected DateThe key expiration time, optional.protected DateThe key issued-at time, optional.protected KeyStoreReference to the underlying key store,nullif none.protected StringThe key ID, optional.protected DateThe key not-before time, optional.protected Set<KeyOperation>The key operations, optional.protected ProviderThe JCA provider,nullto use the default one.protected SecureRandomThe secure random generator to use,nullto use the default one.protected KeyUseThe key use, optional.protected booleanIftruesets the ID of the JWK to the SHA-256 thumbprint of the JWK. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionSets the intended JOSE algorithm (alg) for the JWK.expirationTime(Date exp) Sets the expiration time (exp) of the JWK.abstract Tgenerate()Generates the JWK according to the set parameters.Sets the issued-at time (iat) of the JWK.Sets the ID (kid) of the JWK.keyIDFromThumbprint(boolean x5tKid) Sets the ID (kid) of the JWK to its SHA-256 JWK thumbprint (RFC 7638).keyOperations(Set<KeyOperation> ops) Sets the operations (key_ops) of the JWK.Sets the underlying key store.Sets the use (use) of the JWK.notBeforeTime(Date nbf) Sets the not-before time (nbf) of the JWK.Sets the JCA provider for the key generation.secureRandom(SecureRandom secureRandom) Sets the secure random generator to use.
-
Field Details
-
use
The key use, optional. -
ops
The key operations, optional. -
alg
The intended JOSE algorithm for the key, optional. -
kid
The key ID, optional. -
x5tKid
Iftruesets the ID of the JWK to the SHA-256 thumbprint of the JWK. -
exp
The key expiration time, optional. -
nbf
The key not-before time, optional. -
iat
The key issued-at time, optional. -
keyStore
Reference to the underlying key store,nullif none. -
provider
The JCA provider,nullto use the default one. -
secureRandom
The secure random generator to use,nullto use the default one.
-
-
Constructor Details
-
JWKGenerator
public JWKGenerator()
-
-
Method Details
-
keyUse
Sets the use (use) of the JWK.- Parameters:
use- The key use,nullif not specified or if the key is intended for signing as well as encryption.- Returns:
- This generator.
-
keyOperations
Sets the operations (key_ops) of the JWK.- Parameters:
ops- The key operations,nullif not specified.- Returns:
- This generator.
-
algorithm
Sets the intended JOSE algorithm (alg) for the JWK.- Parameters:
alg- The intended JOSE algorithm,nullif not specified.- Returns:
- This generator.
-
keyID
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 aJWKSetduring key rollover. The key ID may also correspond to a JWS/JWEkidheader parameter value.- Parameters:
kid- The key ID,nullif not specified.- Returns:
- This generator.
-
keyIDFromThumbprint
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 aJWKSetduring key rollover. The key ID may also correspond to a JWS/JWEkidheader parameter value.- Parameters:
x5tKid- Iftruesets the ID of the JWK to the SHA-256 JWK thumbprint.- Returns:
- This generator.
-
expirationTime
Sets the expiration time (exp) of the JWK.- Parameters:
exp- The expiration time,nullif not specified.- Returns:
- This generator.
-
notBeforeTime
Sets the not-before time (nbf) of the JWK.- Parameters:
nbf- The not-before time,nullif not specified.- Returns:
- This generator.
-
issueTime
Sets the issued-at time (iat) of the JWK.- Parameters:
iat- The issued-at time,nullif not specified.- Returns:
- This generator.
-
keyStore
Sets the underlying key store. Overrides theJCA provideris set. Note, some JWK generators may not use the JCA key store API.- Parameters:
keyStore- Reference to the underlying key store,nullif none.- Returns:
- This generator.
-
provider
Sets the JCA provider for the key generation. Note, some JWK generators may not use the JCA provider API.- Parameters:
provider- The JCA provider,nullto use the default one.- Returns:
- This generator.
-
secureRandom
Sets the secure random generator to use. Note, some JWK generators may not use the JCA secure random API.- Parameters:
secureRandom- The secure random generator to use,nullto use the default one.- Returns:
- This generator.
-
generate
Generates the JWK according to the set parameters.- Returns:
- The generated JWK.
- Throws:
JOSEException- If the key generation failed.
-