Package org.forgerock.json.jose.jwk
Class OkpJWK
- java.lang.Object
 - 
- org.forgerock.json.jose.jwk.JWK
 - 
- org.forgerock.json.jose.jwk.OkpJWK
 
 
 
- 
- All Implemented Interfaces:
 EllipticCurveJwk
public class OkpJWK extends JWK implements EllipticCurveJwk
An Octet Key-Pair (OKP) JWK as defined in RFC 8037. 
- 
- 
Nested Class Summary
Nested Classes Modifier and Type Class Description static classOkpJWK.BuilderBuilder object for Octet Key-Pair (OKP) JWKs. 
- 
Field Summary
- 
Fields inherited from class org.forgerock.json.jose.jwk.JWK
JSON_KEY_ALG, JSON_KEY_KID, JSON_KEY_KTY, JSON_KEY_OPERATIONS, JSON_KEY_USE, JSON_KEY_X5C, JSON_KEY_X5T, JSON_KEY_X5T_S256, JSON_KEY_X5U 
 - 
 
- 
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static OkpJWK.Builderbuilder()Creates a new builder object for an OKP key.static OkpJWKgenerateKeyPair(SupportedEllipticCurve curve)Generates a fresh OKP JWK with both public and private claims on the given curve.StringgetD()Returns the private key d value.SupportedEllipticCurvegetEllipticCurve()The supported elliptic curve that this key is on.protected Optional<JWK.Builder<?>>getPublicJwkBuilder()Return a builder with all the values set for representing the public components of the JWK.StringgetX()Returns the x-coordinate that forms the public key.booleanisPrivate()Indicates if any private key attributes are present in the JWK.booleanisPublicKeyValid()Determines whether the public key is valid.static OkpJWKparse(JsonValue json)Parses a JWK from a JsonValue json object.ECPublicKeytoECPublicKey()Converts the public claims in the JWK into a public key object.JsonValuetoJsonValue()Returns a json representation of the JWK.KeyPairtoKeyPair()Converts the JWK to a key-pair.PrivateKeytoPrivateKey()Converts the JWK to a private key object.PublicKeytoPublicKey()Converts the public claims in the JWK into a public key.StringtoString()KeyPairtoXECKeyPair()Returns a KeyPair object containing the XECPrivateKey and XECPublicKey for this JWK.PublicKeytoXECPublicKey()Converts the JWK to a Java 11 XECPublicKey instance.- 
Methods inherited from class org.forgerock.json.jose.jwk.JWK
getAlgorithm, getAlgorithm, getJwaAlgorithm, getJwkThumbprint, getKeyId, getKeyOperations, getKeyType, getUse, getX509Chain, getX509Thumbnail, getX509Thumbprint, getX509ThumbprintS256, getX509URL, loadJWKFromJson, parse, putField, toCryptoKey, toJsonString, toJsonValue, toPublicJwk, toSecretBuilder 
 - 
 
 - 
 
- 
- 
Method Detail
- 
builder
public static OkpJWK.Builder builder()
Creates a new builder object for an OKP key.- Returns:
 - the builder object.
 
 
- 
getEllipticCurve
public SupportedEllipticCurve getEllipticCurve()
The supported elliptic curve that this key is on.- Specified by:
 getEllipticCurvein interfaceEllipticCurveJwk- Returns:
 - the curve.
 
 
- 
getX
public String getX()
Returns the x-coordinate that forms the public key.- Returns:
 - the public key x-coordinate.
 
 
- 
getD
public String getD()
Returns the private key d value.- Returns:
 - the private key d value.
 
 
- 
parse
public static OkpJWK parse(JsonValue json)
Parses a JWK from a JsonValue json object.- Parameters:
 json- JsonValue json object- Returns:
 - a OctJWK object
 
 
- 
toJsonValue
public JsonValue toJsonValue()
Description copied from class:JWKReturns a json representation of the JWK.- Overrides:
 toJsonValuein classJWK- Returns:
 - A JSON representation.
 
 
- 
isPrivate
public boolean isPrivate()
Description copied from class:JWKIndicates if any private key attributes are present in the JWK. 
- 
getPublicJwkBuilder
protected Optional<JWK.Builder<?>> getPublicJwkBuilder()
Description copied from class:JWKReturn a builder with all the values set for representing the public components of the JWK. Common JWK attributes will be added inJWK.toPublicJwk().- Specified by:
 getPublicJwkBuilderin classJWK- Returns:
 - The builder.
 
 
- 
toPrivateKey
public PrivateKey toPrivateKey()
Converts the JWK to a private key object.- Returns:
 - the equivalent private key object.
 
 
- 
toXECPublicKey
public PublicKey toXECPublicKey()
Converts the JWK to a Java 11 XECPublicKey instance. If using Java prior to Java 11 then this returns null.- Returns:
 - the XECPublicKey corresponding to this JWK.
 
 
- 
toXECKeyPair
public KeyPair toXECKeyPair()
Returns a KeyPair object containing the XECPrivateKey and XECPublicKey for this JWK. Only supported in Java 11+. On earlier Java versions it will return a pair of null keys.- Returns:
 - the XEC key pair.
 
 
- 
toECPublicKey
public ECPublicKey toECPublicKey()
Description copied from interface:EllipticCurveJwkConverts the public claims in the JWK into a public key object. This method is only compatible with EcJWKs and will throw an exception if called on an OkpJWK.- Specified by:
 toECPublicKeyin interfaceEllipticCurveJwk- Returns:
 - the public key.
 
 
- 
toPublicKey
public PublicKey toPublicKey()
Description copied from interface:EllipticCurveJwkConverts the public claims in the JWK into a public key. Note that the public key returned may not be an ECPublicKey. For instance, on Java 11 an OkpJWK may return a XECPrivateKey.- Specified by:
 toPublicKeyin interfaceEllipticCurveJwk- Returns:
 - the public key.
 
 
- 
isPublicKeyValid
public boolean isPublicKeyValid()
Determines whether the public key is valid. Currently for Curve25519, we blacklist all the points of small-order given by https://cr.yp.to/ecdh.html#validate.- Specified by:
 isPublicKeyValidin interfaceEllipticCurveJwk- Returns:
 - true if the public key is a valid point on the curve.
 
 
- 
toKeyPair
public KeyPair toKeyPair()
Converts the JWK to a key-pair.- Specified by:
 toKeyPairin interfaceEllipticCurveJwk- Returns:
 - the key-pair equivalent to this JWK.
 
 
- 
generateKeyPair
public static OkpJWK generateKeyPair(SupportedEllipticCurve curve)
Generates a fresh OKP JWK with both public and private claims on the given curve.- Parameters:
 curve- The curve to generate the key pair on.- Returns:
 - the freshly generated JWK.
 
 
 - 
 
 -