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
public class KeystoreCredential
- extends AbstractX509Credential
Wraps a Java KeyStore in form suitable for use in JSSE.
- Author:
- K. Benedyczak
Constructor Summary |
KeystoreCredential(String keystorePath,
char[] storePasswd,
char[] keyPasswd,
String keyAlias,
String storeType)
Reads a Java KeyStore to provide an interface suitable to use it
in JSSE. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
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 read
KeyStoreException
- if the keystore can not be parsed or if passwords are incorrect
loadKeystore
protected KeyStore loadKeystore(String keystorePath,
char[] storePasswd,
String storeType)
throws KeyStoreException,
IOException
- Throws:
KeyStoreException
IOException
checkKeystore
protected String checkKeystore(KeyStore ks,
char[] keyPasswd,
String keyAlias)
throws KeyStoreException
- Throws:
KeyStoreException
getDefaultKeyAlias
protected String getDefaultKeyAlias(KeyStore keystore)
throws KeyStoreException
- Throws:
KeyStoreException
createSingleKeyView
protected void createSingleKeyView(KeyStore original,
String alias,
char[] password)
autodetectType
public static String autodetectType(String ksPath,
char[] ksPassword)
throws IOException,
KeyStoreException
- Tries to autodetect keystore type.
- Parameters:
ksPath
- ksPassword
-
- Returns:
- Detected type
- Throws:
IOException
- if error occurred when reading the file
KeyStoreException
- if autodetection failed
Copyright © 2012-2013 European Middleware Initiative. All Rights Reserved.