Package com.nimbusds.jose.jwk
Class OctetKeyPair.Builder
java.lang.Object
com.nimbusds.jose.jwk.OctetKeyPair.Builder
- Enclosing class:
- OctetKeyPair
Builder for constructing Octet Key Pair JWKs.
Example usage:
OctetKeyPair key = new OctetKeyPair.Builder(Curve.Ed25519, x)
.d(d)
.algorithm(JWSAlgorithm.EdDSA)
.keyID("1")
.build();
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new Octet Key Pair JWK builder.Builder(OctetKeyPair okpJWK) Creates a new Octet Key Pair JWK builder. -
Method Summary
Modifier and TypeMethodDescriptionSets the intended JOSE algorithm (alg) for the JWK.build()Builds a new Octet Key Pair JWK.Sets the private 'd' parameter.expirationTime(Date exp) Sets the expiration time (exp) of the JWK.Sets the issued-at time (iat) of the JWK.Sets the ID (kid) of the JWK.Sets the ID (kid) of the JWK to its SHA-256 JWK thumbprint (RFC 7638).keyIDFromThumbprint(String hashAlg) Sets the ID (kid) of the JWK to its JWK thumbprint (RFC 7638).keyOperations(Set<KeyOperation> ops) Sets the operations (key_ops) of the JWK.keyRevocation(KeyRevocation revocation) Sets the revocation (revoked) 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.x509CertChain(List<Base64> x5c) Sets the X.509 certificate chain (x5c) of the JWK.x509CertSHA256Thumbprint(Base64URL x5t256) Sets the X.509 certificate SHA-256 thumbprint (x5t#S256) of the JWK.Deprecated.x509CertURL(URI x5u) Sets the X.509 certificate URL (x5u) of the JWK.
-
Constructor Details
-
Builder
Creates a new Octet Key Pair JWK builder.- Parameters:
crv- The cryptographic curve. Must not benull.x- The public 'x' parameter. Must not benull.
-
Builder
Creates a new Octet Key Pair JWK builder.- Parameters:
okpJWK- The Octet Key Pair to start with. Must not benull.
-
-
Method Details
-
d
Sets the private 'd' parameter.- Parameters:
d- The private 'd' parameter,nullif not specified (for a public key).- Returns:
- This builder.
-
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 builder.
-
keyOperations
Sets the operations (key_ops) of the JWK.- Parameters:
ops- The key operations,nullif not specified.- Returns:
- This builder.
-
algorithm
Sets the intended JOSE algorithm (alg) for the JWK.- Parameters:
alg- The intended JOSE algorithm,nullif not specified.- Returns:
- This builder.
-
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 builder.
-
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.- Returns:
- This builder.
- Throws:
JOSEException- If the SHA-256 hash algorithm is not supported.
-
keyIDFromThumbprint
Sets the ID (kid) of the JWK to its 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:
hashAlg- The hash algorithm for the JWK thumbprint computation. Must not benull.- Returns:
- This builder.
- Throws:
JOSEException- If the hash algorithm is not supported.
-
x509CertURL
Sets the X.509 certificate URL (x5u) of the JWK.- Parameters:
x5u- The X.509 certificate URL,nullif not specified.- Returns:
- This builder.
-
x509CertThumbprint
Deprecated.Sets the X.509 certificate SHA-1 thumbprint (x5t) of the JWK.- Parameters:
x5t- The X.509 certificate SHA-1 thumbprint,nullif not specified.- Returns:
- This builder.
-
x509CertSHA256Thumbprint
Sets the X.509 certificate SHA-256 thumbprint (x5t#S256) of the JWK.- Parameters:
x5t256- The X.509 certificate SHA-256 thumbprint,nullif not specified.- Returns:
- This builder.
-
x509CertChain
Sets the X.509 certificate chain (x5c) of the JWK.- Parameters:
x5c- The X.509 certificate chain as a unmodifiable list,nullif not specified.- Returns:
- This builder.
-
expirationTime
Sets the expiration time (exp) of the JWK.- Parameters:
exp- The expiration time,nullif not specified.- Returns:
- This builder.
-
notBeforeTime
Sets the not-before time (nbf) of the JWK.- Parameters:
nbf- The not-before time,nullif not specified.- Returns:
- This builder.
-
issueTime
Sets the issued-at time (iat) of the JWK.- Parameters:
iat- The issued-at time,nullif not specified.- Returns:
- This builder.
-
keyRevocation
Sets the revocation (revoked) of the JWK.- Parameters:
revocation- The key revocation,nullif not specified.- Returns:
- This builder.
-
keyStore
Sets the underlying key store.- Parameters:
keyStore- Reference to the underlying key store,nullif none.- Returns:
- This builder.
-
build
Builds a new Octet Key Pair JWK.- Returns:
- The Octet Key Pair JWK.
- Throws:
IllegalStateException- If the JWK parameters were inconsistently specified.
-