Package org.forgerock.json.jose.jwk
Class EcJWK
java.lang.Object
org.forgerock.json.jose.jwt.JWObject
org.forgerock.json.jose.jwk.JWK
org.forgerock.json.jose.jwk.EcJWK
This class implements an Elliptical Curve Json Web Key storage and manipulation class.
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionEcJWK(ECPublicKey publicKey, ECPrivateKey privateKey, KeyUse use, String kid) Creates a public and private EcJWK.EcJWK(ECPublicKey publicKey, KeyUse use, String kid) Creates a public EcJWK.EcJWK(KeyUse use, String alg, String kid, String x, String y, String d, String curve, String x5u, String x5t, List<String> x5c) Creates a public and private EcJWK.EcJWK(KeyUse use, String alg, String kid, String x, String y, String curve, String x5u, String x5t, List<String> x5c) Creates a public EcJWK. -
Method Summary
Modifier and TypeMethodDescriptionstatic BigIntegerdecodeCoordinate(String encodedCoordinate) Decode the unsigned big-endian base64 url encoding of an elliptical curve point.static StringencodeCoordinate(int fieldSize, BigInteger coordinate) Base64url encode the unsigned big-endian representation of an elliptical curve point.getCurve()Gets the known curve to use.getD()Gets the unsigned big-endian base64 url encoding of the d value for the elliptical curve private key.getX()Gets the unsigned big-endian base64 url encoding of the elliptical curve point x coordinate.getY()Gets the unsigned big-endian base64 url encoding of the elliptical curve point y coordinate.static EcJWKParses a JWK from a string json object.static EcJWKParses a JWK from a JsonValue json object.Converts the JWK to a ECPrivateKey.Converts the JWK to a ECPublicKey.Prints the JWK as a String json object.Converts the JWK to a KeyPair.Methods inherited from class org.forgerock.json.jose.jwk.JWK
getAlgorithm, getKeyId, getKeyType, getUse, getX509Chain, getX509Thumbnail, getX509URL, toJsonValueMethods inherited from class org.forgerock.json.jose.jwt.JWObject
checkListValuesAreOfType, checkValueIsOfType, get, isDefined, isValueOfType, keys, put, toJsonValue, toString
-
Constructor Details
-
EcJWK
Creates a public EcJWK.- Parameters:
publicKey- The public key for the JWKuse- The value of the use JWK parameterkid- The key id of the JWK
-
EcJWK
Creates a public and private EcJWK.- Parameters:
publicKey- The public key for the JWKprivateKey- The private key for the JWKuse- The value of the use JWK parameterkid- The key id of the JWK
-
EcJWK
public EcJWK(KeyUse use, String alg, String kid, String x, String y, String curve, String x5u, String x5t, List<String> x5c) Creates a public EcJWK.- Parameters:
use- The value of the use JWK parameteralg- The value of the alg JWK parameterkid- The key id of the JWKx- The unsigned big-endian base64 url encoding of the elliptical curve point x coordinatey- The unsigned big-endian base64 url encoding of the elliptical curve point y coordinatecurve- The known curve to use. For example "NIST P-256".x5u- the x509 url for the keyx5t- the x509 thumbnail for the keyx5c- the x509 chain as a list of Base64 encoded strings
-
EcJWK
public EcJWK(KeyUse use, String alg, String kid, String x, String y, String d, String curve, String x5u, String x5t, List<String> x5c) Creates a public and private EcJWK.- Parameters:
use- The value of the use JWK parameteralg- The value of the alg JWK parameterkid- The key id of the JWKx- The unsigned big-endian base64 url encoding of the elliptical curve point x coordinatey- The unsigned big-endian base64 url encoding of the elliptical curve point y coordinated- The unsigned big-endian base64 url encoding of the d value for the elliptical curve private keycurve- The known curve to use. For example "NIST P-256".x5u- the x509 url for the keyx5t- the x509 thumbnail for the keyx5c- the x509 chain as a list of Base64 encoded strings
-
-
Method Details
-
getX
Gets the unsigned big-endian base64 url encoding of the elliptical curve point x coordinate.- Returns:
- unsigned big-endian base64 url encoding of the elliptical curve point x coordinate
-
getY
Gets the unsigned big-endian base64 url encoding of the elliptical curve point y coordinate.- Returns:
- the unsigned big-endian base64 url encoding of the elliptical curve point y coordinate
-
getD
Gets the unsigned big-endian base64 url encoding of the d value for the elliptical curve private key.- Returns:
- the unsigned big-endian base64 url encoding of the d value for the elliptical curve private key
-
getCurve
Gets the known curve to use. For example "NIST P-256".- Returns:
- the known curve of the JWK
-
parse
Parses a JWK from a string json object.- Parameters:
json- string json object- Returns:
- a EcJWK object
-
parse
Parses a JWK from a JsonValue json object.- Parameters:
json- JsonValue json object- Returns:
- a EcJWK object
-
toJsonString
Prints the JWK as a String json object.- Overrides:
toJsonStringin classJWK- Returns:
- a json string object
-
toECPublicKey
Converts the JWK to a ECPublicKey.- Returns:
- an ECPublicKey
-
toECPrivateKey
Converts the JWK to a ECPrivateKey.- Returns:
- an ECPrivateKey
-
toKeyPair
Converts the JWK to a KeyPair.- Returns:
- an KeyPair
-
decodeCoordinate
Decode the unsigned big-endian base64 url encoding of an elliptical curve point.- Parameters:
encodedCoordinate- the unsigned big-endian base64 url encoding of a the elliptical curve point- Returns:
- the elliptical curve point
-
encodeCoordinate
Base64url encode the unsigned big-endian representation of an elliptical curve point.- Parameters:
fieldSize- the EC field size in bits.coordinate- the elliptical curve point- Returns:
- the unsigned big-endian base64 url encoding of the elliptical curve point
-