你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

JsonWebKey Class

  • java.lang.Object
    • com.azure.security.keyvault.keys.models.JsonWebKey

Implements

public class JsonWebKey
implements JsonSerializable<JsonWebKey>

Constructor Summary

Constructor Description
JsonWebKey()

Creates a new instance of JsonWebKey.

Method Summary

Modifier and Type Method and Description
void clearMemory()

Clear key materials.

boolean equals(JsonWebKey jwk)

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

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

Converts AES key to JSON web key.

static JsonWebKey fromAes(SecretKey secretKey, List<KeyOperation> keyOperations)

Converts AES key to JSON web key.

static JsonWebKey fromEc(KeyPair keyPair, Provider provider)

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 fromJson(JsonReader jsonReader)

Reads a JSON stream into a JsonWebKey.

static JsonWebKey fromRsa(KeyPair keyPair)

Converts RSA key pair to JSON web key.

static JsonWebKey fromRsa(KeyPair keyPair, List<KeyOperation> keyOperations)

Converts RSA key pair to JSON web key.

KeyCurveName getCurveName()

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.

String getId()

Get the kid value.

byte[] getK()

Get Symmetric key value.

List<KeyOperation> getKeyOps()

Get the immutable key operations list.

KeyType getKeyType()

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.

boolean hasPrivateKey()

Verifies whether the JsonWebKey has private key.

int hashCode()
boolean isValid()

Verifies whether the JsonWebKey is valid.

JsonWebKey setCurveName(KeyCurveName crv)

Set the crv value.

JsonWebKey setD(byte[] d)

Set the d value.

JsonWebKey setDp(byte[] dp)

Set RSA Private Key Parameter value.

JsonWebKey setDq(byte[] dq)

Set RSA Private Key Parameter value .

JsonWebKey setE(byte[] e)

Set the e value.

JsonWebKey setId(String keyId)

Set the key identifier value.

JsonWebKey setK(byte[] k)

Set the Symmetric key value.

JsonWebKey setKeyOps(List<KeyOperation> keyOps)

Set the keyOps value.

JsonWebKey setKeyType(KeyType keyType)

Set the key type value.

JsonWebKey setN(byte[] n)

Set the n value.

JsonWebKey setP(byte[] p)

Set the RSA secret prime value.

JsonWebKey setQ(byte[] q)

Set the RSA secret prime, with p < q value.

JsonWebKey setQi(byte[] qi)

Set RSA Private Key Parameter value.

JsonWebKey setT(byte[] t)

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

JsonWebKey setX(byte[] x)

Set the x value.

JsonWebKey setY(byte[] y)

Set the y value.

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.

JsonWriter toJson(JsonWriter jsonWriter)
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()

Methods inherited from java.lang.Object

Constructor Details

JsonWebKey

public JsonWebKey()

Creates a new instance of JsonWebKey.

Method Details

clearMemory

public void clearMemory()

Clear key materials.

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)

Overrides:

JsonWebKey.equals(Object obj)

Parameters:

obj

fromAes

public static JsonWebKey fromAes(SecretKey secretKey)

Converts AES key to JSON web key.

Parameters:

secretKey - The AES key

Returns:

the JSON web key, converted from AES key.

fromAes

public static JsonWebKey fromAes(SecretKey secretKey, List keyOperations)

Converts AES key to JSON web key.

Parameters:

secretKey - The AES key
keyOperations - The key operations to set

Returns:

the JSON web key, converted from AES key.

fromEc

public static JsonWebKey fromEc(KeyPair keyPair, Provider provider)

Converts EC key pair to JSON web key.

Parameters:

keyPair - The EC key pair
provider - The Java security provider

Returns:

the JSON web key, converted from EC key pair.

fromEc

public static JsonWebKey fromEc(KeyPair keyPair, Provider provider, List keyOperations)

Converts EC key pair to JSON web key.

Parameters:

keyPair - The EC key pair
provider - The Java security provider
keyOperations - The key operations to set.

Returns:

the JSON web key, converted from EC key pair.

fromJson

public static JsonWebKey fromJson(JsonReader jsonReader)

Reads a JSON stream into a JsonWebKey.

Parameters:

jsonReader - The JsonReader being read.

Returns:

An instance of JsonWebKey that the JSON stream represented, may return null.

Throws:

IOException

- If a JsonWebKey fails to be read from the jsonReader.

fromRsa

public static JsonWebKey fromRsa(KeyPair keyPair)

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

public static JsonWebKey fromRsa(KeyPair keyPair, List keyOperations)

Converts RSA key pair to JSON web key.

Parameters:

keyPair - Tbe RSA key pair
keyOperations - The key operations to set on the key

Returns:

the JSON web key, converted from RSA key pair.

getCurveName

public KeyCurveName getCurveName()

Get the crv value.

Returns:

the crv value

getD

public byte[] getD()

Get the d value.

Returns:

the d value

getDp

public byte[] getDp()

Get the RSA Private Key Parameter value.

Returns:

the RSA Private Key Parameter value.

getDq

public byte[] getDq()

Get the RSA Private Key Parameter value.

Returns:

the RSA Private Key Parameter value.

getE

public byte[] getE()

Get the e value.

Returns:

the e value

getId

public String getId()

Get the kid value.

Returns:

the kid value

getK

public byte[] getK()

Get Symmetric key value.

Returns:

the symmetric key value.

getKeyOps

public List getKeyOps()

Get the immutable key operations list. The list cannot be modified.

Returns:

the key operations list

getKeyType

public KeyType getKeyType()

Get the kty value.

Returns:

the kty value

getN

public byte[] getN()

Get the n value.

Returns:

the n value

getP

public byte[] getP()

Get the RSA secret prime value.

Returns:

the RSA secret prime value.

getQ

public byte[] getQ()

Get RSA secret prime, with p < q value.

Returns:

the RSA secret prime, with p < q value.

getQi

public byte[] getQi()

Get the RSA Private Key Parameter value.

Returns:

the RSA Private Key Parameter value.

getT

public byte[] getT()

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

Returns:

HSM Token, used with Bring Your Own Key.

getX

public byte[] getX()

Get the x value.

Returns:

the x value

getY

public byte[] getY()

Get the y value.

Returns:

the y value

hasPrivateKey

public boolean hasPrivateKey()

Verifies whether the JsonWebKey has private key.

Returns:

true if the JsonWebKey has private key; false otherwise.

hashCode

public int hashCode()

Overrides:

JsonWebKey.hashCode()

isValid

public boolean isValid()

Verifies whether the JsonWebKey is valid.

Returns:

true if the JsonWebKey is valid; false otherwise.

setCurveName

public JsonWebKey setCurveName(KeyCurveName crv)

Set the crv value.

Parameters:

crv - The crv value to set

Returns:

the JsonWebKey object itself.

setD

public JsonWebKey setD(byte[] d)

Set the d value.

Parameters:

d - The d value to set

Returns:

the JsonWebKey object itself.

setDp

public JsonWebKey setDp(byte[] dp)

Set RSA Private Key Parameter value.

Parameters:

dp - The RSA Private Key Parameter value to set.

Returns:

the JsonWebKey object itself.

setDq

public JsonWebKey setDq(byte[] dq)

Set RSA Private Key Parameter value .

Parameters:

dq - The RSA Private Key Parameter value to set.

Returns:

the JsonWebKey object itself.

setE

public JsonWebKey setE(byte[] e)

Set the e value.

Parameters:

e - The e value to set

Returns:

the JsonWebKey object itself.

setId

public JsonWebKey setId(String keyId)

Set the key identifier value.

Parameters:

keyId - The keyId value to set

Returns:

the JsonWebKey object itself.

setK

public JsonWebKey setK(byte[] k)

Set the Symmetric key value.

Parameters:

k - The symmetric key value to set.

Returns:

the JsonWebKey object itself.

setKeyOps

public JsonWebKey setKeyOps(List keyOps)

Set the keyOps value.

Parameters:

keyOps - The keyOps value to set

Returns:

the JsonWebKey object itself.

setKeyType

public JsonWebKey setKeyType(KeyType keyType)

Set the key type value.

Parameters:

keyType - The key type

Returns:

the JsonWebKey object itself.

setN

public JsonWebKey setN(byte[] n)

Set the n value.

Parameters:

n - The n value to set

Returns:

the JsonWebKey object itself.

setP

public JsonWebKey setP(byte[] p)

Set the RSA secret prime value.

Parameters:

p - The RSA secret prime value.

Returns:

the JsonWebKey object itself.

setQ

public JsonWebKey setQ(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.

setQi

public JsonWebKey setQi(byte[] qi)

Set RSA Private Key Parameter value.

Parameters:

qi - The RSA Private Key Parameter value to set.

Returns:

the JsonWebKey object itself.

setT

public JsonWebKey setT(byte[] t)

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.

setX

public JsonWebKey setX(byte[] x)

Set the x value.

Parameters:

x - The x value to set

Returns:

the JsonWebKey object itself.

setY

public JsonWebKey setY(byte[] y)

Set the y value.

Parameters:

y - The y value to set

Returns:

the JsonWebKey object itself.

toAes

public SecretKey toAes()

Converts JSON web key to AES key.

Returns:

AES key

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 - The Java security provider

Returns:

EC key pair

toJson

public JsonWriter toJson(JsonWriter jsonWriter)

Parameters:

jsonWriter

Throws:

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()

Overrides:

JsonWebKey.toString()

Applies to