use of com.intel.mountwilson.datamodel.TrustedHostVO in project OpenAttestation by OpenAttestation.
the class ConverterUtil method getTrustedHostVoFromHostTrustResponseAndErrorMessage.
public static TrustedHostVO getTrustedHostVoFromHostTrustResponseAndErrorMessage(String hostName, String errorMessage) {
TrustedHostVO hostVO = new TrustedHostVO();
hostVO.setHostName(hostName);
hostVO.setBiosStatus(TDPConfig.getConfiguration().getString(HelperConstant.IMAGE_TRUSTED_UNKNOWN));
hostVO.setVmmStatus(TDPConfig.getConfiguration().getString(HelperConstant.IMAGE_TRUSTED_UNKNOWN));
hostVO.setOverAllStatus(TDPConfig.getConfiguration().getString(HelperConstant.IMAGE_TRUSTED_UNKNOWN));
hostVO.setOverAllStatusBoolean(false);
hostVO.setErrorMessage(errorMessage);
// Bug: 445 - To shown the updated date when the host is in the unknown state
hostVO.setUpdatedOn(new SimpleDateFormat("EEE MMM d HH:MM:ss z yyyy").format(new Date()));
hostVO.setErrorCode(1);
return hostVO;
}
use of com.intel.mountwilson.datamodel.TrustedHostVO in project OpenAttestation by OpenAttestation.
the class DemoPortalServicesImpl method getSingleHostTrust.
/**
* This Method is used to get Trust Status for Single Host.
*
* @param hostName
* @param apiClientServices
* @param trustedCertificates
* @return
* @throws DemoPortalException
*/
@Override
public TrustedHostVO getSingleHostTrust(String hostName, AttestationService apiClientServices, X509Certificate[] trustedCertificates, boolean forceVerify) throws DemoPortalException {
TrustedHostVO hostVO = null;
HostDetailsEntityVO hostDetailsEntityVO = new HostDetailsEntityVO();
hostDetailsEntityVO.setHostName(hostName);
String xmloutput = null;
HostTrustResponse hostTrustResponse = null;
try {
log.info("Getting trust Information for Host " + hostName);
//xmloutput = apiClientServices.getSamlForHost(new Hostname(hostName), false);
// forceVerify=false when loading dashboard, it is true when refreshing host (Refresh button)
xmloutput = apiClientServices.getSamlForHost(new Hostname(hostName), forceVerify);
TrustAssertion trustAssertion = new TrustAssertion(trustedCertificates, xmloutput);
HostTrustAssertion hostTrustAssertion = trustAssertion.getTrustAssertion(hostName);
//Set<Hostname> hostnames = new HashSet<Hostname>();
//hostnames.add(new Hostname(hostName));
//xmloutput = ConverterUtil.formateXMLString(apiClientServices.getSamlForMultipleHosts(hostnames, false));
hostTrustResponse = apiClientServices.getHostTrust(new Hostname(hostDetailsEntityVO.getHostName()));
List<TxtHostRecord> hosts = apiClientServices.queryForHosts(hostDetailsEntityVO.getHostName());
TxtHostRecord txtHostRecord = null;
for (TxtHostRecord record : hosts) {
if (record.HostName.equals(hostDetailsEntityVO.getHostName())) {
txtHostRecord = record;
}
}
hostVO = ConverterUtil.getTrustedHostVoFromHostTrustResponseAndTxtHostRecord(hostTrustResponse, txtHostRecord, hostTrustAssertion);
} catch (Exception e) {
hostVO = ConverterUtil.getTrustedHostVoFromHostTrustResponseAndErrorMessage(hostName, e.getMessage());
}
return hostVO;
}
use of com.intel.mountwilson.datamodel.TrustedHostVO in project OpenAttestation by OpenAttestation.
the class ConverterUtil method getTrustedHostVoFromHostTrustResponseAndTxtHostRecord.
public static TrustedHostVO getTrustedHostVoFromHostTrustResponseAndTxtHostRecord(HostTrustResponse hostTrustResponse, TxtHostRecord txtHostRecord, TrustAssertion.HostTrustAssertion hostTrustAssertion) {
TrustedHostVO hostVO = new TrustedHostVO();
hostVO.setHostName(hostTrustResponse.hostname.toString());
if (hostTrustResponse.trust.bios) {
hostVO.setBiosStatus(TDPConfig.getConfiguration().getString(HelperConstant.IMAGE_TRUSTED_TRUE));
} else {
hostVO.setBiosStatus(TDPConfig.getConfiguration().getString(HelperConstant.IMAGE_TRUSTED_FALSE));
}
if (hostTrustResponse.trust.vmm) {
hostVO.setVmmStatus(TDPConfig.getConfiguration().getString(HelperConstant.IMAGE_TRUSTED_TRUE));
} else {
hostVO.setVmmStatus(TDPConfig.getConfiguration().getString(HelperConstant.IMAGE_TRUSTED_FALSE));
}
if (hostTrustResponse.trust.asset_tag) {
hostVO.setAssetTagStatus(TDPConfig.getConfiguration().getString(HelperConstant.IMAGE_TRUSTED_TRUE));
// We will get the asset tag specific attributes here
StringBuilder atdBuilder = new StringBuilder();
Set<String> attributeNames = hostTrustAssertion.getAttributeNames();
for (String attrName : attributeNames) {
if (attrName.startsWith("ATAG") && !attrName.contains("UUID")) {
atdBuilder.append(hostTrustAssertion.getStringAttribute(attrName) + "\n");
}
}
hostVO.setAssetTagDetails(atdBuilder.toString());
} else {
hostVO.setAssetTagStatus(TDPConfig.getConfiguration().getString(HelperConstant.IMAGE_TRUSTED_FALSE));
hostVO.setAssetTagDetails("Un-Trusted");
}
if (hostTrustResponse.trust.bios && hostTrustResponse.trust.vmm) /*&& hostTrustResponse.trust.asset_tag*/
{
hostVO.setOverAllStatus(TDPConfig.getConfiguration().getString(HelperConstant.IMAGE_TRUSTED_TRUE));
hostVO.setOverAllStatusBoolean(true);
} else {
hostVO.setOverAllStatus(TDPConfig.getConfiguration().getString(HelperConstant.IMAGE_TRUSTED_FALSE));
hostVO.setOverAllStatusBoolean(false);
}
doMoreThingsWithHostVmmName(hostVO, txtHostRecord);
// current json api does not return the timestamp of the latest trust status, so instead we implement fix for bug #445 and show the current time
// Bug: 457 - Refresh button is not updating the time stamp
// hostVO.setUpdatedOn(null);
// Bug: 445 - To shown the updated date when the host is in the unknown state
hostVO.setUpdatedOn(new SimpleDateFormat("EEE MMM d HH:MM:ss z yyyy").format(new Date()));
return hostVO;
}
Aggregations