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;
}
Aggregations