|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.nimbusds.jose.jwk.JWK
public abstract class JWK
The base abstract class for JSON Web Keys (JWKs). It serialises to a JSON object.
The following JSON object members are common to all JWK types:
Example JWK (of the Elliptic Curve type):
{ "kty" : "EC", "crv" : "P-256", "x" : "MKBCTNIcKUSDii11ySs3526iDZ8AiTo7Tu6KPAqv7D4", "y" : "4Etl6SRW2YiLUrN5vfvVHuhp7x8PxltmWWlbbM4IFyM", "use" : "enc", "kid" : "1" }
Constructor Summary | |
---|---|
JWK(KeyType kty,
Use use,
Algorithm alg,
String kid)
Creates a new JSON Web Key (JWK). |
Method Summary | |
---|---|
Algorithm |
getAlgorithm()
Gets the intended JOSE algorithm ( alg ) for this JWK. |
String |
getKeyID()
Gets the ID ( kid ) of this JWK. |
KeyType |
getKeyType()
Gets the type ( kty ) of this JWK. |
Use |
getKeyUse()
Gets the use ( use ) of this JWK. |
abstract boolean |
isPrivate()
Returns true if this JWK contains private or sensitive
(non-public) parameters. |
static JWK |
parse(net.minidev.json.JSONObject jsonObject)
Parses a JWK from the specified JSON object representation. |
static JWK |
parse(String s)
Parses a JWK from the specified JSON object string representation. |
protected static Algorithm |
parseAlgorithm(net.minidev.json.JSONObject jsonObject)
Parses an algorithm ( alg ) parameter from the specified JSON
object representation of a JWK. |
protected static String |
parseKeyID(net.minidev.json.JSONObject jsonObject)
Parses a key ID ( kid ) parameter from the specified JSON
object representation of a JWK. |
protected static Use |
parseKeyUse(net.minidev.json.JSONObject jsonObject)
Parses a key use ( use ) parameter from the specified JSON
object representation of a JWK. |
net.minidev.json.JSONObject |
toJSONObject()
Returns a JSON object representation of this JWK. |
String |
toJSONString()
Returns the JSON object string representation of this JWK. |
abstract JWK |
toPublicJWK()
Creates a copy of this JWK with all private or sensitive parameters removed. |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public JWK(KeyType kty, Use use, Algorithm alg, String kid)
kty
- The key type. Must not be null
.use
- The key use, null
if not specified or if the key
is intended for signing as well as encryption.alg
- The intended JOSE algorithm for the key, null
if
not specified.kid
- The key ID, null
if not specified.Method Detail |
---|
public KeyType getKeyType()
kty
) of this JWK.
public Use getKeyUse()
use
) of this JWK.
null
if not specified or if the key is
intended for signing as well as encryption.public Algorithm getAlgorithm()
alg
) for this JWK.
null
if not specified.public String getKeyID()
kid
) of this JWK. The key ID can be used to
match a specific key. This can be used, for instance, to choose a
key within a JWKSet
during key rollover. The key ID may also
correspond to a JWS/JWE kid
header parameter value.
null
if not specified.public abstract boolean isPrivate()
true
if this JWK contains private or sensitive
(non-public) parameters.
true
if this JWK contains private parameters, else
false
.public abstract JWK toPublicJWK()
null
if none can be
created.public net.minidev.json.JSONObject toJSONObject()
Example:
{ "kty" : "RSA", "use" : "sig", "kid" : "fd28e025-8d24-48bc-a51a-e2ffc8bc274b" }
public String toJSONString()
toJSONString
in interface net.minidev.json.JSONAware
public String toString()
toString
in class Object
toJSONString()
public static JWK parse(String s) throws ParseException
ECKey
, an RSAKey
, or a
OctetSequenceKey
.
s
- The JSON object string to parse. Must not be null
.
ParseException
- If the string couldn't be parsed to a
supported JWK.public static JWK parse(net.minidev.json.JSONObject jsonObject) throws ParseException
ECKey
, an RSAKey
, or a
OctetSequenceKey
.
jsonObject
- The JSON object to parse. Must not be
null
.
ParseException
- If the JSON object couldn't be parsed to a
supported JWK.protected static Use parseKeyUse(net.minidev.json.JSONObject jsonObject) throws ParseException
use
) parameter from the specified JSON
object representation of a JWK.
jsonObject
- The JSON object to parse. Must not be
null
.
null
if not specified.
ParseException
- If the key use parameter couldn't be parsed.protected static Algorithm parseAlgorithm(net.minidev.json.JSONObject jsonObject) throws ParseException
alg
) parameter from the specified JSON
object representation of a JWK.
Note that the algorithm requirement level is not inferred.
jsonObject
- The JSON object to parse. Must not be
null
.
null
if not specified.
ParseException
- If the algorithm parameter couldn't be
parsed.protected static String parseKeyID(net.minidev.json.JSONObject jsonObject) throws ParseException
kid
) parameter from the specified JSON
object representation of a JWK.
jsonObject
- The JSON object to parse. Must not be
null
.
null
if not specified.
ParseException
- If the key ID parameter couldn't be parsed.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |