public class JsonWebKey extends Object
Constructor and Description |
---|
JsonWebKey() |
Modifier and Type | Method and Description |
---|---|
void |
clearMemory()
Clear key materials.
|
boolean |
equals(JsonWebKey jwk)
Indicates whether some other
JsonWebKey is "equal to" this one. |
boolean |
equals(Object obj) |
static JsonWebKey |
fromAes(SecretKey secretKey)
Converts AES key to JSON web key.
|
static JsonWebKey |
fromAes(SecretKey secretKey,
List<KeyOperation> keyOperations)
Converts AES key to JSON web key.
|
static JsonWebKey |
fromEc(KeyPair keyPair,
Provider provider)
Converts EC key pair to JSON web key.
|
static JsonWebKey |
fromEc(KeyPair keyPair,
Provider provider,
List<KeyOperation> keyOperations)
Converts EC key pair to JSON web key.
|
static JsonWebKey |
fromRsa(KeyPair keyPair)
Converts RSA key pair to JSON web key.
|
static JsonWebKey |
fromRsa(KeyPair keyPair,
List<KeyOperation> keyOperations)
Converts RSA key pair to JSON web key.
|
KeyCurveName |
getCurveName()
Get the crv value.
|
byte[] |
getD()
Get the d value.
|
byte[] |
getDp()
Get the RSA Private Key Parameter value.
|
byte[] |
getDq()
Get the RSA Private Key Parameter value.
|
byte[] |
getE()
Get the e value.
|
String |
getId()
Get the kid value.
|
byte[] |
getK()
Get Symmetric key value.
|
List<KeyOperation> |
getKeyOps()
Get the immutable key operations list.
|
KeyType |
getKeyType()
Get the kty value.
|
byte[] |
getN()
Get the n value.
|
byte[] |
getP()
Get the RSA secret prime value.
|
byte[] |
getQ()
Get RSA secret prime, with p < q value.
|
byte[] |
getQi()
Get the RSA Private Key Parameter value.
|
byte[] |
getT()
Get HSM Token value, used with Bring Your Own Key.
|
byte[] |
getX()
Get the x value.
|
byte[] |
getY()
Get the y value.
|
int |
hashCode() |
boolean |
hasPrivateKey()
Verifies whether the
JsonWebKey has private key. |
boolean |
isValid()
Verifies whether the
JsonWebKey is valid. |
JsonWebKey |
setCurveName(KeyCurveName crv)
Set the crv value.
|
JsonWebKey |
setD(byte[] d)
Set the d value.
|
JsonWebKey |
setDp(byte[] dp)
Set RSA Private Key Parameter value.
|
JsonWebKey |
setDq(byte[] dq)
Set RSA Private Key Parameter value .
|
JsonWebKey |
setE(byte[] e)
Set the e value.
|
JsonWebKey |
setId(String keyId)
Set the key identifier value.
|
JsonWebKey |
setK(byte[] k)
Set the Symmetric key value.
|
JsonWebKey |
setKeyOps(List<KeyOperation> keyOps)
Set the keyOps value.
|
JsonWebKey |
setKeyType(KeyType keyType)
Set the key type value.
|
JsonWebKey |
setN(byte[] n)
Set the n value.
|
JsonWebKey |
setP(byte[] p)
Set the RSA secret prime value.
|
JsonWebKey |
setQ(byte[] q)
Set the RSA secret prime, with p < q value.
|
JsonWebKey |
setQi(byte[] qi)
Set RSA Private Key Parameter value.
|
JsonWebKey |
setT(byte[] t)
Set HSM Token value, used with Bring Your Own Key.
|
JsonWebKey |
setX(byte[] x)
Set the x value.
|
JsonWebKey |
setY(byte[] y)
Set the y value.
|
SecretKey |
toAes()
Converts JSON web key to AES key.
|
KeyPair |
toEc()
Converts JSON web key to EC key pair and include the private key if set to
true.
|
KeyPair |
toEc(boolean includePrivateParameters)
Converts JSON web key to EC key pair and include the private key if set to
true.
|
KeyPair |
toEc(boolean includePrivateParameters,
Provider provider)
Converts JSON web key to EC key pair and include the private key if set to
true.
|
KeyPair |
toRsa()
Converts JSON web key to RSA key pair.
|
KeyPair |
toRsa(boolean includePrivateParameters)
Converts JSON web key to RSA key pair and include the private key if set to
true.
|
KeyPair |
toRsa(boolean includePrivateParameters,
Provider provider)
Converts JSON web key to RSA key pair and include the private key if set to
true.
|
String |
toString() |
public String getId()
public JsonWebKey setId(String keyId)
keyId
- The keyId value to setpublic KeyType getKeyType()
public JsonWebKey setKeyType(KeyType keyType)
keyType
- The key typepublic List<KeyOperation> getKeyOps()
public JsonWebKey setKeyOps(List<KeyOperation> keyOps)
keyOps
- The keyOps value to setpublic byte[] getN()
public JsonWebKey setN(byte[] n)
n
- The n value to setpublic byte[] getE()
public JsonWebKey setE(byte[] e)
e
- The e value to setpublic byte[] getD()
public JsonWebKey setD(byte[] d)
d
- The d value to setpublic byte[] getDp()
public JsonWebKey setDp(byte[] dp)
dp
- The RSA Private Key Parameter value to set.public byte[] getDq()
public JsonWebKey setDq(byte[] dq)
dq
- The RSA Private Key Parameter value to set.public byte[] getQi()
public JsonWebKey setQi(byte[] qi)
qi
- The RSA Private Key Parameter value to set.public byte[] getP()
public JsonWebKey setP(byte[] p)
p
- The RSA secret prime value.public byte[] getQ()
public JsonWebKey setQ(byte[] q)
q
- The the RSA secret prime, with p < q value to be set.public byte[] getK()
public JsonWebKey setK(byte[] k)
k
- The symmetric key value to set.public byte[] getT()
public JsonWebKey setT(byte[] t)
t
- The HSM Token value to set, used with Bring Your Own Keypublic KeyCurveName getCurveName()
public JsonWebKey setCurveName(KeyCurveName crv)
crv
- The crv value to setpublic byte[] getX()
public JsonWebKey setX(byte[] x)
x
- The x value to setpublic byte[] getY()
public JsonWebKey setY(byte[] y)
y
- The y value to setpublic static JsonWebKey fromRsa(KeyPair keyPair)
keyPair
- Tbe RSA key pairpublic static JsonWebKey fromRsa(KeyPair keyPair, List<KeyOperation> keyOperations)
keyPair
- Tbe RSA key pairkeyOperations
- The key operations to set on the keypublic KeyPair toRsa()
public KeyPair toRsa(boolean includePrivateParameters)
includePrivateParameters
- true if the RSA key pair should include the private key. False otherwise.public KeyPair toRsa(boolean includePrivateParameters, Provider provider)
provider
- The Java security provider.includePrivateParameters
- true if the RSA key pair should include the private key. False otherwise.public KeyPair toEc()
public KeyPair toEc(boolean includePrivateParameters)
includePrivateParameters
- true if the EC key pair should include the private key. False otherwise.public KeyPair toEc(boolean includePrivateParameters, Provider provider)
includePrivateParameters
- true if the EC key pair should include the private key. False otherwise.provider
- The Java security providerIllegalArgumentException
- if the key type is not EC or EC HSMIllegalStateException
- if an instance of EC key pair cannot be generatedpublic static JsonWebKey fromEc(KeyPair keyPair, Provider provider)
keyPair
- The EC key pairprovider
- The Java security providerpublic static JsonWebKey fromEc(KeyPair keyPair, Provider provider, List<KeyOperation> keyOperations)
keyPair
- The EC key pairprovider
- The Java security providerkeyOperations
- The key operations to set.public static JsonWebKey fromAes(SecretKey secretKey)
secretKey
- The AES keypublic static JsonWebKey fromAes(SecretKey secretKey, List<KeyOperation> keyOperations)
secretKey
- The AES keykeyOperations
- The key operations to setpublic SecretKey toAes()
public boolean equals(JsonWebKey jwk)
JsonWebKey
is "equal to" this one.jwk
- The other JsonWebKey
to compare with.JsonWebKey
is the same as the jwk argument;
false otherwise.public boolean hasPrivateKey()
JsonWebKey
has private key.JsonWebKey
has private key; false otherwise.public boolean isValid()
JsonWebKey
is valid.JsonWebKey
is valid; false otherwise.public void clearMemory()
Visit the Azure for Java Developers site for more Java documentation, including quick starts, tutorials, and code samples.