Search in sources :

Example 1 with HostsTrustReportType

use of com.intel.mountwilson.as.hosttrustreport.data.HostsTrustReportType in project OpenAttestation by OpenAttestation.

the class DemoPortalServicesImpl method getHostTrustReport.

@Override
public List<HostReportTypeVO> getHostTrustReport(List<String> hostNames, ApiClient client) throws DemoPortalException {
    AttestationService service = (AttestationService) client;
    HostsTrustReportType report = null;
    List<HostReportTypeVO> hostReportTypeVO = new ArrayList<HostReportTypeVO>();
    try {
        List<Hostname> hostList = new ArrayList<Hostname>();
        for (String host : hostNames) {
            hostList.add(new Hostname(host));
        }
        report = service.getHostTrustReport(hostList);
    } catch (Exception e) {
        log.error(e.getMessage());
        throw ConnectionUtil.handleException(e);
    }
    List<HostType> list = report.getHost();
    for (HostType hostType : list) {
        HostReportTypeVO vo = new HostReportTypeVO();
        vo.setHostName(hostType.getHostName());
        vo.setMleInfo(hostType.getMLEInfo());
        vo.setCreatedOn("");
        vo.setTrustStatus(hostType.getTrustStatus());
        vo.setVerifiedOn(formatter.format(hostType.getVerifiedOn().toGregorianCalendar().getTime()));
        hostReportTypeVO.add(vo);
    }
    return hostReportTypeVO;
}
Also used : HostType(com.intel.mountwilson.as.hosttrustreport.data.HostType) AttestationService(com.intel.mtwilson.AttestationService) HostsTrustReportType(com.intel.mountwilson.as.hosttrustreport.data.HostsTrustReportType) ArrayList(java.util.ArrayList) Hostname(com.intel.mtwilson.util.net.Hostname) HostReportTypeVO(com.intel.mountwilson.datamodel.HostReportTypeVO) ApiException(com.intel.mtwilson.ApiException) SignatureException(java.security.SignatureException) IOException(java.io.IOException) DemoPortalException(com.intel.mountwilson.common.DemoPortalException)

Example 2 with HostsTrustReportType

use of com.intel.mountwilson.as.hosttrustreport.data.HostsTrustReportType in project OpenAttestation by OpenAttestation.

the class ReportsBO method getTrustReport.

public HostsTrustReportType getTrustReport(Collection<Hostname> hostNames) {
    // datatype.Hostname
    try {
        HostsTrustReportType hostsTrustReportType = new HostsTrustReportType();
        for (Hostname host : hostNames) {
            // datatype.Hostname
            TblHosts tblHosts = getTblHostsJpaController().findByName(host.toString());
            if (tblHosts == null) {
                throw new ASException(ErrorCode.AS_HOST_NOT_FOUND, host);
            }
            List<TblTaLog> logs = getTblTaLogJpaController().findTrustStatusByHostId(tblHosts.getId(), 5);
            if (logs != null) {
                for (TblTaLog log : logs) {
                    HostType hostType = new HostType();
                    // datatype.Hostname
                    hostType.setHostName(host.toString());
                    hostType.setMLEInfo(getMleInfo(tblHosts));
                    hostType.setTrustStatus(getTrustStatus(log.getError()));
                    hostType.setVerifiedOn(Util.getCalendar(log.getUpdatedOn()));
                    hostsTrustReportType.getHost().add(hostType);
                }
            }
        }
        return hostsTrustReportType;
    } catch (CryptographyException e) {
        throw new ASException(e, ErrorCode.AS_ENCRYPTION_ERROR, e.getCause() == null ? e.getMessage() : e.getCause().getMessage());
    } catch (Exception e) {
        throw new ASException(e);
    }
}
Also used : HostType(com.intel.mountwilson.as.hosttrustreport.data.HostType) HostsTrustReportType(com.intel.mountwilson.as.hosttrustreport.data.HostsTrustReportType) TblTaLog(com.intel.mtwilson.as.data.TblTaLog) CryptographyException(com.intel.mtwilson.crypto.CryptographyException) TblHosts(com.intel.mtwilson.as.data.TblHosts) Hostname(com.intel.mtwilson.util.net.Hostname) ASException(com.intel.mountwilson.as.common.ASException) ASException(com.intel.mountwilson.as.common.ASException) CryptographyException(com.intel.mtwilson.crypto.CryptographyException) IOException(java.io.IOException)

Example 3 with HostsTrustReportType

use of com.intel.mountwilson.as.hosttrustreport.data.HostsTrustReportType in project OpenAttestation by OpenAttestation.

the class ReportsBOTest method testGetTrustReportWithError.

@Test
public void testGetTrustReportWithError() {
    Collection<Hostname> hostNames = new ArrayList<Hostname>();
    hostNames.add(new Hostname(SERVER_NAME));
    when(tblHostsJpaController.findByName(anyString())).thenReturn(mockFindByName());
    List<TblTaLog> taLogs = new ArrayList<TblTaLog>();
    TblTaLog taLog1 = new TblTaLog(Integer.valueOf(1), 1, 1, "0", "31B97D97B4679917EC3C1D943635693FFBAB4143", false, new Date());
    TblTaLog taLog2 = new TblTaLog(Integer.valueOf(2), 1, 2, "18", "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", false, new Date());
    taLog1.setError("BIOS:1,VMM:1");
    taLog2.setError("BIOS:1,VMM:1");
    taLogs.add(taLog1);
    taLogs.add(taLog2);
    when(tblTaLogJpaController.findTrustStatusByHostId(anyInt(), anyInt())).thenReturn(taLogs);
    HostsTrustReportType hostsTrustReportType = reportsBO.getTrustReport(hostNames);
    assertNotNull(hostsTrustReportType);
    assertTrue(hostsTrustReportType.getHost().size() > 0);
}
Also used : TblTaLog(com.intel.mtwilson.as.data.TblTaLog) HostsTrustReportType(com.intel.mountwilson.as.hosttrustreport.data.HostsTrustReportType) ArrayList(java.util.ArrayList) Hostname(com.intel.mtwilson.util.net.Hostname) Date(java.util.Date) Test(org.junit.Test)

Example 4 with HostsTrustReportType

use of com.intel.mountwilson.as.hosttrustreport.data.HostsTrustReportType in project OpenAttestation by OpenAttestation.

the class ApiClient method getHostTrustReport.

@Override
public HostsTrustReportType getHostTrustReport(List<Hostname> hostnames) throws IOException, ApiException, SignatureException, JAXBException {
    String hostNamesCSV = StringUtils.join(hostnames, ",");
    MultivaluedMap<String, String> query = new MultivaluedMapImpl();
    query.add("hostNames", hostNamesCSV);
    HostsTrustReportType report = fromXML(httpGet(asurl("/hosts/reports/trust", query)), HostsTrustReportType.class);
    return report;
}
Also used : HostsTrustReportType(com.intel.mountwilson.as.hosttrustreport.data.HostsTrustReportType)

Example 5 with HostsTrustReportType

use of com.intel.mountwilson.as.hosttrustreport.data.HostsTrustReportType in project OpenAttestation by OpenAttestation.

the class ReportsBOTest method testGetTrustReportNoError.

@Test
public void testGetTrustReportNoError() {
    Collection<Hostname> hostNames = new ArrayList<Hostname>();
    hostNames.add(new Hostname(SERVER_NAME));
    when(tblHostsJpaController.findByName(anyString())).thenReturn(mockFindByName());
    when(tblTaLogJpaController.findTrustStatusByHostId(anyInt(), anyInt())).thenReturn(null);
    HostsTrustReportType hostsTrustReportType = reportsBO.getTrustReport(hostNames);
    assertNotNull(hostsTrustReportType);
    assertFalse(hostsTrustReportType.getHost().size() > 0);
}
Also used : HostsTrustReportType(com.intel.mountwilson.as.hosttrustreport.data.HostsTrustReportType) ArrayList(java.util.ArrayList) Hostname(com.intel.mtwilson.util.net.Hostname) Test(org.junit.Test)

Aggregations

HostsTrustReportType (com.intel.mountwilson.as.hosttrustreport.data.HostsTrustReportType)5 Hostname (com.intel.mtwilson.util.net.Hostname)4 ArrayList (java.util.ArrayList)3 HostType (com.intel.mountwilson.as.hosttrustreport.data.HostType)2 TblTaLog (com.intel.mtwilson.as.data.TblTaLog)2 IOException (java.io.IOException)2 Test (org.junit.Test)2 ASException (com.intel.mountwilson.as.common.ASException)1 DemoPortalException (com.intel.mountwilson.common.DemoPortalException)1 HostReportTypeVO (com.intel.mountwilson.datamodel.HostReportTypeVO)1 ApiException (com.intel.mtwilson.ApiException)1 AttestationService (com.intel.mtwilson.AttestationService)1 TblHosts (com.intel.mtwilson.as.data.TblHosts)1 CryptographyException (com.intel.mtwilson.crypto.CryptographyException)1 SignatureException (java.security.SignatureException)1 Date (java.util.Date)1