KeyVaultKeyStore Class

  • java.lang.Object
    • java.security.KeyStoreSpi
      • com.azure.security.keyvault.jca.KeyVaultKeyStore

public final class KeyVaultKeyStore
extends KeyStoreSpi

The Azure Key Vault implementation of the KeyStoreSpi.

Field Summary

Modifier and Type Field and Description
static final String ALGORITHM_NAME

Stores the algorithm name.

static final String KEY_STORE_TYPE

Stores the key-store name.

Constructor Summary

Constructor Description
KeyVaultKeyStore()

Constructor.

Method Summary

Modifier and Type Method and Description
Enumeration<String> engineAliases()

Lists all the alias names of this keystore.

boolean engineContainsAlias(String alias)

Checks if the given alias exists in this keystore.

void engineDeleteEntry(String alias)

Deletes the entry identified by the given alias from this keystore.

boolean engineEntryInstanceOf(String alias, Class<? extends KeyStore.Entry> entryClass)

Determines if the keystore Entry for the specified alias is an instance or subclass of the specified entryClass.

Certificate engineGetCertificate(String alias)

Get the certificate associated with the given alias.

String engineGetCertificateAlias(Certificate cert)

Get the (alias) name of the first keystore entry whose certificate matches the given certificate.

Certificate[] engineGetCertificateChain(String alias)

Get the certificate chain associated with the given alias.

Date engineGetCreationDate(String alias)

Get the creation date of the entry identified by the given alias.

java.security.KeyStore.Entry engineGetEntry(String alias, KeyStore.ProtectionParameter protParam)

Gets a KeyStore.Entry for the specified alias with the specified protection parameter.

Key engineGetKey(String alias, char[] password)

Get key associated with the given alias.

boolean engineIsCertificateEntry(String alias)

Check whether the entry identified by the given alias contains a trusted certificate.

boolean engineIsKeyEntry(String alias)

Check whether the entry identified by the given alias is a key-related.

void engineLoad(InputStream stream, char[] password)

Loads the keystore from the given input stream.

void engineLoad(KeyStore.LoadStoreParameter param)

Loads the keystore using the given KeyStore.LoadStoreParameter.

void engineSetCertificateEntry(String alias, Certificate certificate)

Assigns the given certificate to the given alias.

void engineSetEntry(String alias, KeyStore.Entry entry, KeyStore.ProtectionParameter protParam)

Saves a KeyStore.Entry under the specified alias.

void engineSetKeyEntry(String alias, byte[] key, Certificate[] chain)

Assigns the given key (that has already been protected) to the given alias.

void engineSetKeyEntry(String alias, Key key, char[] password, Certificate[] chain)

Assigns the given key to the given alias, protecting it with the given password.

int engineSize()

Retrieves the number of entries in this keystore.

void engineStore(KeyStore.LoadStoreParameter param)

Stores this keystore using the given.

void engineStore(OutputStream stream, char[] password)

Stores this keystore to the given output stream, and protects its integrity with the given password.

static KeyStore getKeyVaultKeyStoreBySystemProperty()

Gets a Key Vault key store configured from a snapshot of the supported system properties.

Methods inherited from java.lang.Object

Methods inherited from java.security.KeyStoreSpi

Field Details

ALGORITHM_NAME

public static final String ALGORITHM_NAME

Stores the algorithm name.

KEY_STORE_TYPE

public static final String KEY_STORE_TYPE

Stores the key-store name.

Constructor Details

KeyVaultKeyStore

public KeyVaultKeyStore()

Constructor.

The constructor uses fromSystemProperties() to capture the supported system properties and initialize all certificate sources from one configuration snapshot.

Method Details

engineAliases

public Enumeration<String> engineAliases()

Lists all the alias names of this keystore.

Overrides:

KeyVaultKeyStore.engineAliases()

Returns:

enumeration of the alias names

engineContainsAlias

public boolean engineContainsAlias(String alias)

Checks if the given alias exists in this keystore.

Overrides:

KeyVaultKeyStore.engineContainsAlias(String alias)

Parameters:

alias - the alias name

Returns:

true if the alias exists, false otherwise

engineDeleteEntry

public void engineDeleteEntry(String alias)

Deletes the entry identified by the given alias from this keystore.

Overrides:

KeyVaultKeyStore.engineDeleteEntry(String alias)

Parameters:

alias - the alias name

engineEntryInstanceOf

public boolean engineEntryInstanceOf(String alias, Class<? extends KeyStore.Entry> entryClass)

Determines if the keystore Entry for the specified alias is an instance or subclass of the specified entryClass.

Overrides:

KeyVaultKeyStore.engineEntryInstanceOf(String alias, Class<? extends KeyStore.Entry> entryClass)

Parameters:

alias - the alias name
entryClass - the entry class

Returns:

true if the keystore Entry for the specified alias is an instance or subclass of the specified entryClass, false otherwise

engineGetCertificate

public Certificate engineGetCertificate(String alias)

Get the certificate associated with the given alias.

Overrides:

KeyVaultKeyStore.engineGetCertificate(String alias)

Parameters:

alias - the alias name

Returns:

the certificate, or null if the given alias does not exist or does not contain a certificate

engineGetCertificateAlias

public String engineGetCertificateAlias(Certificate cert)

Get the (alias) name of the first keystore entry whose certificate matches the given certificate.

Overrides:

KeyVaultKeyStore.engineGetCertificateAlias(Certificate cert)

Parameters:

cert - the certificate to match with.

Returns:

the alias name of the first entry with matching certificate, or null if no such entry exists in this keystore

engineGetCertificateChain

public Certificate[] engineGetCertificateChain(String alias)

Get the certificate chain associated with the given alias.

Overrides:

KeyVaultKeyStore.engineGetCertificateChain(String alias)

Parameters:

alias - the alias name

Returns:

the certificate chain (ordered with the user's certificate first and the root certificate authority last), or null if the given alias does not exist or does not contain a certificate chain

engineGetCreationDate

public Date engineGetCreationDate(String alias)

Get the creation date of the entry identified by the given alias.

Overrides:

KeyVaultKeyStore.engineGetCreationDate(String alias)

Parameters:

alias - the alias name

Returns:

the creation date of this entry, or null if the given alias does not exist

engineGetEntry

public KeyStore.Entry engineGetEntry(String alias, KeyStore.ProtectionParameter protParam)

Gets a KeyStore.Entry for the specified alias with the specified protection parameter.

Overrides:

KeyVaultKeyStore.engineGetEntry(String alias, KeyStore.ProtectionParameter protParam)

Parameters:

alias - the alias name
protParam - the protParam

Returns:

the KeyStore.Entry for the specified alias,or null if there is no such entry

Throws:

engineGetKey

public Key engineGetKey(String alias, char[] password)

Get key associated with the given alias.

Overrides:

KeyVaultKeyStore.engineGetKey(String alias, char[] password)

Parameters:

alias - the alias name
password - the password for recovering the key

Returns:

the requested key, or null if the given alias does not exist or does not identify a key-related entry

engineIsCertificateEntry

public boolean engineIsCertificateEntry(String alias)

Check whether the entry identified by the given alias contains a trusted certificate.

Overrides:

KeyVaultKeyStore.engineIsCertificateEntry(String alias)

Parameters:

alias - the alias name

Returns:

true if the entry identified by the given alias contains a trusted certificate, false otherwise

engineIsKeyEntry

public boolean engineIsKeyEntry(String alias)

Check whether the entry identified by the given alias is a key-related.

Overrides:

KeyVaultKeyStore.engineIsKeyEntry(String alias)

Parameters:

alias - the alias for the keystore entry to be checked

Returns:

true if the entry identified by the given alias is a key-related, false otherwise

engineLoad

public void engineLoad(InputStream stream, char[] password)

Loads the keystore from the given input stream.

Overrides:

KeyVaultKeyStore.engineLoad(InputStream stream, char[] password)

Parameters:

stream - the input stream from which the keystore is loaded,or null
password - the password

engineLoad

public void engineLoad(KeyStore.LoadStoreParameter param)

Loads the keystore using the given KeyStore.LoadStoreParameter. A KeyVaultLoadStoreParameter replaces the complete configuration captured by the constructor.

Overrides:

KeyVaultKeyStore.engineLoad(KeyStore.LoadStoreParameter param)

Parameters:

param - the KeyStore.LoadStoreParameter that specifies how to load the keystore, which may be null

engineSetCertificateEntry

public void engineSetCertificateEntry(String alias, Certificate certificate)

Assigns the given certificate to the given alias.

Overrides:

KeyVaultKeyStore.engineSetCertificateEntry(String alias, Certificate certificate)

Parameters:

alias - the alias name
certificate - the certificate

engineSetEntry

public void engineSetEntry(String alias, KeyStore.Entry entry, KeyStore.ProtectionParameter protParam)

Saves a KeyStore.Entry under the specified alias. The specified protection parameter is used to protect the Entry.

Overrides:

KeyVaultKeyStore.engineSetEntry(String alias, KeyStore.Entry entry, KeyStore.ProtectionParameter protParam)

Parameters:

alias - the alias name
entry - the entry
protParam - the protParam

Throws:

KeyStoreException

- if this operation fails

engineSetKeyEntry

public void engineSetKeyEntry(String alias, byte[] key, Certificate[] chain)

Assigns the given key (that has already been protected) to the given alias.

Overrides:

KeyVaultKeyStore.engineSetKeyEntry(String alias, byte[] key, Certificate[] chain)

Parameters:

alias - the alias name
key - the key
chain - the certificate chain

engineSetKeyEntry

public void engineSetKeyEntry(String alias, Key key, char[] password, Certificate[] chain)

Assigns the given key to the given alias, protecting it with the given password.

Overrides:

KeyVaultKeyStore.engineSetKeyEntry(String alias, Key key, char[] password, Certificate[] chain)

Parameters:

alias - the alias name
key - the key to be associated with the alias
password - the password to protect the key
chain - the certificate chain

engineSize

public int engineSize()

Retrieves the number of entries in this keystore.

Overrides:

KeyVaultKeyStore.engineSize()

Returns:

the number of entries in this keystore

engineStore

public void engineStore(KeyStore.LoadStoreParameter param)

Stores this keystore using the given.

Overrides:

KeyVaultKeyStore.engineStore(KeyStore.LoadStoreParameter param)

Parameters:

param - the param

engineStore

public void engineStore(OutputStream stream, char[] password)

Stores this keystore to the given output stream, and protects its integrity with the given password.

Overrides:

KeyVaultKeyStore.engineStore(OutputStream stream, char[] password)

Parameters:

stream - the output stream to which this keystore is written
password - the password to generate the keystore integrity check

getKeyVaultKeyStoreBySystemProperty

public static KeyStore getKeyVaultKeyStoreBySystemProperty()

Gets a Key Vault key store configured from a snapshot of the supported system properties.

Returns:

The Key Vault key store.

Throws:

CertificateException

- if any of the certificates in the keystore could not be loaded

NoSuchAlgorithmException

- if any of the certificates in the keystore could not be loaded

KeyStoreException

- if any of the certificates in the keystore could not be loaded

IOException

- if any of the certificates in the keystore could not be loaded

Applies to