Search in sources :

Example 6 with TblModuleManifestLog

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

the class ReportsBO method addManifestLogs.

private void addManifestLogs(Integer hostId, PcrLogReport manifest, TblTaLog log, Boolean failureOnly, TblPcrManifest tblPcrManifest) throws IOException {
    HashMap<String, ModuleLogReport> moduleReports = new HashMap<>();
    if (log.getTblModuleManifestLogCollection() != null) {
        logger.debug("addManifestLogs - This is module based attestation with {} of modules.", log.getTblModuleManifestLogCollection().size());
        for (TblModuleManifestLog moduleManifestLog : log.getTblModuleManifestLogCollection()) {
            moduleReports.put(moduleManifestLog.getName(), new ModuleLogReport(moduleManifestLog.getName(), moduleManifestLog.getValue(), moduleManifestLog.getWhitelistValue(), 0));
        }
    }
    if (!failureOnly) {
        logger.debug("FailureOnly flag is false. Adding all manifests.");
        for (TblModuleManifest moduleManifest : tblPcrManifest.getMleId().getTblModuleManifestCollection()) {
            if (moduleManifest.getExtendedToPCR().equalsIgnoreCase(tblPcrManifest.getName()) && !moduleReports.containsKey(moduleManifest.getComponentName())) {
                if (moduleManifest.getUseHostSpecificDigestValue() != null && moduleManifest.getUseHostSpecificDigestValue().booleanValue()) {
                    // For open source we used to have multiple module manifests for the same hosts. So, the below query by hostID was returning multiple results.
                    //String hostSpecificDigestValue = new TblHostSpecificManifestJpaController(getEntityManagerFactory()).findByHostID(hostId).getDigestValue();
                    //String hostSpecificDigestValue = My.jpa().mwHostSpecificManifest().findByModuleAndHostID(hostId, moduleManifest.getId()).getDigestValue();
                    TblHostSpecificManifestJpaController tblHostSpecificManifestJpaController = getTblHostSpecificManifestJpaController();
                    String hostSpecificDigestValue = tblHostSpecificManifestJpaController.findByModuleAndHostID(hostId, moduleManifest.getId()).getDigestValue();
                    moduleReports.put(moduleManifest.getComponentName(), new ModuleLogReport(moduleManifest.getComponentName(), hostSpecificDigestValue, hostSpecificDigestValue, 1));
                } else {
                    moduleReports.put(moduleManifest.getComponentName(), new ModuleLogReport(moduleManifest.getComponentName(), moduleManifest.getDigestValue(), moduleManifest.getDigestValue(), 1));
                }
            }
        }
    }
    manifest.getModuleLogs().addAll(moduleReports.values());
}
Also used : TblHostSpecificManifestJpaController(com.intel.mtwilson.as.controller.TblHostSpecificManifestJpaController) TblModuleManifest(com.intel.mtwilson.as.data.TblModuleManifest) TblModuleManifestLog(com.intel.mtwilson.as.data.TblModuleManifestLog)

Aggregations

TblModuleManifestLog (com.intel.mtwilson.as.data.TblModuleManifestLog)6 EntityManager (javax.persistence.EntityManager)5 Query (javax.persistence.Query)3 CriteriaQuery (javax.persistence.criteria.CriteriaQuery)3 NonexistentEntityException (com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException)2 TblTaLog (com.intel.mtwilson.as.data.TblTaLog)2 EntityNotFoundException (javax.persistence.EntityNotFoundException)2 NoResultException (javax.persistence.NoResultException)2 TblHostSpecificManifestJpaController (com.intel.mtwilson.as.controller.TblHostSpecificManifestJpaController)1 ASDataException (com.intel.mtwilson.as.controller.exceptions.ASDataException)1 TblModuleManifest (com.intel.mtwilson.as.data.TblModuleManifest)1