Package com.sun.identity.saml.xmlsig
Interface KeyProvider
-
@SupportedAll public interface KeyProvider
The classKeyProvider
is an interface that is implemented to retrieve X509Certificates and Private Keys from user data store.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
containsKey(String alias)
Whether the key alias exists in the keystore.Certificate
getCertificate(PublicKey publicKey)
Returns certificate corresponding to the specifiedPublicKey
.String
getCertificateAlias(Certificate cert)
Get the alias name of the first keystore entry whose certificate matches the given certificate.KeyPair
getKeyPair(String certAlias)
KeyStore
getKeyStore()
Returns the keystore instance.PrivateKey
getPrivateKey(String certAlias)
Returnsjava.security.PrivateKey
for the specifiedcertAlias
.PrivateKey
getPrivateKey(String certAlias, String encryptedKeyPass)
Return thePrivateKey
for the specified certAlias and encrypted private key password.PublicKey
getPublicKey(String keyAlias)
Returnsjava.security.PublicKey
for the specifiedkeyAlias
SecretKey
getSecretKey(String certAlias)
Retrieves the secret key for the given certificate alias.X509Certificate
getX509Certificate(String certAlias)
Returnjava.security.cert.X509Certificate
for the specifiedcertAlias
.void
setKey(String storepass, String keypass)
Set the key to access key store database.
-
-
-
Method Detail
-
setKey
void setKey(String storepass, String keypass)
Set the key to access key store database. This method will only need to be called once if the key could not be obtained by other means.- Parameters:
storepass
- password for the key storekeypass
- password for the certificate
-
getX509Certificate
X509Certificate getX509Certificate(String certAlias)
Returnjava.security.cert.X509Certificate
for the specifiedcertAlias
.- Parameters:
certAlias
- Certificate alias name- Returns:
X509Certificate
which matches thecertAlias
, return null if the certificate could not be found.
-
getPublicKey
PublicKey getPublicKey(String keyAlias)
Returnsjava.security.PublicKey
for the specifiedkeyAlias
- Parameters:
keyAlias
- Key alias name- Returns:
PublicKey
which matches thekeyAlias
, return null if thePublicKey
could not be found.
-
getPrivateKey
PrivateKey getPrivateKey(String certAlias)
Returnsjava.security.PrivateKey
for the specifiedcertAlias
.- Parameters:
certAlias
- Certificate alias name- Returns:
PrivateKey
which matches thecertAlias
, return null if the private key could not be found.
-
getSecretKey
SecretKey getSecretKey(String certAlias)
Retrieves the secret key for the given certificate alias.- Parameters:
certAlias
- the certificate alieas- Returns:
- the secret key or returns null if the key does not exist or this key provider does not support secret keys
-
getPrivateKey
PrivateKey getPrivateKey(String certAlias, String encryptedKeyPass)
Return thePrivateKey
for the specified certAlias and encrypted private key password.- Parameters:
certAlias
- Certificate alias nameencryptedKeyPass
- The encrypted keypass to use when getting the private certificate- Returns:
- PrivateKey which matches the certAlias, return null if the private key could not be found.
-
getCertificateAlias
String getCertificateAlias(Certificate cert)
Get the alias name of the first keystore entry whose certificate matches the given certificate.- Parameters:
cert
- Certificate- Returns:
- the (alias) name of the first entry with matching certificate, or null if no such entry exists in this keystore. If the keystore has not been loaded properly, return null as well.
-
getCertificate
Certificate getCertificate(PublicKey publicKey)
Returns certificate corresponding to the specifiedPublicKey
.- Parameters:
publicKey
- Certificate public key- Returns:
- Certificate which matches the
PublicKey
, return null if the Certificate could not be found.
-
getKeyPair
KeyPair getKeyPair(String certAlias)
- Parameters:
certAlias
- Certificate alias name- Returns:
- KeyPair which matches the certAlias, return null if the PrivateKey or PublicKey could not be found.
-
getKeyStore
KeyStore getKeyStore()
Returns the keystore instance.- Returns:
- the keystore instance.
-
containsKey
boolean containsKey(String alias)
Whether the key alias exists in the keystore.- Parameters:
alias
- the key alias- Returns:
- whether the key alias exists
-
-