Search in sources :

Example 21 with TblTaLog

use of com.intel.mtwilson.as.data.TblTaLog in project OpenAttestation by OpenAttestation.

the class ReportsBOTest method testGetReportManifest.

@Test
public void testGetReportManifest() {
    when(tblHostsJpaController.findByName(anyString())).thenReturn(mockFindByName());
    when(tblTaLogJpaController.findLastStatusTs(any(Integer.class))).thenReturn(new Date());
    List<TblTaLog> taLogs = new ArrayList<TblTaLog>();
    taLogs.add(new TblTaLog(Integer.valueOf(1), 1, 1, "0", "31B97D97B4679917EC3C1D943635693FFBAB4143", true, new Date()));
    when(tblTaLogJpaController.findLogsByHostId(anyInt(), any(Date.class))).thenReturn(taLogs);
    HostManifestReportType hostManifestReportType = reportsBO.getReportManifest(new Hostname(SERVER_NAME));
    assertNotNull(hostManifestReportType);
    assertNotNull(hostManifestReportType.getHost());
}
Also used : TblTaLog(com.intel.mtwilson.as.data.TblTaLog) ArrayList(java.util.ArrayList) Hostname(com.intel.mtwilson.util.net.Hostname) HostManifestReportType(com.intel.mountwilson.as.hostmanifestreport.data.HostManifestReportType) Date(java.util.Date) Test(org.junit.Test)

Example 22 with TblTaLog

use of com.intel.mtwilson.as.data.TblTaLog in project OpenAttestation by OpenAttestation.

the class HostTrustBO method getTrustWithCache.

public HostTrust getTrustWithCache(String host, Boolean forceVerify) {
    log.info("Getting trust for host: " + host + " Force verify flag: " + forceVerify);
    try {
        if (forceVerify != true) {
            TblHosts tblHosts = getHostByName(new Hostname(host));
            if (tblHosts != null) {
                TblTaLog tblTaLog = new TblTaLogJpaController(getEntityManagerFactory()).getHostTALogEntryBefore(tblHosts.getId(), getCacheStaleAfter());
                if (tblTaLog != null)
                    return getHostTrustObj(tblTaLog);
            } else {
                throw new ASException(ErrorCode.AS_HOST_NOT_FOUND, host);
            }
        }
        log.info("Getting trust status from host.");
        HostTrustStatus status = getTrustStatus(new Hostname(host));
        HostTrust hostTrust = new HostTrust(ErrorCode.OK, "OK");
        hostTrust.setBiosStatus((status.bios) ? 1 : 0);
        hostTrust.setVmmStatus((status.vmm) ? 1 : 0);
        hostTrust.setIpAddress(host);
        return hostTrust;
    } catch (ASException e) {
        log.error("Error while getting trust for host " + host, e);
        return new HostTrust(e.getErrorCode(), e.getErrorMessage(), host, null, null);
    } catch (Exception e) {
        log.error("Error while getting trust for host " + host, e);
        return new HostTrust(ErrorCode.SYSTEM_ERROR, new AuthResponse(ErrorCode.SYSTEM_ERROR, e.getMessage()).getErrorMessage(), host, null, null);
    }
}
Also used : TblTaLogJpaController(com.intel.mtwilson.as.controller.TblTaLogJpaController) TblTaLog(com.intel.mtwilson.as.data.TblTaLog) 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) WebApplicationException(javax.ws.rs.WebApplicationException) ConfigurationException(org.apache.commons.configuration.ConfigurationException) CryptographyException(com.intel.mtwilson.crypto.CryptographyException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException)

Example 23 with TblTaLog

use of com.intel.mtwilson.as.data.TblTaLog in project OpenAttestation by OpenAttestation.

the class HostTrustBO method logOverallTrustStatus.

private void logOverallTrustStatus(TblHosts host, String response) {
    Date today = new Date(System.currentTimeMillis());
    TblTaLog taLog = new TblTaLog();
    taLog.setHostID(host.getId());
    taLog.setMleId(0);
    taLog.setTrustStatus(false);
    taLog.setError(response);
    taLog.setManifestName(" ");
    taLog.setManifestValue(" ");
    taLog.setUpdatedOn(today);
    getTblTaLogJpaController().create(taLog);
}
Also used : TblTaLog(com.intel.mtwilson.as.data.TblTaLog) Date(java.util.Date)

Aggregations

TblTaLog (com.intel.mtwilson.as.data.TblTaLog)23 EntityManager (javax.persistence.EntityManager)11 Date (java.util.Date)9 Query (javax.persistence.Query)7 CriteriaQuery (javax.persistence.criteria.CriteriaQuery)7 Hostname (com.intel.mtwilson.util.net.Hostname)6 TblHosts (com.intel.mtwilson.as.data.TblHosts)5 ASException (com.intel.mountwilson.as.common.ASException)4 NonexistentEntityException (com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException)4 CryptographyException (com.intel.mtwilson.crypto.CryptographyException)4 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)4 HostType (com.intel.mountwilson.as.hosttrustreport.data.HostType)3 TblTaLogJpaController (com.intel.mtwilson.as.controller.TblTaLogJpaController)3 EntityNotFoundException (javax.persistence.EntityNotFoundException)3 HostManifestReportType (com.intel.mountwilson.as.hostmanifestreport.data.HostManifestReportType)2 HostsTrustReportType (com.intel.mountwilson.as.hosttrustreport.data.HostsTrustReportType)2 TblModuleManifestLog (com.intel.mtwilson.as.data.TblModuleManifestLog)2 IOException (java.io.IOException)2 ManifestType (com.intel.mountwilson.as.hostmanifestreport.data.ManifestType)1