use of com.adaptris.security.exc.KeystoreException in project interlok by adaptris.
the class X509KeystoreProxy method getCertificateChain.
/**
* Return the certificate specified by the given alias.
*
* @param alias the alias of the Certificate
* @return requested certificate chain, or null if the alias does not
* exist/not a certificate
* @throws AdaptrisSecurityException for any error
*/
public Certificate[] getCertificateChain(String alias) throws AdaptrisSecurityException {
Certificate cert = null;
if (getAliasName().equalsIgnoreCase(alias)) {
cert = certHandler.getCertificate();
} else {
throw new KeystoreException(alias + " not found");
}
Certificate[] certChain = new Certificate[1];
certChain[0] = cert;
return certChain;
}
use of com.adaptris.security.exc.KeystoreException in project interlok by adaptris.
the class CompositeKeystore method load.
/**
* @see KeystoreProxy#load()
*/
public void load() throws AdaptrisSecurityException {
aliasCache = new Hashtable<String, AliasListEntry>();
try {
for (KeystoreLocation k : keystores) {
KeystoreProxy kp = keystoreFactory.create(k);
kp.load();
KeyStore ks = kp.getKeystore();
AliasListEntry kk = new AliasListEntry(kp, k);
if (ks != null) {
for (Enumeration<String> e = kp.getKeystore().aliases(); e.hasMoreElements(); ) {
String key = (String) e.nextElement();
if (!addToAliases(key, kk)) {
logR.warn("{} already exists in keystore group, ignoring {} in {}", key, key, k);
}
}
} else {
String key = k.getAdditionalParams().getProperty(Constants.KEYSTORE_ALIAS);
if (!addToAliases(key, kk)) {
logR.warn("{} already exists in keystore group, ignoring {} in {}", key, key, k);
}
}
}
} catch (GeneralSecurityException e) {
aliasCache = null;
throw new KeystoreException(e);
} catch (IOException e) {
aliasCache = null;
throw new KeystoreException(e);
}
}
use of com.adaptris.security.exc.KeystoreException in project interlok by adaptris.
the class StdSecurityService method getCertificate.
private Certificate getCertificate(String alias) throws AdaptrisSecurityException {
Certificate c = null;
for (Map.Entry<ConfiguredKeystore, KeystoreProxy> set : keystores.entrySet()) {
ConfiguredKeystore ksi = set.getKey();
KeystoreProxy ksm = set.getValue();
if (ksm.containsAlias(alias)) {
if (logR.isDebugEnabled()) {
logR.debug("Certificate Alias " + alias + " found in " + ksi);
}
c = ksm.getCertificate(alias);
break;
}
}
if (c == null) {
throw new KeystoreException("Alias " + alias + " not found in registered keystores");
}
return c;
}
use of com.adaptris.security.exc.KeystoreException in project interlok by adaptris.
the class StdSecurityService method getPrivateKey.
private PrivateKey getPrivateKey(String alias, char[] password) throws AdaptrisSecurityException {
PrivateKey pk = null;
for (Map.Entry<ConfiguredKeystore, KeystoreProxy> set : keystores.entrySet()) {
ConfiguredKeystore ksi = set.getKey();
KeystoreProxy ksm = set.getValue();
if (ksm.containsAlias(alias)) {
pk = ksm.getPrivateKey(alias, password);
if (logR.isDebugEnabled()) {
logR.debug("Private key alias " + alias + " found in " + ksi);
}
break;
}
}
if (pk == null) {
throw new KeystoreException("Private Key Alias " + alias + " not found in registered keystores");
}
return pk;
}
use of com.adaptris.security.exc.KeystoreException in project interlok by adaptris.
the class StdSecurityService method registerKeystore.
/**
* @see SecurityService#registerKeystore(ConfiguredKeystore)
*/
public void registerKeystore(ConfiguredKeystore keystore) throws AdaptrisSecurityException {
try {
KeystoreProxy ksh = keystore.asKeystoreProxy();
keystores.put(keystore, ksh);
logKeystores();
} catch (Exception e) {
throw new KeystoreException(e);
}
}
Aggregations