Package com.azure.security.keyvault.jca
Class KeyVaultKeyStore
java.lang.Object
java.security.KeyStoreSpi
com.azure.security.keyvault.jca.KeyVaultKeyStore
The Azure Key Vault implementation of the KeyStoreSpi.
- See Also:
 
- 
Field Summary
Fields - 
Constructor Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptionLists all the alias names of this keystore.booleanengineContainsAlias(String alias) Checks if the given alias exists in this keystore.voidengineDeleteEntry(String alias) Deletes the entry identified by the given alias from this keystore.booleanengineEntryInstanceOf(String alias, Class<? extends KeyStore.Entry> entryClass) Determines if the keystoreEntryfor the specifiedaliasis an instance or subclass of the specifiedentryClass.engineGetCertificate(String alias) Get the certificate associated with the given alias.Get the (alias) name of the first keystore entry whose certificate matches the given certificate.engineGetCertificateChain(String alias) Get the certificate chain associated with the given alias.engineGetCreationDate(String alias) Get the creation date of the entry identified by the given alias.engineGetEntry(String alias, KeyStore.ProtectionParameter protParam) Gets aKeyStore.Entryfor the specified alias with the specified protection parameter.engineGetKey(String alias, char[] password) Get key associated with the given alias.booleanengineIsCertificateEntry(String alias) Check whether the entry identified by the given alias contains a trusted certificate.booleanengineIsKeyEntry(String alias) Check whether the entry identified by the given alias is a key-related.voidengineLoad(InputStream stream, char[] password) Loads the keystore from the given input stream.voidLoads the keystore using the givenKeyStore.LoadStoreParameter.voidengineSetCertificateEntry(String alias, Certificate certificate) Assigns the given certificate to the given alias.voidengineSetEntry(String alias, KeyStore.Entry entry, KeyStore.ProtectionParameter protParam) Saves aKeyStore.Entryunder the specified alias.voidengineSetKeyEntry(String alias, byte[] key, Certificate[] chain) Assigns the given key (that has already been protected) to the given alias.voidengineSetKeyEntry(String alias, Key key, char[] password, Certificate[] chain) Assigns the given key to the given alias, protecting it with the given password.intRetrieves the number of entries in this keystore.voidengineStore(OutputStream stream, char[] password) Stores this keystore to the given output stream, and protects its integrity with the given password.voidStores this keystore using the given.static KeyStoreget key vault key store by system propertyMethods inherited from class java.security.KeyStoreSpi
engineGetAttributes, engineProbe 
- 
Field Details
- 
KEY_STORE_TYPE
Stores the key-store name.- See Also:
 
 - 
ALGORITHM_NAME
Stores the algorithm name.- See Also:
 
 
 - 
 - 
Constructor Details
- 
KeyVaultKeyStore
public KeyVaultKeyStore()Constructor.The constructor uses System.getProperty for
azure.keyvault.uri,azure.keyvault.tenantId,azure.keyvault.clientId,azure.keyvault.clientSecretandazure.keyvault.managedIdentityto initialize the Key Vault client. 
 - 
 - 
Method Details
- 
getKeyVaultKeyStoreBySystemProperty
public static KeyStore getKeyVaultKeyStoreBySystemProperty() throws CertificateException, NoSuchAlgorithmException, KeyStoreException, IOExceptionget key vault key store by system property- Returns:
 - KeyVault key store
 - Throws:
 CertificateException- if any of the certificates in the keystore could not be loadedNoSuchAlgorithmException- when algorithm is unavailable.KeyStoreException- when no Provider supports a KeyStoreSpi implementation for the specified typeIOException- when an I/O error occurs.
 - 
engineAliases
Lists all the alias names of this keystore.- Specified by:
 engineAliasesin classKeyStoreSpi- Returns:
 - enumeration of the alias names
 
 - 
engineContainsAlias
Checks if the given alias exists in this keystore.- Specified by:
 engineContainsAliasin classKeyStoreSpi- Parameters:
 alias- the alias name- Returns:
 - true if the alias exists, false otherwise
 
 - 
engineDeleteEntry
Deletes the entry identified by the given alias from this keystore.- Specified by:
 engineDeleteEntryin classKeyStoreSpi- Parameters:
 alias- the alias name
 - 
engineEntryInstanceOf
Determines if the keystoreEntryfor the specifiedaliasis an instance or subclass of the specifiedentryClass.- Overrides:
 engineEntryInstanceOfin classKeyStoreSpi- Parameters:
 alias- the alias nameentryClass- the entry class- Returns:
 - true if the keystore 
Entryfor the specifiedaliasis an instance or subclass of the specifiedentryClass, false otherwise 
 - 
engineGetCertificate
Get the certificate associated with the given alias.- Specified by:
 engineGetCertificatein classKeyStoreSpi- Parameters:
 alias- the alias name- Returns:
 - the certificate, or null if the given alias does not exist or does not contain a certificate
 
 - 
engineGetCertificateAlias
Get the (alias) name of the first keystore entry whose certificate matches the given certificate.- Specified by:
 engineGetCertificateAliasin classKeyStoreSpi- 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
Get the certificate chain associated with the given alias.- Specified by:
 engineGetCertificateChainin classKeyStoreSpi- 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
Get the creation date of the entry identified by the given alias.- Specified by:
 engineGetCreationDatein classKeyStoreSpi- 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) throws KeyStoreException, NoSuchAlgorithmException, UnrecoverableEntryException Gets aKeyStore.Entryfor the specified alias with the specified protection parameter.- Overrides:
 engineGetEntryin classKeyStoreSpi- Parameters:
 alias- the alias nameprotParam- the protParam- Returns:
 - the 
KeyStore.Entryfor the specified alias,ornullif there is no such entry - Throws:
 KeyStoreException- if the operation failedNoSuchAlgorithmException- if the algorithm for recovering the entry cannot be foundUnrecoverableEntryException- if the specifiedprotParamwere insufficient or invalid
 - 
engineGetKey
Get key associated with the given alias.- Specified by:
 engineGetKeyin classKeyStoreSpi- Parameters:
 alias- the alias namepassword- 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
Check whether the entry identified by the given alias contains a trusted certificate.- Specified by:
 engineIsCertificateEntryin classKeyStoreSpi- Parameters:
 alias- the alias name- Returns:
 - true if the entry identified by the given alias contains a trusted certificate, false otherwise
 
 - 
engineIsKeyEntry
Check whether the entry identified by the given alias is a key-related.- Specified by:
 engineIsKeyEntryin classKeyStoreSpi- 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
Loads the keystore using the givenKeyStore.LoadStoreParameter.- Overrides:
 engineLoadin classKeyStoreSpi- Parameters:
 param- theKeyStore.LoadStoreParameterthat specifies how to load the keystore, which may benull
 - 
engineLoad
Loads the keystore from the given input stream.- Specified by:
 engineLoadin classKeyStoreSpi- Parameters:
 stream- the input stream from which the keystore is loaded,ornullpassword- the password
 - 
engineSetCertificateEntry
Assigns the given certificate to the given alias.- Specified by:
 engineSetCertificateEntryin classKeyStoreSpi- Parameters:
 alias- the alias namecertificate- the certificate
 - 
engineSetEntry
public void engineSetEntry(String alias, KeyStore.Entry entry, KeyStore.ProtectionParameter protParam) throws KeyStoreException Saves aKeyStore.Entryunder the specified alias. The specified protection parameter is used to protect theEntry.- Overrides:
 engineSetEntryin classKeyStoreSpi- Parameters:
 alias- the alias nameentry- the entryprotParam- the protParam- Throws:
 KeyStoreException- if this operation fails
 - 
engineSetKeyEntry
Assigns the given key to the given alias, protecting it with the given password.- Specified by:
 engineSetKeyEntryin classKeyStoreSpi- Parameters:
 alias- the alias namekey- the key to be associated with the aliaspassword- the password to protect the keychain- the certificate chain
 - 
engineSetKeyEntry
Assigns the given key (that has already been protected) to the given alias.- Specified by:
 engineSetKeyEntryin classKeyStoreSpi- Parameters:
 alias- the alias namekey- the keychain- the certificate chain
 - 
engineSize
public int engineSize()Retrieves the number of entries in this keystore.- Specified by:
 engineSizein classKeyStoreSpi- Returns:
 - the number of entries in this keystore
 
 - 
engineStore
Stores this keystore to the given output stream, and protects its integrity with the given password.- Specified by:
 engineStorein classKeyStoreSpi- Parameters:
 stream- the output stream to which this keystore is writtenpassword- the password to generate the keystore integrity check
 - 
engineStore
Stores this keystore using the given.- Overrides:
 engineStorein classKeyStoreSpi- Parameters:
 param- the param
 
 -