Search in sources :

Example 1 with HostTrustResponse

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));
}
Also used : HostTrustResponse(com.intel.mtwilson.datatypes.HostTrustResponse) Hostname(com.intel.mtwilson.util.net.Hostname) ApiClient(com.intel.mtwilson.ApiClient)

Example 2 with HostTrustResponse

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;
}
Also used : TxtHostRecord(com.intel.mtwilson.datatypes.TxtHostRecord) HostDetailsEntityVO(com.intel.mountwilson.datamodel.HostDetailsEntityVO) HostTrustResponse(com.intel.mtwilson.datatypes.HostTrustResponse) TrustAssertion(com.intel.mtwilson.saml.TrustAssertion) HostTrustAssertion(com.intel.mtwilson.saml.TrustAssertion.HostTrustAssertion) Hostname(com.intel.mtwilson.util.net.Hostname) TrustedHostVO(com.intel.mountwilson.datamodel.TrustedHostVO) HostTrustAssertion(com.intel.mtwilson.saml.TrustAssertion.HostTrustAssertion) ApiException(com.intel.mtwilson.ApiException) SignatureException(java.security.SignatureException) IOException(java.io.IOException) DemoPortalException(com.intel.mountwilson.common.DemoPortalException)

Aggregations

HostTrustResponse (com.intel.mtwilson.datatypes.HostTrustResponse)2 Hostname (com.intel.mtwilson.util.net.Hostname)2 DemoPortalException (com.intel.mountwilson.common.DemoPortalException)1 HostDetailsEntityVO (com.intel.mountwilson.datamodel.HostDetailsEntityVO)1 TrustedHostVO (com.intel.mountwilson.datamodel.TrustedHostVO)1 ApiClient (com.intel.mtwilson.ApiClient)1 ApiException (com.intel.mtwilson.ApiException)1 TxtHostRecord (com.intel.mtwilson.datatypes.TxtHostRecord)1 TrustAssertion (com.intel.mtwilson.saml.TrustAssertion)1 HostTrustAssertion (com.intel.mtwilson.saml.TrustAssertion.HostTrustAssertion)1 IOException (java.io.IOException)1 SignatureException (java.security.SignatureException)1