public class JsonWebKey extends Object
| Constructor and Description |
|---|
JsonWebKey() |
| Modifier and Type | Method and Description |
|---|---|
void |
clearMemory()
Clear key materials.
|
JsonWebKeyCurveName |
crv()
Get the crv value.
|
byte[] |
d()
Get the d value.
|
byte[] |
dp()
Get the RSA Private Key Parameter value.
|
byte[] |
dq()
Get the RSA Private Key Parameter value.
|
byte[] |
e()
Get the e value.
|
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 |
fromEC(KeyPair keyPair,
Provider provider)
Converts EC key pair to JSON web key.
|
static JsonWebKey |
fromRSA(KeyPair keyPair)
Converts RSA key pair to JSON web key.
|
int |
hashCode() |
boolean |
hasPrivateKey()
Verifies whether the
JsonWebKey has private key. |
boolean |
isValid()
Verifies whether the
JsonWebKey is valid. |
byte[] |
k()
Get Symmetric key value.
|
List<JsonWebKeyOperation> |
keyOps()
Get the keyOps value.
|
String |
kid()
Get the kid value.
|
JsonWebKeyType |
kty()
Get the kty value.
|
byte[] |
n()
Get the n value.
|
byte[] |
p()
Get the RSA secret prime value.
|
byte[] |
q()
Get RSA secret prime, with p < q value.
|
byte[] |
qi()
Get the RSA Private Key Parameter value.
|
byte[] |
t()
Get HSM Token value, used with Bring Your Own Key.
|
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() |
JsonWebKey |
withCrv(JsonWebKeyCurveName crv)
Set the crv value.
|
JsonWebKey |
withD(byte[] d)
Set the d value.
|
JsonWebKey |
withDp(byte[] dp)
Set RSA Private Key Parameter value.
|
JsonWebKey |
withDq(byte[] dq)
Set RSA Private Key Parameter value .
|
JsonWebKey |
withE(byte[] e)
Set the e value.
|
JsonWebKey |
withK(byte[] k)
Set the Symmetric key value.
|
JsonWebKey |
withKeyOps(List<JsonWebKeyOperation> keyOps)
Set the keyOps value.
|
JsonWebKey |
withKid(String kid)
Set the key identifier value.
|
JsonWebKey |
withKty(JsonWebKeyType kty)
Set the key type value.
|
JsonWebKey |
withN(byte[] n)
Set the n value.
|
JsonWebKey |
withP(byte[] p)
Set the RSA secret prime value.
|
JsonWebKey |
withQ(byte[] q)
Set the RSA secret prime, with p < q value.
|
JsonWebKey |
withQi(byte[] qi)
Set RSA Private Key Parameter value.
|
JsonWebKey |
withT(byte[] t)
Set HSM Token value, used with Bring Your Own Key.
|
JsonWebKey |
withX(byte[] x)
Set the x value.
|
JsonWebKey |
withY(byte[] y)
Set the y value.
|
byte[] |
x()
Get the x value.
|
byte[] |
y()
Get the y value.
|
public String kid()
public JsonWebKey withKid(String kid)
kid - the kid value to setpublic JsonWebKeyType kty()
public JsonWebKey withKty(JsonWebKeyType kty)
kty - the key typepublic List<JsonWebKeyOperation> keyOps()
public JsonWebKey withKeyOps(List<JsonWebKeyOperation> keyOps)
keyOps - the keyOps value to setpublic byte[] n()
public JsonWebKey withN(byte[] n)
n - the n value to setpublic byte[] e()
public JsonWebKey withE(byte[] e)
e - the e value to setpublic byte[] d()
public JsonWebKey withD(byte[] d)
d - the d value to setpublic byte[] dp()
public JsonWebKey withDp(byte[] dp)
dp - the RSA Private Key Parameter value to set.public byte[] dq()
public JsonWebKey withDq(byte[] dq)
dq - the RSA Private Key Parameter value to set.public byte[] qi()
public JsonWebKey withQi(byte[] qi)
qi - the RSA Private Key Parameter value to set.public byte[] p()
public JsonWebKey withP(byte[] p)
p - the RSA secret prime value.public byte[] q()
public JsonWebKey withQ(byte[] q)
q - the the RSA secret prime, with p < q value to be set.public byte[] k()
public JsonWebKey withK(byte[] k)
k - the symmetric key value to set.public byte[] t()
public JsonWebKey withT(byte[] t)
t - HSM Token value to set, used with Bring Your Own Keypublic JsonWebKeyCurveName crv()
public JsonWebKey withCrv(JsonWebKeyCurveName crv)
crv - the crv value to setpublic byte[] x()
public JsonWebKey withX(byte[] x)
x - the x value to setpublic byte[] y()
public JsonWebKey withY(byte[] y)
y - the y value to setpublic static JsonWebKey fromRSA(KeyPair keyPair)
keyPair - RSA key pairpublic 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 - Java security providerpublic static JsonWebKey fromEC(KeyPair keyPair, Provider provider)
keyPair - EC key pairprovider - Java security providerpublic static JsonWebKey fromAes(SecretKey secretKey)
secretKey - AES keypublic 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()
/**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for
* license information.
*/