Search in sources :

Example 1 with KeystoreEngine

use of com.emc.storageos.security.keystore.impl.KeystoreEngine in project coprhd-controller by CoprHD.

the class CassandraKeystoreHandler method saveTrustStore.

public void saveTrustStore() throws Exception {
    log.info("Trying to generate truststore {}", trustStoreFile);
    KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
    ks.load(null, password);
    DistributedLoadKeyStoreParam loadStoreParam;
    loadStoreParam = new DistributedLoadKeyStoreParam();
    loadStoreParam.setCoordinator(coordinator);
    KeystoreEngine ksEngine = new KeystoreEngine();
    ksEngine.engineLoad(loadStoreParam);
    Enumeration<String> allAliases = ksEngine.engineAliases();
    while (allAliases.hasMoreElements()) {
        String alias = (String) allAliases.nextElement();
        KeyStore.TrustedCertificateEntry trustedCertEntry = new KeyStore.TrustedCertificateEntry(keystore.getCertificate(alias));
        ks.setEntry(alias, trustedCertEntry, null);
    }
    ks.store(new FileOutputStream(trustStoreFile), password);
    setFilePermission(trustStoreFile);
    log.info("The truststore file {} is generated successfully.", trustStoreFile);
}
Also used : DistributedLoadKeyStoreParam(com.emc.storageos.security.keystore.impl.DistributedLoadKeyStoreParam) FileOutputStream(java.io.FileOutputStream) KeyStore(java.security.KeyStore) KeystoreEngine(com.emc.storageos.security.keystore.impl.KeystoreEngine)

Aggregations

DistributedLoadKeyStoreParam (com.emc.storageos.security.keystore.impl.DistributedLoadKeyStoreParam)1 KeystoreEngine (com.emc.storageos.security.keystore.impl.KeystoreEngine)1 FileOutputStream (java.io.FileOutputStream)1 KeyStore (java.security.KeyStore)1