Class JsonWebKey
- java.lang.Object
-
- com.microsoft.azure.keyvault.webkey.JsonWebKey
-
public class JsonWebKey extends Object
As of http://tools.ietf.org/html/draft-ietf-jose-json-web-key-18.
-
-
Constructor Summary
Constructors Constructor Description JsonWebKey()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method 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 otherJsonWebKey
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 theJsonWebKey
has private key.boolean
isValid()
Verifies whether theJsonWebKey
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.
-
-
-
Method Detail
-
kid
public String kid()
Get the kid value.- Returns:
- the kid value
-
withKid
public JsonWebKey withKid(String kid)
Set the key identifier value.- Parameters:
kid
- the kid value to set- Returns:
- the JsonWebKey object itself.
-
kty
public JsonWebKeyType kty()
Get the kty value.- Returns:
- the kty value
-
withKty
public JsonWebKey withKty(JsonWebKeyType kty)
Set the key type value.- Parameters:
kty
- the key type- Returns:
- the JsonWebKey object itself.
-
keyOps
public List<JsonWebKeyOperation> keyOps()
Get the keyOps value.- Returns:
- the keyOps value
-
withKeyOps
public JsonWebKey withKeyOps(List<JsonWebKeyOperation> keyOps)
Set the keyOps value.- Parameters:
keyOps
- the keyOps value to set- Returns:
- the JsonWebKey object itself.
-
n
public byte[] n()
Get the n value.- Returns:
- the n value
-
withN
public JsonWebKey withN(byte[] n)
Set the n value.- Parameters:
n
- the n value to set- Returns:
- the JsonWebKey object itself.
-
e
public byte[] e()
Get the e value.- Returns:
- the e value
-
withE
public JsonWebKey withE(byte[] e)
Set the e value.- Parameters:
e
- the e value to set- Returns:
- the JsonWebKey object itself.
-
d
public byte[] d()
Get the d value.- Returns:
- the d value
-
withD
public JsonWebKey withD(byte[] d)
Set the d value.- Parameters:
d
- the d value to set- Returns:
- the JsonWebKey object itself.
-
dp
public byte[] dp()
Get the RSA Private Key Parameter value.- Returns:
- the RSA Private Key Parameter value.
-
withDp
public JsonWebKey withDp(byte[] dp)
Set RSA Private Key Parameter value.- Parameters:
dp
- the RSA Private Key Parameter value to set.- Returns:
- the JsonWebKey object itself.
-
dq
public byte[] dq()
Get the RSA Private Key Parameter value.- Returns:
- the RSA Private Key Parameter value.
-
withDq
public JsonWebKey withDq(byte[] dq)
Set RSA Private Key Parameter value .- Parameters:
dq
- the RSA Private Key Parameter value to set.- Returns:
- the JsonWebKey object itself.
-
qi
public byte[] qi()
Get the RSA Private Key Parameter value.- Returns:
- the RSA Private Key Parameter value.
-
withQi
public JsonWebKey withQi(byte[] qi)
Set RSA Private Key Parameter value.- Parameters:
qi
- the RSA Private Key Parameter value to set.- Returns:
- the JsonWebKey object itself.
-
p
public byte[] p()
Get the RSA secret prime value.- Returns:
- the RSA secret prime value.
-
withP
public JsonWebKey withP(byte[] p)
Set the RSA secret prime value.- Parameters:
p
- the RSA secret prime value.- Returns:
- the JsonWebKey object itself.
-
q
public byte[] q()
Get RSA secret prime, with p < q value.- Returns:
- the RSA secret prime, with p < q value.
-
withQ
public JsonWebKey withQ(byte[] q)
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.
-
k
public byte[] k()
Get Symmetric key value.- Returns:
- the symmetric key value.
-
withK
public JsonWebKey withK(byte[] k)
Set the Symmetric key value.- Parameters:
k
- the symmetric key value to set.- Returns:
- the JsonWebKey object itself.
-
t
public byte[] t()
Get HSM Token value, used with Bring Your Own Key.- Returns:
- HSM Token, used with Bring Your Own Key.
-
withT
public JsonWebKey withT(byte[] t)
Set HSM Token value, used with Bring Your Own Key.- Parameters:
t
- HSM Token value to set, used with Bring Your Own Key- Returns:
- the JsonWebKey object itself.
-
crv
public JsonWebKeyCurveName crv()
Get the crv value.- Returns:
- the crv value
-
withCrv
public JsonWebKey withCrv(JsonWebKeyCurveName crv)
Set the crv value.- Parameters:
crv
- the crv value to set- Returns:
- the JsonWebKey object itself.
-
x
public byte[] x()
Get the x value.- Returns:
- the x value
-
withX
public JsonWebKey withX(byte[] x)
Set the x value.- Parameters:
x
- the x value to set- Returns:
- the JsonWebKey object itself.
-
y
public byte[] y()
Get the y value.- Returns:
- the y value
-
withY
public JsonWebKey withY(byte[] y)
Set the y value.- Parameters:
y
- the y value to set- Returns:
- the JsonWebKey object itself.
-
fromRSA
public static JsonWebKey fromRSA(KeyPair keyPair)
Converts RSA key pair to JSON web key.- Parameters:
keyPair
- RSA key pair- Returns:
- the JSON web key, converted from RSA key pair.
-
toRSA
public KeyPair toRSA()
Converts JSON web key to RSA key pair.- Returns:
- RSA key pair
-
toRSA
public KeyPair toRSA(boolean includePrivateParameters)
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
public KeyPair toRSA(boolean includePrivateParameters, Provider provider)
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
public KeyPair toEC()
Converts JSON web key to EC key pair and include the private key if set to true.- Returns:
- EC key pair
-
toEC
public KeyPair toEC(boolean includePrivateParameters)
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
public KeyPair toEC(boolean includePrivateParameters, Provider provider)
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
- Java security provider- Returns:
- EC key pair
-
fromEC
public static JsonWebKey fromEC(KeyPair keyPair, Provider provider)
Converts EC key pair to JSON web key.- Parameters:
keyPair
- EC key pairprovider
- Java security provider- Returns:
- the JSON web key, converted from EC key pair.
-
fromAes
public static JsonWebKey fromAes(SecretKey secretKey)
Converts AES key to JSON web key.- Parameters:
secretKey
- AES key- Returns:
- the JSON web key, converted from AES key.
-
toAes
public SecretKey toAes()
Converts JSON web key to AES key.- Returns:
- AES key
-
equals
public boolean equals(JsonWebKey jwk)
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.
-
-