JsonWebKey Class

  • java.lang.Object
    • com.microsoft.azure.keyvault.webkey.JsonWebKey

public class JsonWebKey

Method Summary

Modifier and Type Method and Description
void clearMemory()

Clear key materials.

byte [] d()

Get the RSA private exponent value.

byte [] dp()

Get the RSA Private Key Parameter value.

byte [] dq()

Get the RSA Private Key Parameter value.

byte [] e()

Get the RSA public exponent value.

boolean equals(JsonWebKey jwk)

Indicates whether some other JsonWebKey is "equal to" this one.

boolean equals(Object obj)
JsonWebKey fromAes(SecretKey secretKey)

Converts AES key to JSON web key.

JsonWebKey fromRSA(KeyPair keyPair)

Converts RSA key pair to JSON web key.

int hashCode()
boolean hasPrivateKey()

Verifies whether the JsonWebKey has private key.

boolean isValid()

Verifies whether the JsonWebKey is valid.

byte [] k()

Get Symmetric key value.

List<JsonWebKeyOperation> keyOps()

Get the key operations.

String kid()

Key Identifier.

JsonWebKeyType kty()

Key type, usually RSA. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct'.

byte [] n()

Get the RSA modulus 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 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 withD(byte[] d)

Set RSA private exponent 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 RSA public exponent value.

JsonWebKey withK(byte[] k)

Set the Symmetric key value.

JsonWebKey withKeyOps(List<JsonWebKeyOperation> keyOps)

Set the key operations 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 RSA modulus 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.

Method Details

clearMemory

public void clearMemory()

Clear key materials.

d

public byte [] d()

Get the RSA private exponent value.

Returns:

the RSA private exponent value.

dp

public byte [] dp()

Get the RSA Private Key Parameter value.

Returns:

the RSA Private Key Parameter value.

dq

public byte [] dq()

Get the RSA Private Key Parameter value.

Returns:

the RSA Private Key Parameter value.

e

public byte [] e()

Get the RSA public exponent value.

Returns:

the RSA public exponent value.

equals

public boolean equals(JsonWebKey jwk)

Indicates whether some other JsonWebKey is "equal to" this one.

Parameters:

jwk - the other JsonWebKey to compare with.

Returns:

true if this JsonWebKey is the same as the jwk argument; false otherwise.

equals

public boolean equals(Object obj)

Parameters:

obj

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.

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.

hashCode

public int hashCode()

hasPrivateKey

public boolean hasPrivateKey()

Verifies whether the JsonWebKey has private key.

Returns:

true if the JsonWebKey has private key; false otherwise.

isValid

public boolean isValid()

Verifies whether the JsonWebKey is valid.

Returns:

true if the JsonWebKey is valid; false otherwise.

k

public byte [] k()

Get Symmetric key value.

Returns:

the symmetric key value.

keyOps

public List keyOps()

Get the key operations.

Returns:

the key operations.

kid

public String kid()

Key Identifier.

Returns:

the kid value.

kty

public JsonWebKeyType kty()

Key type, usually RSA. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct'.

Returns:

the key type.

n

public byte [] n()

Get the RSA modulus value.

Returns:

the RSA modulus value.

p

public byte [] p()

Get the RSA secret prime value.

Returns:

the RSA secret prime value.

q

public byte [] q()

Get RSA secret prime, with p <q value.

Returns:

the RSA secret prime, with p <q value.

qi

public byte [] qi()

Get the RSA Private Key Parameter value.

Returns:

the RSA Private Key Parameter value.

t

public byte [] t()

Get HSM Token value, used with Bring Your Own Key.

Returns:

HSM Token, used with Bring Your Own Key.

toAes

public SecretKey toAes()

Converts JSON web key to AES key.

Returns:

AES key

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:

includePrivateParameters - true if the RSA key pair should include the private key. False otherwise.
provider - the Java security provider.

Returns:

RSA key pair

toString

public String toString()

withD

public JsonWebKey withD(byte[] d)

Set RSA private exponent value.

Parameters:

d - the RSA private exponent value to set.

Returns:

the JsonWebKey object itself.

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.

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.

withE

public JsonWebKey withE(byte[] e)

Set the RSA public exponent value.

Parameters:

e - RSA public exponent value to set

Returns:

the JsonWebKey object itself.

withK

public JsonWebKey withK(byte[] k)

Set the Symmetric key value.

Parameters:

k - the symmetric key value to set.

Returns:

the JsonWebKey object itself.

withKeyOps

public JsonWebKey withKeyOps(List keyOps)

Set the key operations value.

Parameters:

keyOps - the key operations value to set

Returns:

the JsonWebKey object itself.

withKid

public JsonWebKey withKid(String kid)

Set the key identifier value.

Parameters:

kid - the key identifier

Returns:

the JsonWebKey object itself.

withKty

public JsonWebKey withKty(JsonWebKeyType kty)

Set the key type value.

Parameters:

kty - the key type

Returns:

the JsonWebKey object itself.

withN

public JsonWebKey withN(byte[] n)

Set the RSA modulus value.

Parameters:

n - the RSA modulus value to set

Returns:

the JsonWebKey object itself.

withP

public JsonWebKey withP(byte[] p)

Set the RSA secret prime value.

Parameters:

p - the RSA secret prime value.

Returns:

the JsonWebKey object itself.

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.

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.

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.

Applies to