@Immutable public final class ECKey extends JWK
Elliptic Curve
JSON Web Key (JWK).
This class is immutable.
Example JSON object representation of a public EC JWK:
{ "kty" : "EC", "crv" : "P-256", "x" : "MKBCTNIcKUSDii11ySs3526iDZ8AiTo7Tu6KPAqv7D4", "y" : "4Etl6SRW2YiLUrN5vfvVHuhp7x8PxltmWWlbbM4IFyM", "use" : "enc", "kid" : "1" }
Example JSON object representation of a public and private EC JWK:
{ "kty" : "EC", "crv" : "P-256", "x" : "MKBCTNIcKUSDii11ySs3526iDZ8AiTo7Tu6KPAqv7D4", "y" : "4Etl6SRW2YiLUrN5vfvVHuhp7x8PxltmWWlbbM4IFyM", "d" : "870MB6gfuTJ4HtUnUvYMyJpr5eUZNP4Bk43bVdj3eAE", "use" : "enc", "kid" : "1" }
See http://en.wikipedia.org/wiki/Elliptic_curve_cryptography
Modifier and Type | Class and Description |
---|---|
static class |
ECKey.Curve
Cryptographic curve.
|
Constructor and Description |
---|
ECKey(ECKey.Curve crv,
Base64URL x,
Base64URL y,
Base64URL d,
Use use,
Algorithm alg,
java.lang.String kid)
Creates a new public / private Elliptic Curve JSON Web Key (JWK)
with the specified parameters.
|
ECKey(ECKey.Curve crv,
Base64URL x,
Base64URL y,
Use use,
Algorithm alg,
java.lang.String kid)
Creates a new public Elliptic Curve JSON Web Key (JWK) with the
specified parameters.
|
Modifier and Type | Method and Description |
---|---|
ECKey.Curve |
getCurve()
Gets the cryptographic curve.
|
Base64URL |
getD()
Gets the private 'd' coordinate for the elliptic curve point.
|
Base64URL |
getX()
Gets the public 'x' coordinate for the elliptic curve point.
|
Base64URL |
getY()
Gets the public 'y' coordinate for the elliptic curve point.
|
boolean |
isPrivate()
Returns
true if this JWK contains private or sensitive
(non-public) parameters. |
static ECKey |
parse(net.minidev.json.JSONObject jsonObject)
Parses a public / private Elliptic Curve JWK from the specified JSON
object representation.
|
static ECKey |
parse(java.lang.String s)
Parses a public / private Elliptic Curve JWK from the specified JSON
object string representation.
|
java.security.interfaces.ECPrivateKey |
toECPrivateKey()
Returns a standard
java.security.interfaces.ECPrivateKey
representation of this Elliptic Curve JWK. |
java.security.interfaces.ECPublicKey |
toECPublicKey()
Returns a standard
java.security.interfaces.ECPublicKey
representation of this Elliptic Curve JWK. |
net.minidev.json.JSONObject |
toJSONObject()
Returns a JSON object representation of this JWK.
|
java.security.KeyPair |
toKeyPair()
Returns a standard
java.security.KeyPair representation of
this Elliptic Curve JWK. |
ECKey |
toPublicJWK()
Returns a copy of this Elliptic Curve JWK with any private values
removed.
|
getAlgorithm, getKeyID, getKeyType, getKeyUse, parseAlgorithm, parseKeyID, parseKeyUse, toJSONString, toString
public ECKey(ECKey.Curve crv, Base64URL x, Base64URL y, Use use, Algorithm alg, java.lang.String kid)
crv
- The cryptographic curve. Must not be null
.x
- The public 'x' coordinate for the elliptic curve point.
It is represented as the Base64URL encoding of the
coordinate's big endian representation. Must not be
null
.y
- The public 'y' coordinate for the elliptic curve point.
It is represented as the Base64URL encoding of the
coordinate's big endian representation. Must not be
null
.use
- The key use, null
if not specified.alg
- The intended JOSE algorithm for the key, null
if
not specified.kid
- The key ID, null
if not specified.public ECKey(ECKey.Curve crv, Base64URL x, Base64URL y, Base64URL d, Use use, Algorithm alg, java.lang.String kid)
crv
- The cryptographic curve. Must not be null
.x
- The public 'x' coordinate for the elliptic curve point.
It is represented as the Base64URL encoding of the
coordinate's big endian representation. Must not be
null
.y
- The public 'y' coordinate for the elliptic curve point.
It is represented as the Base64URL encoding of the
coordinate's big endian representation. Must not be
null
.d
- The private 'd' coordinate for the elliptic curve point.
It is represented as the Base64URL encoding of the
coordinate's big endian representation. May be
null
if this is a public key.use
- The key use, null
if not specified.alg
- The intended JOSE algorithm for the key, null
if
not specified.kid
- The key ID, null
if not specified.public ECKey.Curve getCurve()
public Base64URL getX()
public Base64URL getY()
public Base64URL getD()
null
if not specified (for a
public key).public java.security.interfaces.ECPublicKey toECPublicKey()
java.security.interfaces.ECPublicKey
representation of this Elliptic Curve JWK.java.lang.UnsupportedOperationException
- Not yet implemented.public java.security.interfaces.ECPrivateKey toECPrivateKey()
java.security.interfaces.ECPrivateKey
representation of this Elliptic Curve JWK.null
if not
specified by this JWK.java.lang.UnsupportedOperationException
- Not yet implemented.public java.security.KeyPair toKeyPair()
java.security.KeyPair
representation of
this Elliptic Curve JWK.null
if not specified.public boolean isPrivate()
JWK
true
if this JWK contains private or sensitive
(non-public) parameters.public ECKey toPublicJWK()
toPublicJWK
in class JWK
public net.minidev.json.JSONObject toJSONObject()
JWK
Example:
{ "kty" : "RSA", "use" : "sig", "kid" : "fd28e025-8d24-48bc-a51a-e2ffc8bc274b" }
toJSONObject
in class JWK
public static ECKey parse(java.lang.String s) throws java.text.ParseException
s
- The JSON object string to parse. Must not be null
.java.text.ParseException
- If the string couldn't be parsed to an
Elliptic Curve JWK.public static ECKey parse(net.minidev.json.JSONObject jsonObject) throws java.text.ParseException
jsonObject
- The JSON object to parse. Must not be
null
.java.text.ParseException
- If the JSON object couldn't be parsed to an
Elliptic Curve JWK.Copyright © 2013 NimbusDS. All Rights Reserved.