Interface KeyStore
-
public interface KeyStoreKeymanager interface that handles and stores its cryptographic keys.- Since:
- 1.0.0
- Author:
- Dharmesh Khandelwal
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voiddeleteKey(String alias)Delete key form keystorevoidgenerateAndStoreAsymmetricKey(String alias, String signKeyAlias, CertificateParameters certParams)Asymmetric(keypair) keys will be generated based on the provider specified and Store the keys along with self-signed certificate in provider specific keystorevoidgenerateAndStoreSymmetricKey(String alias)Symmetric key will be generated based on the provider specified and Store the key in provider specific keystoreCertificategenerateCertificate(PrivateKey signPrivateKey, PublicKey publicKey, CertificateParameters certParams, X500Principal signerPrincipal)Creates a certificate for the given public key and signs the certificate with provided private keyList<String>getAllAlias()Lists all the alias names of this keystore.KeyStore.PrivateKeyEntrygetAsymmetricKey(String alias)Get Asymmetric key from keystoreCertificategetCertificate(String alias)Get certificate from keystoreKeygetKey(String alias)Returns the key associated with the given alias, using the given password to recover it.StringgetKeystoreProviderName()Gets the keyStore provider name.PrivateKeygetPrivateKey(String alias)Get private key from keystorePublicKeygetPublicKey(String alias)Get public key from keystoreSecretKeygetSymmetricKey(String alias)Get Symmetric key from keystorevoidstoreAsymmetricKey(KeyPair keyPair, String alias, LocalDateTime validityFrom, LocalDateTime validityTo)Store keypair in keystorevoidstoreCertificate(String alias, PrivateKey privateKey, Certificate certificate)Stores the given trusted certificate to the given aliasvoidstoreSymmetricKey(SecretKey secretKey, String alias)Store symmetric key in keystore
-
-
-
Method Detail
-
getPrivateKey
PrivateKey getPrivateKey(String alias)
Get private key from keystore- Parameters:
alias- the alias- Returns:
- The private key
-
getPublicKey
PublicKey getPublicKey(String alias)
Get public key from keystore- Parameters:
alias- the alias- Returns:
- The public key
-
getCertificate
Certificate getCertificate(String alias)
Get certificate from keystore- Parameters:
alias- the alias- Returns:
- The certificate
-
getSymmetricKey
SecretKey getSymmetricKey(String alias)
Get Symmetric key from keystore- Parameters:
alias- the alias- Returns:
- The Symmetric key
-
getAsymmetricKey
KeyStore.PrivateKeyEntry getAsymmetricKey(String alias)
Get Asymmetric key from keystore- Parameters:
alias- the alias- Returns:
- The asymmetric key
-
getAllAlias
List<String> getAllAlias()
Lists all the alias names of this keystore.- Returns:
- list of all alias in keystore
-
getKey
Key getKey(String alias)
Returns the key associated with the given alias, using the given password to recover it. The key must have been associated with the alias by a call to setKeyEntry, or by a call to setEntry with a PrivateKeyEntry or SecretKeyEntry.- Parameters:
alias- the alias- Returns:
- the requested key, or null if the given alias does not exist or does not identify a key-related entry
-
storeSymmetricKey
void storeSymmetricKey(SecretKey secretKey, String alias)
Store symmetric key in keystore- Parameters:
secretKey- the secret keyalias- the alias
-
storeAsymmetricKey
void storeAsymmetricKey(KeyPair keyPair, String alias, LocalDateTime validityFrom, LocalDateTime validityTo)
Store keypair in keystore- Parameters:
keyPair- the keypairalias- the aliasvalidityFrom- validityFromvalidityTo- validityTo
-
generateAndStoreSymmetricKey
void generateAndStoreSymmetricKey(String alias)
Symmetric key will be generated based on the provider specified and Store the key in provider specific keystore- Parameters:
secretKey- the secret keyalias- the alias
-
generateAndStoreAsymmetricKey
void generateAndStoreAsymmetricKey(String alias, String signKeyAlias, CertificateParameters certParams)
Asymmetric(keypair) keys will be generated based on the provider specified and Store the keys along with self-signed certificate in provider specific keystore- Parameters:
alias- the aliassignKeyAlias- alias used to sign the generated keycertParams- required Certificate Parameters to create the certificate
-
deleteKey
void deleteKey(String alias)
Delete key form keystore- Parameters:
alias- the alias
-
storeCertificate
void storeCertificate(String alias, PrivateKey privateKey, Certificate certificate)
Stores the given trusted certificate to the given alias- Parameters:
alias- the aliasprivateKey- privateKey reference of the provided certificatecertificate- Certificate to be stored
-
generateCertificate
Certificate generateCertificate(PrivateKey signPrivateKey, PublicKey publicKey, CertificateParameters certParams, X500Principal signerPrincipal)
Creates a certificate for the given public key and signs the certificate with provided private key- Parameters:
signPrivateKey- privateKey used to create certificatepublicKey- publicKey to be signed to create certificatecertParams- required Certificate Parameters to create the certificatesignerPrincipal- Signer Principal- Returns:
- returns the generated certificate.
-
getKeystoreProviderName
String getKeystoreProviderName()
Gets the keyStore provider name.
-
-