Search in sources :

Example 1 with TblTaLogJpaController

use of com.intel.mtwilson.as.controller.TblTaLogJpaController in project OpenAttestation by OpenAttestation.

the class HostBO method deleteTALogs.

private void deleteTALogs(Integer hostId) throws IllegalOrphanException {
    TblTaLogJpaController tblTaLogJpaController = getTaLogJpaController();
    List<TblTaLog> taLogs = tblTaLogJpaController.findLogsByHostId(hostId, new Date());
    if (taLogs != null) {
        for (TblTaLog taLog : taLogs) {
            try {
                tblTaLogJpaController.destroy(taLog.getId());
            } catch (NonexistentEntityException e) {
                log.warn("Ta Log is already deleted " + taLog.getId());
            }
        }
        log.info("Deleted all the logs for the given host " + hostId);
    }
}
Also used : TblTaLogJpaController(com.intel.mtwilson.as.controller.TblTaLogJpaController) TblTaLog(com.intel.mtwilson.as.data.TblTaLog) NonexistentEntityException(com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException) Date(java.util.Date)

Example 2 with TblTaLogJpaController

use of com.intel.mtwilson.as.controller.TblTaLogJpaController in project OpenAttestation by OpenAttestation.

the class HostTrustBO method logBlankTrustStatus.

/*Bug 510
     * Added to support removal of TPM from host which was previously enabled. 
     * Adding blank row to ta log table will prevent an invalid trust report
     */
private void logBlankTrustStatus(TblHosts host) {
    Date today = new Date(System.currentTimeMillis());
    TblTaLog taLog = new TblTaLog();
    taLog.setHostID(host.getId());
    taLog.setMleId(0);
    taLog.setTrustStatus(false);
    taLog.setManifestName("");
    taLog.setManifestValue("");
    taLog.setUpdatedOn(today);
    new TblTaLogJpaController(getEntityManagerFactory()).create(taLog);
}
Also used : TblTaLogJpaController(com.intel.mtwilson.as.controller.TblTaLogJpaController) TblTaLog(com.intel.mtwilson.as.data.TblTaLog) Date(java.util.Date)

Example 3 with TblTaLogJpaController

use of com.intel.mtwilson.as.controller.TblTaLogJpaController 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)

Aggregations

TblTaLogJpaController (com.intel.mtwilson.as.controller.TblTaLogJpaController)3 TblTaLog (com.intel.mtwilson.as.data.TblTaLog)3 Date (java.util.Date)2 ASException (com.intel.mountwilson.as.common.ASException)1 NonexistentEntityException (com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException)1 TblHosts (com.intel.mtwilson.as.data.TblHosts)1 CryptographyException (com.intel.mtwilson.crypto.CryptographyException)1 Hostname (com.intel.mtwilson.util.net.Hostname)1 IOException (java.io.IOException)1 UnknownHostException (java.net.UnknownHostException)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 ConfigurationException (org.apache.commons.configuration.ConfigurationException)1