use of com.intel.mtwilson.datatypes.HostTrustResponse in project OpenAttestation by OpenAttestation.
the class GetHostTrust method execute.
@Override
public void execute(String[] args) throws Exception {
ApiClient api = getClient();
HostTrustResponse response = api.getHostTrust(new Hostname(args[0]));
System.out.println(toJson(response));
}
use of com.intel.mtwilson.datatypes.HostTrustResponse 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;
}
Aggregations