Class JsonWebKey
java.lang.Object
com.azure.security.keyvault.keys.models.JsonWebKey
- All Implemented Interfaces:
com.azure.json.JsonSerializable<JsonWebKey>
As of http://tools.ietf.org/html/draft-ietf-jose-json-web-key-18.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidClear key materials.booleanequals(JsonWebKey jwk) Indicates whether some otherJsonWebKeyis "equal to" this one.booleanstatic JsonWebKeyConverts AES key to JSON web key.static JsonWebKeyfromAes(SecretKey secretKey, List<KeyOperation> keyOperations) Converts AES key to JSON web key.static JsonWebKeyConverts EC key pair to JSON web key.static JsonWebKeyfromEc(KeyPair keyPair, Provider provider, List<KeyOperation> keyOperations) Converts EC key pair to JSON web key.static JsonWebKeyfromJson(com.azure.json.JsonReader jsonReader) Reads a JSON stream into aJsonWebKey.static JsonWebKeyConverts RSA key pair to JSON web key.static JsonWebKeyfromRsa(KeyPair keyPair, List<KeyOperation> keyOperations) Converts RSA key pair to JSON web key.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.getId()Get the kid value.byte[]getK()Get Symmetric key value.Get the immutable key operations list.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.inthashCode()booleanVerifies whether theJsonWebKeyhas private key.booleanisValid()Verifies whether theJsonWebKeyis valid.setCurveName(KeyCurveName crv) Set the crv value.setD(byte[] d) Set the d value.setDp(byte[] dp) Set RSA Private Key Parameter value.setDq(byte[] dq) Set RSA Private Key Parameter value .setE(byte[] e) Set the e value.Set the key identifier value.setK(byte[] k) Set the Symmetric key value.setKeyOps(List<KeyOperation> keyOps) Set the keyOps value.setKeyType(KeyType keyType) Set the key type value.setN(byte[] n) Set the n value.setP(byte[] p) Set the RSA secret prime value.setQ(byte[] q) Set the RSA secret prime, with p < q value.setQi(byte[] qi) Set RSA Private Key Parameter value.setT(byte[] t) Set HSM Token value, used with Bring Your Own Key.setX(byte[] x) Set the x value.setY(byte[] y) Set the y value.toAes()Converts JSON web key to AES key.toEc()Converts JSON web key to EC key pair and include the private key if set to true.toEc(boolean includePrivateParameters) Converts JSON web key to EC key pair and include the private key if set to true.Converts JSON web key to EC key pair and include the private key if set to true.com.azure.json.JsonWritertoJson(com.azure.json.JsonWriter jsonWriter) toRsa()Converts JSON web key to RSA key pair.toRsa(boolean includePrivateParameters) Converts JSON web key to RSA key pair and include the private key if set to true.Converts JSON web key to RSA key pair and include the private key if set to true.toString()Methods inherited from interface com.azure.json.JsonSerializable
toJson, toJson, toJsonBytes, toJsonString
-
Constructor Details
-
JsonWebKey
public JsonWebKey()Creates a new instance ofJsonWebKey.
-
-
Method Details
-
getId
-
setId
Set the key identifier value.- Parameters:
keyId- The keyId value to set- Returns:
- the JsonWebKey object itself.
-
getKeyType
-
setKeyType
Set the key type value.- Parameters:
keyType- The key type- Returns:
- the JsonWebKey object itself.
-
getKeyOps
Get the immutable key operations list. The list cannot be modified.- Returns:
- the key operations list
-
setKeyOps
Set the keyOps value.- Parameters:
keyOps- The keyOps value to set- Returns:
- the JsonWebKey object itself.
-
getN
public byte[] getN()Get the n value.- Returns:
- the n value
-
setN
Set the n value.- Parameters:
n- The n value to set- Returns:
- the JsonWebKey object itself.
-
getE
public byte[] getE()Get the e value.- Returns:
- the e value
-
setE
Set the e value.- Parameters:
e- The e value to set- Returns:
- the JsonWebKey object itself.
-
getD
public byte[] getD()Get the d value.- Returns:
- the d value
-
setD
Set the d value.- Parameters:
d- The d value to set- Returns:
- the JsonWebKey object itself.
-
getDp
public byte[] getDp()Get the RSA Private Key Parameter value.- Returns:
- the RSA Private Key Parameter value.
-
setDp
Set RSA Private Key Parameter value.- Parameters:
dp- The RSA Private Key Parameter value to set.- Returns:
- the JsonWebKey object itself.
-
getDq
public byte[] getDq()Get the RSA Private Key Parameter value.- Returns:
- the RSA Private Key Parameter value.
-
setDq
Set RSA Private Key Parameter value .- Parameters:
dq- The RSA Private Key Parameter value to set.- Returns:
- the JsonWebKey object itself.
-
getQi
public byte[] getQi()Get the RSA Private Key Parameter value.- Returns:
- the RSA Private Key Parameter value.
-
setQi
Set RSA Private Key Parameter value.- Parameters:
qi- The RSA Private Key Parameter value to set.- Returns:
- the JsonWebKey object itself.
-
getP
public byte[] getP()Get the RSA secret prime value.- Returns:
- the RSA secret prime value.
-
setP
Set the RSA secret prime value.- Parameters:
p- The RSA secret prime value.- Returns:
- the JsonWebKey object itself.
-
getQ
public byte[] getQ()Get RSA secret prime, with p < q value.- Returns:
- the RSA secret prime, with p < q value.
-
setQ
Set the RSA secret prime, with p < q value.- Parameters:
q- The the RSA secret prime, with p < q value to be set.- Returns:
- the JsonWebKey object itself.
-
getK
public byte[] getK()Get Symmetric key value.- Returns:
- the symmetric key value.
-
setK
Set the Symmetric key value.- Parameters:
k- The symmetric key value to set.- Returns:
- the JsonWebKey object itself.
-
getT
public byte[] getT()Get HSM Token value, used with Bring Your Own Key.- Returns:
- HSM Token, used with Bring Your Own Key.
-
setT
Set HSM Token value, used with Bring Your Own Key.- Parameters:
t- The HSM Token value to set, used with Bring Your Own Key- Returns:
- the JsonWebKey object itself.
-
toString
-
getCurveName
-
setCurveName
Set the crv value.- Parameters:
crv- The crv value to set- Returns:
- the JsonWebKey object itself.
-
getX
public byte[] getX()Get the x value.- Returns:
- the x value
-
setX
Set the x value.- Parameters:
x- The x value to set- Returns:
- the JsonWebKey object itself.
-
getY
public byte[] getY()Get the y value.- Returns:
- the y value
-
setY
Set the y value.- Parameters:
y- The y value to set- Returns:
- the JsonWebKey object itself.
-
fromRsa
Converts RSA key pair to JSON web key.- Parameters:
keyPair- Tbe RSA key pair- Returns:
- the JSON web key, converted from RSA key pair.
-
fromRsa
Converts RSA key pair to JSON web key.- Parameters:
keyPair- Tbe RSA key pairkeyOperations- The key operations to set on the key- Returns:
- the JSON web key, converted from RSA key pair.
-
toRsa
-
toRsa
Converts JSON web key to RSA key pair and include the private key if set to true.- Parameters:
includePrivateParameters- true if the RSA key pair should include the private key. False otherwise.- Returns:
- RSA key pair
-
toRsa
Converts JSON web key to RSA key pair and include the private key if set to true.- Parameters:
includePrivateParameters- true if the RSA key pair should include the private key. False otherwise.provider- The Java security provider.- Returns:
- RSA key pair
-
toEc
Converts JSON web key to EC key pair and include the private key if set to true.- Returns:
- EC key pair
-
toEc
Converts JSON web key to EC key pair and include the private key if set to true.- Parameters:
includePrivateParameters- true if the EC key pair should include the private key. False otherwise.- Returns:
- EC key pair
-
toEc
Converts JSON web key to EC key pair and include the private key if set to true.- Parameters:
includePrivateParameters- true if the EC key pair should include the private key. False otherwise.provider- The Java security provider- Returns:
- EC key pair
- Throws:
IllegalArgumentException- if the key type is not EC or EC HSMIllegalStateException- if an instance of EC key pair cannot be generated
-
fromEc
Converts EC key pair to JSON web key.- Parameters:
keyPair- The EC key pairprovider- The Java security provider- Returns:
- the JSON web key, converted from EC key pair.
-
fromEc
public static JsonWebKey fromEc(KeyPair keyPair, Provider provider, List<KeyOperation> keyOperations) Converts EC key pair to JSON web key.- Parameters:
keyPair- The EC key pairprovider- The Java security providerkeyOperations- The key operations to set.- Returns:
- the JSON web key, converted from EC key pair.
-
fromAes
Converts AES key to JSON web key.- Parameters:
secretKey- The AES key- Returns:
- the JSON web key, converted from AES key.
-
fromAes
Converts AES key to JSON web key.- Parameters:
secretKey- The AES keykeyOperations- The key operations to set- Returns:
- the JSON web key, converted from AES key.
-
toAes
-
equals
-
equals
Indicates whether some otherJsonWebKeyis "equal to" this one.- Parameters:
jwk- The otherJsonWebKeyto compare with.- Returns:
- true if this
JsonWebKeyis the same as the jwk argument; false otherwise.
-
hasPrivateKey
public boolean hasPrivateKey()Verifies whether theJsonWebKeyhas private key.- Returns:
- true if the
JsonWebKeyhas private key; false otherwise.
-
isValid
public boolean isValid()Verifies whether theJsonWebKeyis valid.- Returns:
- true if the
JsonWebKeyis valid; false otherwise.
-
clearMemory
public void clearMemory()Clear key materials. -
hashCode
-
toJson
- Specified by:
toJsonin interfacecom.azure.json.JsonSerializable<JsonWebKey>- Throws:
IOException
-
fromJson
Reads a JSON stream into aJsonWebKey.- Parameters:
jsonReader- TheJsonReaderbeing read.- Returns:
- An instance of
JsonWebKeythat the JSON stream represented, may return null. - Throws:
IOException- If aJsonWebKeyfails to be read from thejsonReader.
-