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 voidclearMemory()Clear key materials.JsonWebKeyCurveNamecrv()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.booleanequals(JsonWebKey jwk)Indicates whether some otherJsonWebKeyis "equal to" this one.booleanequals(Object obj)static JsonWebKeyfromAes(SecretKey secretKey)Converts AES key to JSON web key.static JsonWebKeyfromEC(KeyPair keyPair, Provider provider)Converts EC key pair to JSON web key.static JsonWebKeyfromRSA(KeyPair keyPair)Converts RSA key pair to JSON web key.inthashCode()booleanhasPrivateKey()Verifies whether theJsonWebKeyhas private key.booleanisValid()Verifies whether theJsonWebKeyis valid.byte[]k()Get Symmetric key value.List<JsonWebKeyOperation>keyOps()Get the keyOps value.Stringkid()Get the kid value.JsonWebKeyTypekty()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.SecretKeytoAes()Converts JSON web key to AES key.KeyPairtoEC()Converts JSON web key to EC key pair and include the private key if set to true.KeyPairtoEC(boolean includePrivateParameters)Converts JSON web key to EC key pair and include the private key if set to true.KeyPairtoEC(boolean includePrivateParameters, Provider provider)Converts JSON web key to EC key pair and include the private key if set to true.KeyPairtoRSA()Converts JSON web key to RSA key pair.KeyPairtoRSA(boolean includePrivateParameters)Converts JSON web key to RSA key pair and include the private key if set to true.KeyPairtoRSA(boolean includePrivateParameters, Provider provider)Converts JSON web key to RSA key pair and include the private key if set to true.StringtoString()JsonWebKeywithCrv(JsonWebKeyCurveName crv)Set the crv value.JsonWebKeywithD(byte[] d)Set the d value.JsonWebKeywithDp(byte[] dp)Set RSA Private Key Parameter value.JsonWebKeywithDq(byte[] dq)Set RSA Private Key Parameter value .JsonWebKeywithE(byte[] e)Set the e value.JsonWebKeywithK(byte[] k)Set the Symmetric key value.JsonWebKeywithKeyOps(List<JsonWebKeyOperation> keyOps)Set the keyOps value.JsonWebKeywithKid(String kid)Set the key identifier value.JsonWebKeywithKty(JsonWebKeyType kty)Set the key type value.JsonWebKeywithN(byte[] n)Set the n value.JsonWebKeywithP(byte[] p)Set the RSA secret prime value.JsonWebKeywithQ(byte[] q)Set the RSA secret prime, with p < q value.JsonWebKeywithQi(byte[] qi)Set RSA Private Key Parameter value.JsonWebKeywithT(byte[] t)Set HSM Token value, used with Bring Your Own Key.JsonWebKeywithX(byte[] x)Set the x value.JsonWebKeywithY(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 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.
-
-