Search in sources :

Example 11 with TblPcrManifest

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

the class PcrGKVStrategyTest method mockFindBiosMle.

public TblMle mockFindBiosMle() {
    String biosName = "DELL";
    String biosVersion = "A08";
    String oemName = "DELL";
    TblMle biosMle = new TblMle();
    biosMle.setId(1);
    biosMle.setName(biosName);
    biosMle.setVersion(biosVersion);
    TblOem oem = new TblOem();
    oem.setId(1);
    oem.setName(oemName);
    biosMle.setOemId(oem);
    Collection<TblPcrManifest> tblPcrManifestCollection = new ArrayList<TblPcrManifest>();
    TblPcrManifest tblPcrManifest = new TblPcrManifest();
    tblPcrManifest.setId(1);
    tblPcrManifest.setName("0");
    tblPcrManifestCollection.add(tblPcrManifest);
    biosMle.setTblPcrManifestCollection(tblPcrManifestCollection);
    return biosMle;
}
Also used : TblMle(com.intel.mtwilson.as.data.TblMle) TblOem(com.intel.mtwilson.as.data.TblOem) ArrayList(java.util.ArrayList) Matchers.anyString(org.mockito.Matchers.anyString) TblPcrManifest(com.intel.mtwilson.as.data.TblPcrManifest)

Example 12 with TblPcrManifest

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

the class MleBO method addPCRWhiteList.

/**
         * Added By: Sudhir on June 20, 2012
         * 
         * Processes the add request for a new PCR white list for the specified MLE.
         * 
         * @param pcrData: White list data sent by the user
         * @return : true if the call is successful or else exception.
         */
public String addPCRWhiteList(PCRWhiteList pcrData) {
    TblMle tblMle;
    TblPcrManifest tblPcr;
    try {
        tblMle = getMleDetails(pcrData.getMleName(), pcrData.getMleVersion(), pcrData.getOsName(), pcrData.getOsVersion(), pcrData.getOemName());
        if (tblMle == null && pcrData.getOemName() != null) {
            throw new ASException(ErrorCode.WS_MLE_OEM_DOES_NOT_EXIST, pcrData.getMleName(), pcrData.getMleVersion(), pcrData.getOemName());
        }
        if (tblMle == null && pcrData.getOsName() != null) {
            throw new ASException(ErrorCode.WS_MLE_OS_DOES_NOT_EXIST, pcrData.getMleName(), pcrData.getMleVersion(), pcrData.getOsName(), pcrData.getOsVersion());
        }
        // Now we need to check if PCR is already configured. If yes, then
        // we ned to ask the user to use the Update option instead of create
        tblPcr = getPCRWhiteListDetails(tblMle.getId(), pcrData.getPcrName());
        if (tblPcr != null) {
            throw new ASException(ErrorCode.WS_PCR_WHITELIST_ALREADY_EXISTS, pcrData.getPcrName());
        }
        /*
           if (StringUtils.isNotBlank(pcrData.getOemName())) {
               log.info("BIOS MLE, check the range of PCR value " + pcrData.getPcrName());
               if (Integer.valueOf(pcrData.getPcrName()).intValue() > 5 || Integer.valueOf(pcrData.getPcrName()).intValue() < 0)
                   throw new ASException(ErrorCode.WS_MLE_PCR_NOT_VALID, pcrData.getPcrName());
           } else {
               log.info("VMM MLE, check the range of PCR value " + pcrData.getPcrName());
               if (Integer.valueOf(pcrData.getPcrName()).intValue() > 20 || Integer.valueOf(pcrData.getPcrName()).intValue() < 17)
                   throw new ASException(ErrorCode.WS_MLE_PCR_NOT_VALID, pcrData.getPcrName());
           } */
        // In order to reuse the addPCRManifest function, we need to create a list and
        // add a single entry into it using the manifest data that we got.
        List<ManifestData> pcrWhiteList = new ArrayList<ManifestData>();
        pcrWhiteList.add(new ManifestData(pcrData.getPcrName(), pcrData.getPcrDigest()));
        // Now add the pcr to the database.
        addPcrManifest(tblMle, pcrWhiteList);
    } catch (ASException ase) {
        throw ase;
    } catch (Exception e) {
        throw new ASException(e);
    }
    return "true";
}
Also used : TblMle(com.intel.mtwilson.as.data.TblMle) TblPcrManifest(com.intel.mtwilson.as.data.TblPcrManifest) ManifestData(com.intel.mtwilson.datatypes.ManifestData) ASException(com.intel.mountwilson.as.common.ASException) ASException(com.intel.mountwilson.as.common.ASException) NoResultException(javax.persistence.NoResultException) ASDataException(com.intel.mtwilson.as.controller.exceptions.ASDataException) NonexistentEntityException(com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException) IllegalOrphanException(com.intel.mtwilson.as.controller.exceptions.IllegalOrphanException)

Example 13 with TblPcrManifest

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

the class MleBO method addPcrManifest.

private void addPcrManifest(TblMle tblMle, List<ManifestData> mleManifests) throws IllegalOrphanException, NonexistentEntityException, ASDataException {
    Collection<TblPcrManifest> tblPcrManifests = new ArrayList<TblPcrManifest>();
    if (mleManifests != null) {
        for (ManifestData manifestData : mleManifests) {
            TblPcrManifest pcrManifest = new TblPcrManifest();
            pcrManifest.setName(manifestData.getName());
            pcrManifest.setValue(manifestData.getValue());
            pcrManifest.setMleId(tblMle);
            pcrManifestJpaController.create(pcrManifest);
            tblPcrManifests.add(pcrManifest);
        }
    }
    tblPcrManifests.addAll(tblMle.getTblPcrManifestCollection());
    tblMle.setTblPcrManifestCollection(tblPcrManifests);
    String oldRequiredManifestList = tblMle.getRequiredManifestList() == null || tblMle.getRequiredManifestList().length() == 0 ? "" : tblMle.getRequiredManifestList() + ",";
    tblMle.setRequiredManifestList(oldRequiredManifestList + getRequiredManifestList(mleManifests));
    mleJpaController.edit(tblMle);
}
Also used : TblPcrManifest(com.intel.mtwilson.as.data.TblPcrManifest) ManifestData(com.intel.mtwilson.datatypes.ManifestData)

Example 14 with TblPcrManifest

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

the class MleBO method deleteMle.

/**
    * 
    * @param mleName
    * @param mleVersion
    * @param osName
    * @param osVersion
    * @param oemName
    * @return 
    */
public String deleteMle(String mleName, String mleVersion, String osName, String osVersion, String oemName) {
    try {
        TblMle tblMle = getMleDetails(mleName, mleVersion, osName, osVersion, oemName);
        if (tblMle == null) {
            throw new ASException(ErrorCode.WS_MLE_DOES_NOT_EXIST, mleName, mleVersion);
        }
        Collection<TblHosts> tblHostsCollection;
        if (oemName == null || oemName.isEmpty()) {
            tblHostsCollection = tblMle.getTblHostsCollection();
        } else {
            tblHostsCollection = tblMle.getTblHostsCollection1();
        }
        if (tblHostsCollection != null) {
            log.info(String.format("MLE '%s' is currently associated with '%d' hosts. ", mleName, tblHostsCollection.size()));
            if (!tblHostsCollection.isEmpty()) {
                throw new ASException(ErrorCode.WS_MLE_ASSOCIATION_EXISTS, mleName, mleVersion, tblHostsCollection.size());
            }
        }
        for (TblPcrManifest manifest : tblMle.getTblPcrManifestCollection()) {
            pcrManifestJpaController.destroy(manifest.getId());
        }
        // We also need to delete entries in the MleSource table for the MLE. This table would store the host
        // name that was used to white list the MLE.
        deleteMleSource(mleName, mleVersion, osName, osVersion, oemName);
        mleJpaController.destroy(tblMle.getId());
    } catch (ASException ase) {
        throw ase;
    } catch (Exception e) {
        throw new ASException(e);
    }
    return "true";
}
Also used : TblMle(com.intel.mtwilson.as.data.TblMle) TblHosts(com.intel.mtwilson.as.data.TblHosts) TblPcrManifest(com.intel.mtwilson.as.data.TblPcrManifest) ASException(com.intel.mountwilson.as.common.ASException) ASException(com.intel.mountwilson.as.common.ASException) NoResultException(javax.persistence.NoResultException) ASDataException(com.intel.mtwilson.as.controller.exceptions.ASDataException) NonexistentEntityException(com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException) IllegalOrphanException(com.intel.mtwilson.as.controller.exceptions.IllegalOrphanException)

Example 15 with TblPcrManifest

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

the class MleBO method getPCRWhiteListDetails.

/**
         * Added By: Sudhir on June 20, 2012
         * 
         * Retrieves the details of the PCR manifest entry if exists.
         * 
         * @param mle_id : Identity of the MLE
         * @param pcrName : Name of the PCR
         * @return : Data row containing the PCR manifest details.
         */
private TblPcrManifest getPCRWhiteListDetails(Integer mle_id, String pcrName) {
    TblPcrManifest tblPcr;
    validateNull("pcrName", pcrName);
    tblPcr = pcrManifestJpaController.findByMleIdName(mle_id, pcrName);
    return tblPcr;
}
Also used : TblPcrManifest(com.intel.mtwilson.as.data.TblPcrManifest)

Aggregations

TblPcrManifest (com.intel.mtwilson.as.data.TblPcrManifest)34 TblMle (com.intel.mtwilson.as.data.TblMle)18 Matchers.anyString (org.mockito.Matchers.anyString)12 ArrayList (java.util.ArrayList)9 EntityManager (javax.persistence.EntityManager)9 NonexistentEntityException (com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException)8 TblHosts (com.intel.mtwilson.as.data.TblHosts)7 Test (org.junit.Test)7 ASDataException (com.intel.mtwilson.as.controller.exceptions.ASDataException)6 IllegalOrphanException (com.intel.mtwilson.as.controller.exceptions.IllegalOrphanException)6 TblOem (com.intel.mtwilson.as.data.TblOem)6 TblOs (com.intel.mtwilson.as.data.TblOs)6 NoResultException (javax.persistence.NoResultException)5 ASException (com.intel.mountwilson.as.common.ASException)4 IManifest (com.intel.mountwilson.manifest.data.IManifest)4 PcrManifest (com.intel.mountwilson.manifest.data.PcrManifest)4 HashMap (java.util.HashMap)4 EntityNotFoundException (javax.persistence.EntityNotFoundException)4 Query (javax.persistence.Query)4 CriteriaQuery (javax.persistence.criteria.CriteriaQuery)4