18 package org.turro.elephant.impl.security;
20 import java.io.FileInputStream;
21 import java.io.IOException;
22 import java.security.KeyStore;
23 import java.security.KeyStoreException;
24 import java.security.NoSuchAlgorithmException;
25 import java.security.PrivateKey;
26 import java.security.UnrecoverableKeyException;
27 import java.security.cert.Certificate;
28 import java.security.cert.CertificateException;
29 import java.util.logging.Level;
30 import java.util.logging.Logger;
31 import org.turro.elephant.context.ElephantContext;
32 import org.turro.elephant.impl.abstracts.AbstractImplementation;
40 private PrivateKey key;
41 private Certificate[] chain;
57 private void initCertificate() {
61 KeyStore ks = KeyStore.getInstance((String)
getAttributes().
get(
"storeType"));
62 ks.load(
new FileInputStream((String)
getAttributes().
get(
"storeFile")), password.toCharArray());
63 String alias = (String) ks.aliases().nextElement();
64 key = (PrivateKey) ks.getKey(alias, password.toCharArray());
65 chain = ks.getCertificateChain(alias);
66 }
catch (IOException ex) {
67 Logger.getLogger(CertificateStore.class.getName()).log(Level.SEVERE,
ElephantContext.
logMsg(
null), ex);
68 }
catch (CertificateException | NoSuchAlgorithmException | UnrecoverableKeyException | KeyStoreException ex) {
69 Logger.getLogger(CertificateStore.class.getName()).log(Level.SEVERE,
ElephantContext.
logMsg(
null), ex);
70 }
catch (Exception ex) {
71 Logger.getLogger(CertificateStore.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(
null), ex);
static String logMsg(String msg)
static byte[] decrypt(byte[] value)
KeyValueMap getAttributes()