Search in sources :

Example 1 with VdcCertParam

use of com.emc.storageos.geomodel.VdcCertParam in project coprhd-controller by CoprHD.

the class AbstractVdcTaskOp method genCertListParam.

protected VdcCertListParam genCertListParam(String cmd) {
    log.info("generating certs sync parameter ...");
    VdcCertListParam certsParam = genCertOperationParam(cmd);
    // add certs of the current existing VDCs
    List<VdcCertParam> certs = certsParam.getVdcCerts();
    List<VirtualDataCenter> vdcList = getAllVdc();
    for (VirtualDataCenter vdc : vdcList) {
        if (!vdc.getId().equals(operatedVdc.getId())) {
            log.info("adding cert from vdc {} into sync param...", vdc.getId().toString());
            VdcCertParam certParam = new VdcCertParam();
            certParam.setVdcId(vdc.getId());
            try {
                Certificate cert = null;
                if (myVdc.getId().compareTo(vdc.getId()) == 0) {
                    log.info("it is local vdc {}", vdc.getId().toString());
                    Certificate[] certChain = null;
                    certChain = keystore.getCertificateChain(KeystoreEngine.ViPR_KEY_AND_CERTIFICATE_ALIAS);
                    cert = certChain[0];
                } else {
                    log.info("it is a remote vdc {}", vdc.getId().toString());
                    cert = keystore.getCertificate(vdc.getId().toString());
                }
                certParam.setCertificate(KeyCertificatePairGenerator.getCertificateAsString(cert));
                certs.add(certParam);
            } catch (KeyStoreException ex) {
                log.error("Failed to get key from the keyStore at VDC " + vdc.getLabel());
                throw GeoException.fatals.keyStoreFailure(vdc.getLabel(), ex);
            } catch (CertificateException ex) {
                log.error("Failed to get proper certificate on VDC " + vdc.getLabel());
                throw GeoException.fatals.connectVdcSyncCertFail(vdc.getLabel(), ex);
            }
        }
    }
    return certsParam;
}
Also used : VdcCertParam(com.emc.storageos.geomodel.VdcCertParam) VirtualDataCenter(com.emc.storageos.db.client.model.VirtualDataCenter) CertificateException(java.security.cert.CertificateException) KeyStoreException(java.security.KeyStoreException) VdcCertListParam(com.emc.storageos.geomodel.VdcCertListParam) Certificate(java.security.cert.Certificate)

Aggregations

VirtualDataCenter (com.emc.storageos.db.client.model.VirtualDataCenter)1 VdcCertListParam (com.emc.storageos.geomodel.VdcCertListParam)1 VdcCertParam (com.emc.storageos.geomodel.VdcCertParam)1 KeyStoreException (java.security.KeyStoreException)1 Certificate (java.security.cert.Certificate)1 CertificateException (java.security.cert.CertificateException)1