Search in sources :

Example 1 with TrustedHostVO

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;
}
Also used : TrustedHostVO(com.intel.mountwilson.datamodel.TrustedHostVO) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Example 2 with TrustedHostVO

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

Example 3 with TrustedHostVO

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;
}
Also used : TrustedHostVO(com.intel.mountwilson.datamodel.TrustedHostVO) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Aggregations

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