public abstract class JWK extends java.lang.Object implements net.minidev.json.JSONAware
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 and Description |
|---|
JWK(KeyType kty,
Use use,
Algorithm alg,
java.lang.String kid)
Creates a new JSON Web Key (JWK).
|
| Modifier and Type | Method and Description |
|---|---|
Algorithm |
getAlgorithm()
Gets the intended JOSE algorithm (
alg) for this JWK. |
java.lang.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(java.lang.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 java.lang.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.
|
java.lang.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.
|
java.lang.String |
toString() |
public JWK(KeyType kty, Use use, Algorithm alg, java.lang.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.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 java.lang.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 java.lang.String toJSONString()
toJSONString in interface net.minidev.json.JSONAwarepublic java.lang.String toString()
toString in class java.lang.ObjecttoJSONString()public static JWK parse(java.lang.String s) throws java.text.ParseException
ECKey, an RSAKey, or a
OctetSequenceKey.s - The JSON object string to parse. Must not be null.java.text.ParseException - If the string couldn't be parsed to a
supported JWK.public static JWK parse(net.minidev.json.JSONObject jsonObject) throws java.text.ParseException
ECKey, an RSAKey, or a
OctetSequenceKey.jsonObject - The JSON object to parse. Must not be
null.java.text.ParseException - If the JSON object couldn't be parsed to a
supported JWK.protected static Use parseKeyUse(net.minidev.json.JSONObject jsonObject) throws java.text.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.java.text.ParseException - If the key use parameter couldn't be parsed.protected static Algorithm parseAlgorithm(net.minidev.json.JSONObject jsonObject) throws java.text.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.java.text.ParseException - If the algorithm parameter couldn't be
parsed.protected static java.lang.String parseKeyID(net.minidev.json.JSONObject jsonObject) throws java.text.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.java.text.ParseException - If the key ID parameter couldn't be parsed.Copyright © 2013 NimbusDS. All Rights Reserved.