Search in sources :

Example 26 with TblModuleManifest

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

the class HostBO method deleteModulesForMLE.

private void deleteModulesForMLE(TxtHostRecord host) throws NonexistentEntityException, IOException {
    TblMleJpaController tblMleJpaController = getMleJpaController();
    TblModuleManifestJpaController tblModuleManifestJpaController = getModuleJpaController();
    try {
        TblMle tblMle = tblMleJpaController.findVmmMle(host.VMM_Name, host.VMM_Version, host.VMM_OSName, host.VMM_OSVersion);
        if (tblMle != null) {
            // Retrieve the list of all the modules for the specified VMM MLE.
            List<TblModuleManifest> moduleList = tblModuleManifestJpaController.findTblModuleManifestByHardwareUuid(host.Hardware_Uuid);
            if (moduleList != null && moduleList.size() > 0) {
                for (TblModuleManifest moduleObj : moduleList) {
                    //if (moduleObj.getUseHostSpecificDigestValue()) // we cannot delete the host specific one since it would be referenced by the Hosts
                    //    continue;
                    tblModuleManifestJpaController.destroy(moduleObj.getId());
                }
            }
        }
    } catch (IllegalOrphanException | NonexistentEntityException ex) {
        log.error("Error during the deletion of VMM modules {}. ", host.VMM_Name, ex);
        throw new ASException(ErrorCode.WS_MODULE_WHITELIST_DELETE_ERROR, ex.getClass().getSimpleName());
    }
}
Also used : IllegalOrphanException(com.intel.mtwilson.as.controller.exceptions.IllegalOrphanException) TblMleJpaController(com.intel.mtwilson.as.controller.TblMleJpaController) TblModuleManifestJpaController(com.intel.mtwilson.as.controller.TblModuleManifestJpaController) TblMle(com.intel.mtwilson.as.data.TblMle) NonexistentEntityException(com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException) TblModuleManifest(com.intel.mtwilson.as.data.TblModuleManifest) ASException(com.intel.mountwilson.as.common.ASException)

Example 27 with TblModuleManifest

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

the class HostBO method deleteHostSpecificManifest.

// PREMIUM FEATURE ? 
private void deleteHostSpecificManifest(TblHosts tblHosts) throws NonexistentEntityException, IOException {
    //TblHostSpecificManifestJpaController tblHostSpecificManifestJpaController = My.jpa().mwHostSpecificManifest();
    TblHostSpecificManifestJpaController tblHostSpecificManifestJpaController = getHostSpecificManifestJpaController();
    for (TblModuleManifest moduleManifest : tblHosts.getVmmMleId().getTblModuleManifestCollection()) {
        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.
            TblHostSpecificManifest hostSpecificManifest = tblHostSpecificManifestJpaController.findByModuleAndHostID(tblHosts.getId(), moduleManifest.getId());
            if (hostSpecificManifest != null) {
                log.debug("Deleting Host specific manifest." + moduleManifest.getComponentName() + ":" + hostSpecificManifest.getDigestValue());
                tblHostSpecificManifestJpaController.destroy(hostSpecificManifest.getId());
            }
        }
    }
}
Also used : TblHostSpecificManifestJpaController(com.intel.mtwilson.as.controller.TblHostSpecificManifestJpaController) TblHostSpecificManifest(com.intel.mtwilson.as.data.TblHostSpecificManifest) TblModuleManifest(com.intel.mtwilson.as.data.TblModuleManifest)

Example 28 with TblModuleManifest

use of com.intel.mtwilson.as.data.TblModuleManifest 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

TblModuleManifest (com.intel.mtwilson.as.data.TblModuleManifest)28 EntityManager (javax.persistence.EntityManager)21 NonexistentEntityException (com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException)11 NoResultException (javax.persistence.NoResultException)10 IllegalOrphanException (com.intel.mtwilson.as.controller.exceptions.IllegalOrphanException)9 TblEventType (com.intel.mtwilson.as.data.TblEventType)9 TblHostSpecificManifest (com.intel.mtwilson.as.data.TblHostSpecificManifest)9 TblPackageNamespace (com.intel.mtwilson.as.data.TblPackageNamespace)9 ArrayList (java.util.ArrayList)9 EntityNotFoundException (javax.persistence.EntityNotFoundException)9 Query (javax.persistence.Query)9 CriteriaQuery (javax.persistence.criteria.CriteriaQuery)9 TblMle (com.intel.mtwilson.as.data.TblMle)7 ASDataException (com.intel.mtwilson.as.controller.exceptions.ASDataException)5 TblModuleManifestJpaController (com.intel.mtwilson.as.controller.TblModuleManifestJpaController)3 ASException (com.intel.mountwilson.as.common.ASException)2 TblHostSpecificManifestJpaController (com.intel.mtwilson.as.controller.TblHostSpecificManifestJpaController)2 TblMleJpaController (com.intel.mtwilson.as.controller.TblMleJpaController)2 Measurement (com.intel.mtwilson.util.model.Measurement)2 PcrEventLog (com.intel.mtwilson.util.model.PcrEventLog)2