Package eu.emi.security.authn.x509.impl
Class KeystoreCredential
java.lang.Object
eu.emi.security.authn.x509.helpers.AbstractX509Credential
eu.emi.security.authn.x509.impl.KeystoreCredential
- All Implemented Interfaces:
X509Credential
Wraps a Java KeyStore in form suitable for use in JSSE.
- Author:
- K. Benedyczak
-
Field Summary
Fields inherited from class eu.emi.security.authn.x509.helpers.AbstractX509Credential
ALIAS, KEY_PASSWD, ks -
Constructor Summary
ConstructorsConstructorDescriptionKeystoreCredential(String keystorePath, char[] storePasswd, char[] keyPasswd, String keyAlias, String storeType) Reads a Java KeyStore to provide an interface suitable to use it in JSSE. -
Method Summary
Modifier and TypeMethodDescriptionstatic StringautodetectType(String ksPath, char[] ksPassword) Tries to autodetect keystore type.protected StringcheckKeystore(KeyStore ks, char[] keyPasswd, String keyAlias) protected voidcreateSingleKeyView(KeyStore original, String alias, char[] password) protected StringgetDefaultKeyAlias(KeyStore keystore) protected KeyStoreloadKeystore(String keystorePath, char[] storePasswd, String storeType) Methods inherited from class eu.emi.security.authn.x509.helpers.AbstractX509Credential
getCertificate, getCertificateChain, getKey, getKeyAlias, getKeyManager, getKeyPassword, getKeyStore, getSubjectName
-
Constructor Details
-
KeystoreCredential
public KeystoreCredential(String keystorePath, char[] storePasswd, char[] keyPasswd, String keyAlias, String storeType) throws IOException, KeyStoreException Reads a Java KeyStore to provide an interface suitable to use it in JSSE.- Parameters:
keystorePath- keystore pathstorePasswd- keystore passwordkeyPasswd- private key passwordkeyAlias- private key alias or null. In case of null, alias will be autodetected, however this will work only it the keystore contains exactly one key entry.storeType- type of the keystore, "JKS" or "PKCS12". null value is forbidden, but if autodetection is desired the static autodetectType() method of this can be used.- Throws:
IOException- if the keystore can not be readKeyStoreException- if the keystore can not be parsed or if passwords are incorrect
-
-
Method Details
-
loadKeystore
protected KeyStore loadKeystore(String keystorePath, char[] storePasswd, String storeType) throws KeyStoreException, IOException - Throws:
KeyStoreExceptionIOException
-
checkKeystore
protected String checkKeystore(KeyStore ks, char[] keyPasswd, String keyAlias) throws KeyStoreException - Throws:
KeyStoreException
-
getDefaultKeyAlias
- Throws:
KeyStoreException
-
createSingleKeyView
-
autodetectType
public static String autodetectType(String ksPath, char[] ksPassword) throws IOException, KeyStoreException Tries to autodetect keystore type.- Parameters:
ksPath- key store pathksPassword- key store password- Returns:
- Detected type
- Throws:
IOException- if error occurred when reading the fileKeyStoreException- if autodetection failed
-