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. |
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 KeyType getKeyType()
public List<KeyOperation> getKeyOps()
public byte[] getN()
public byte[] getE()
public byte[] getD()
public byte[] getDp()
public byte[] getDq()
public byte[] getQi()
public byte[] getP()
public byte[] getQ()
public byte[] getK()
public byte[] getT()
public KeyCurveName getCurveName()
public byte[] getX()
public byte[] getY()
public 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()
Copyright © 2020 Microsoft Corporation. All rights reserved.