public class JsonWebKey extends Object
| Constructor and Description |
|---|
JsonWebKey() |
| Modifier and Type | Method and Description |
|---|---|
void |
clearMemory()
Clear key materials.
|
byte[] |
d()
Get the RSA private exponent value.
|
byte[] |
dp()
Get the RSA Private Key Parameter value.
|
byte[] |
dq()
Get the RSA Private Key Parameter value.
|
byte[] |
e()
Get the RSA public exponent 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 |
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 key operations.
|
String |
kid()
Key Identifier.
|
JsonWebKeyType |
kty()
Key type, usually RSA.
|
byte[] |
n()
Get the RSA modulus 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 |
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 |
withD(byte[] d)
Set RSA private exponent 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 RSA public exponent value.
|
JsonWebKey |
withK(byte[] k)
Set the Symmetric key value.
|
JsonWebKey |
withKeyOps(List<JsonWebKeyOperation> keyOps)
Set the key operations 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 RSA modulus 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.
|
public String kid()
public JsonWebKey withKid(String kid)
kid - the key identifierpublic JsonWebKeyType kty()
public JsonWebKey withKty(JsonWebKeyType kty)
kty - the key typepublic List<JsonWebKeyOperation> keyOps()
public JsonWebKey withKeyOps(List<JsonWebKeyOperation> keyOps)
keyOps - the key operations value to setpublic byte[] n()
public JsonWebKey withN(byte[] n)
n - the RSA modulus value to setpublic byte[] e()
public JsonWebKey withE(byte[] e)
e - RSA public exponent value to setpublic byte[] d()
public JsonWebKey withD(byte[] d)
d - the RSA private exponent value to set.public 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 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 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.
*/