com.nimbusds.jose
Class ECKey

java.lang.Object
  extended by com.nimbusds.jose.JWK
      extended by com.nimbusds.jose.ECKey
All Implemented Interfaces:
net.minidev.json.JSONAware

@Immutable
public final class ECKey
extends JWK

Public Elliptic Curve JSON Web Key (JWK). This class is immutable.

Example JSON:

 {
   "kty" : "EC",
   "crv" : "P-256",
   "x"   : "MKBCTNIcKUSDii11ySs3526iDZ8AiTo7Tu6KPAqv7D4",
   "y"   : "4Etl6SRW2YiLUrN5vfvVHuhp7x8PxltmWWlbbM4IFyM",
   "use" : "enc",
   "kid" : "1"
 }
 

See http://en.wikipedia.org/wiki/Elliptic_curve_cryptography

Version:
$version$ (2013-01-15)
Author:
Vladimir Dzhuvinov

Nested Class Summary
static class ECKey.Curve
          Cryptographic curve.
 
Constructor Summary
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.
 
Method Summary
 ECKey.Curve getCurve()
          Gets the cryptographic curve.
 Base64URL getX()
          Gets the 'x' coordinate for the elliptic curve point.
 Base64URL getY()
          Gets the 'y' coordinate for the elliptic curve point.
static ECKey parse(net.minidev.json.JSONObject jsonObject)
          Parses an Elliptic Curve JWK from the specified JSON object representation.
 net.minidev.json.JSONObject toJSONObject()
          Returns a JSON object representation of this JWK.
 
Methods inherited from class com.nimbusds.jose.JWK
getAlgorithm, getKeyID, getKeyType, getKeyUse, parse, parseAlgorithm, parseKeyID, parseKeyUse, toJSONString, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ECKey

public 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.

Parameters:
crv - The cryptographic curve. Must not be null.
x - The '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 '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.
Method Detail

getCurve

public ECKey.Curve getCurve()
Gets the cryptographic curve.

Returns:
The cryptographic curve.

getX

public Base64URL getX()
Gets the 'x' coordinate for the elliptic curve point. It is represented as the Base64URL encoding of the coordinate's big endian representation.

Returns:
The 'x' coordinate.

getY

public Base64URL getY()
Gets the 'y' coordinate for the elliptic curve point. It is represented as the Base64URL encoding of the coordinate's big endian representation.

Returns:
The 'y' coordinate.

toJSONObject

public net.minidev.json.JSONObject toJSONObject()
Description copied from class: JWK
Returns a JSON object representation of this JWK. This method is intended to be called from extending classes.

Example:

 {
   "kty" : "RSA",
   "use" : "sig",
   "kid" : "fd28e025-8d24-48bc-a51a-e2ffc8bc274b"
 }
 

Overrides:
toJSONObject in class JWK
Returns:
The JSON object representation.

parse

public static ECKey parse(net.minidev.json.JSONObject jsonObject)
                   throws java.text.ParseException
Parses an Elliptic Curve JWK from the specified JSON object representation.

Parameters:
jsonObject - The JSON object to parse. Must not be null.
Returns:
The Elliptic Curve JWK.
Throws:
java.text.ParseException - If the JSON object couldn't be parsed to a valid Elliptic Curve JWK.


Copyright © 2013 NimbusDS. All Rights Reserved.