Search in sources :

Example 1 with TxtHostRecord

use of com.intel.mtwilson.datatypes.TxtHostRecord 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 2 with TxtHostRecord

use of com.intel.mtwilson.datatypes.TxtHostRecord in project OpenAttestation by OpenAttestation.

the class ConverterUtil method getTxtHostFromHostVO.

public static TxtHost getTxtHostFromHostVO(HostDetailsEntityVO dataVO) {
    TxtHostRecord hostRecord = new TxtHostRecord();
    hostRecord.AddOn_Connection_String = dataVO.getvCenterDetails();
    hostRecord.BIOS_Name = dataVO.getBiosName();
    hostRecord.BIOS_Oem = dataVO.getOemName();
    hostRecord.BIOS_Version = dataVO.getBiosBuildNo();
    hostRecord.Description = dataVO.getHostDescription();
    hostRecord.Email = dataVO.getEmailAddress();
    hostRecord.HostName = dataVO.getHostName();
    hostRecord.IPAddress = dataVO.getHostIPAddress();
    hostRecord.Port = Integer.parseInt(dataVO.getHostPort());
    String[] osVMMInfo = dataVO.getVmmName().split(Pattern.quote(HelperConstant.OS_VMM_INFORMATION_SEPERATOR));
    String osNameWithVer = osVMMInfo[0];
    String[] s = osNameWithVer.split(HelperConstant.OS_VERSION_INFORMATION_SEPERATOR);
    String osName = s[0];
    String osVer = "";
    if (s.length == 2) {
        osVer = s[1];
    } else {
        for (int i = 1; i < s.length; i++) {
            osVer += s[i] + " ";
        }
    }
    String hypervisor = osVMMInfo[1];
    hostRecord.VMM_Name = hypervisor;
    hostRecord.VMM_OSName = osName;
    hostRecord.VMM_OSVersion = osVer;
    hostRecord.VMM_Version = dataVO.getVmmBuildNo();
    return new TxtHost(hostRecord);
}
Also used : TxtHostRecord(com.intel.mtwilson.datatypes.TxtHostRecord) TxtHost(com.intel.mtwilson.datatypes.TxtHost)

Example 3 with TxtHostRecord

use of com.intel.mtwilson.datatypes.TxtHostRecord in project OpenAttestation by OpenAttestation.

the class HostBOTest method mockHost.

public TxtHost mockHost() {
    TxtHostRecord hostRecord = new TxtHostRecord();
    HostTrustStatus trustStatus = new HostTrustStatus();
    hostRecord.HostName = SERVER_NAME;
    hostRecord.IPAddress = SERVER_NAME;
    hostRecord.BIOS_Name = "DELL";
    hostRecord.BIOS_Version = "A08";
    hostRecord.BIOS_Oem = "DELL";
    hostRecord.VMM_Name = "XENESX";
    hostRecord.VMM_Version = "4.3";
    hostRecord.VMM_OSName = "Fedora";
    hostRecord.VMM_OSVersion = "20";
    hostRecord.AddOn_Connection_String = "intel:https://" + SERVER_NAME + ":9999";
    hostRecord.Port = Integer.valueOf(9999);
    trustStatus.bios = true;
    trustStatus.vmm = true;
    TxtHost host = new TxtHost(hostRecord, trustStatus);
    return host;
}
Also used : TxtHostRecord(com.intel.mtwilson.datatypes.TxtHostRecord) TxtHost(com.intel.mtwilson.datatypes.TxtHost) HostTrustStatus(com.intel.mtwilson.datatypes.HostTrustStatus)

Aggregations

TxtHostRecord (com.intel.mtwilson.datatypes.TxtHostRecord)3 TxtHost (com.intel.mtwilson.datatypes.TxtHost)2 DemoPortalException (com.intel.mountwilson.common.DemoPortalException)1 HostDetailsEntityVO (com.intel.mountwilson.datamodel.HostDetailsEntityVO)1 TrustedHostVO (com.intel.mountwilson.datamodel.TrustedHostVO)1 ApiException (com.intel.mtwilson.ApiException)1 HostTrustResponse (com.intel.mtwilson.datatypes.HostTrustResponse)1 HostTrustStatus (com.intel.mtwilson.datatypes.HostTrustStatus)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