Class JsonWebKey
java.lang.Object
com.azure.security.keyvault.keys.models.JsonWebKey
As of http://tools.ietf.org/html/draft-ietf-jose-json-web-key-18.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Clear key materials.boolean
equals
(JsonWebKey jwk) Indicates whether some otherJsonWebKey
is "equal to" this one.boolean
static JsonWebKey
Converts AES key to JSON web key.static JsonWebKey
fromAes
(SecretKey secretKey, List<KeyOperation> keyOperations) Converts AES key to JSON web key.static JsonWebKey
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
Converts RSA key pair to JSON web key.static JsonWebKey
fromRsa
(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.int
hashCode()
boolean
Verifies whether theJsonWebKey
has private key.boolean
isValid()
Verifies whether theJsonWebKey
is 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.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()
-
Constructor Details
-
JsonWebKey
public JsonWebKey()
-
-
Method Details
-
getId
Get the kid value.- Returns:
- the kid value
-
setId
Set the key identifier value.- Parameters:
keyId
- The keyId value to set- Returns:
- the JsonWebKey object itself.
-
getKeyType
Get the kty value.- Returns:
- the kty value
-
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
Get the crv value.- Returns:
- the crv value
-
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
Converts JSON web key to RSA key pair.- 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.- Returns:
- RSA key pair
-
toRsa
Converts JSON web key to RSA key pair and include the private key if set to true.- Parameters:
provider
- The Java security provider.includePrivateParameters
- true if the RSA key pair should include the private key. False otherwise.- 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
Converts JSON web key to AES key.- Returns:
- AES key
-
equals
-
equals
Indicates whether some otherJsonWebKey
is "equal to" this one.- Parameters:
jwk
- The otherJsonWebKey
to compare with.- Returns:
- true if this
JsonWebKey
is the same as the jwk argument; false otherwise.
-
hasPrivateKey
public boolean hasPrivateKey()Verifies whether theJsonWebKey
has private key.- Returns:
- true if the
JsonWebKey
has private key; false otherwise.
-
isValid
public boolean isValid()Verifies whether theJsonWebKey
is valid.- Returns:
- true if the
JsonWebKey
is valid; false otherwise.
-
clearMemory
public void clearMemory()Clear key materials. -
hashCode
public int hashCode()
-