Search in sources :

Example 16 with TblPcrManifest

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

the class MleBO method deletePCRWhiteList.

/**
         * 
         * Added By: Sudhir on June 20, 2012
         * 
         * Processes the delete request for an existing PCR white list for the specified MLE.
         * 
         * @param pcrName : Name of the PCR, which is usually the number
         * @param mleName : Name of the associated MLE
         * @param mleVersion : Version of the associated MLE
         * @param osName : OS name associated with the VMM MLE
         * @param osVersion : OS version associated with the VMM MLE
         * @param oemName : OEM Name associated with the BIOS MLE
         * @return 
         */
public String deletePCRWhiteList(String pcrName, String mleName, String mleVersion, String osName, String osVersion, String oemName) {
    TblPcrManifest tblPcr;
    TblMle tblMle;
    try {
        tblMle = getMleDetails(mleName, mleVersion, osName, osVersion, oemName);
        if (tblMle == null && oemName != null) {
            throw new ASException(ErrorCode.WS_MLE_OEM_DOES_NOT_EXIST, mleName, mleVersion, oemName);
        }
        if (tblMle == null && osName != null) {
            throw new ASException(ErrorCode.WS_MLE_OS_DOES_NOT_EXIST, mleName, mleVersion, osName, osVersion);
        }
        // Now we need to check if PCR value exists. If it does, then we do delete or else
        // we still return true since the data does not exist.
        tblPcr = getPCRWhiteListDetails(tblMle.getId(), pcrName);
        if (tblPcr == null) {
            return "true";
        }
        // Delete the PCR white list entry.
        pcrManifestJpaController.destroy(tblPcr.getId());
    } 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) 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 17 with TblPcrManifest

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

the class MleBO method updatePCRWhiteList.

/**
         * Added By: Sudhir on June 20, 2012
         * 
         * Processes the update request for an existing 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 updatePCRWhiteList(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_DOES_NOT_EXIST, pcrData.getPcrName());
        }
        // Now update the pcr in the database.
        tblPcr.setValue(pcrData.getPcrDigest());
        pcrManifestJpaController.edit(tblPcr);
    } 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) 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 18 with TblPcrManifest

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

the class MleBOTest method mockFindVmmMle.

public TblMle mockFindVmmMle() {
    String vmmName = "XEN";
    String vmmVersion = "4.3";
    String osName = "Fedora";
    String osVersion = "20";
    TblMle vmmMle = new TblMle();
    vmmMle.setId(MLE_ID2);
    vmmMle.setName(vmmName);
    vmmMle.setVersion(vmmVersion);
    vmmMle.setOemId(new TblOem());
    TblOs os = new TblOs();
    os.setId(1);
    os.setName(osName);
    os.setVersion(osVersion);
    vmmMle.setOsId(os);
    Collection<TblPcrManifest> tblPcrManifestCollectionVMM = new ArrayList<TblPcrManifest>();
    TblPcrManifest tblPcrManifestVMM = new TblPcrManifest();
    tblPcrManifestVMM.setId(2);
    tblPcrManifestVMM.setName("18");
    tblPcrManifestVMM.setValue("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF");
    tblPcrManifestCollectionVMM.add(tblPcrManifestVMM);
    vmmMle.setTblPcrManifestCollection(tblPcrManifestCollectionVMM);
    return vmmMle;
}
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) TblOs(com.intel.mtwilson.as.data.TblOs)

Example 19 with TblPcrManifest

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

the class MleBOTest method mockFindBiosMle.

public TblMle mockFindBiosMle() {
    String biosName = "DELL";
    String biosVersion = "A08";
    String oemName = "DELL";
    TblMle biosMle = new TblMle();
    biosMle.setId(MLE_ID1);
    biosMle.setName(biosName);
    biosMle.setVersion(biosVersion);
    TblOem oem = new TblOem();
    oem.setId(1);
    oem.setName(oemName);
    biosMle.setOemId(oem);
    biosMle.setOsId(new TblOs());
    Collection<TblPcrManifest> tblPcrManifestCollection = new ArrayList<TblPcrManifest>();
    TblPcrManifest tblPcrManifest = new TblPcrManifest();
    tblPcrManifest.setId(1);
    tblPcrManifest.setName("0");
    tblPcrManifest.setValue("31B97D97B4679917EC3C1D943635693FFBAB4143");
    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) TblOs(com.intel.mtwilson.as.data.TblOs)

Example 20 with TblPcrManifest

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

the class TblMleJpaController method destroy.

public void destroy(Integer id) throws IllegalOrphanException, NonexistentEntityException {
    EntityManager em = getEntityManager();
    try {
        em.getTransaction().begin();
        TblMle tblMle;
        try {
            tblMle = em.getReference(TblMle.class, id);
            tblMle.getId();
        } catch (EntityNotFoundException enfe) {
            throw new NonexistentEntityException("The tblMle with id " + id + " no longer exists.", enfe);
        }
        List<String> illegalOrphanMessages = null;
        Collection<TblHosts> tblHostsCollectionOrphanCheck = tblMle.getTblHostsCollection();
        for (TblHosts tblHostsCollectionOrphanCheckTblHosts : tblHostsCollectionOrphanCheck) {
            if (illegalOrphanMessages == null) {
                illegalOrphanMessages = new ArrayList<String>();
            }
            illegalOrphanMessages.add("This TblMle (" + tblMle + ") cannot be destroyed since the TblHosts " + tblHostsCollectionOrphanCheckTblHosts + " in its tblHostsCollection field has a non-nullable vmmMleId field.");
        }
        Collection<TblHosts> tblHostsCollection1OrphanCheck = tblMle.getTblHostsCollection1();
        for (TblHosts tblHostsCollection1OrphanCheckTblHosts : tblHostsCollection1OrphanCheck) {
            if (illegalOrphanMessages == null) {
                illegalOrphanMessages = new ArrayList<String>();
            }
            illegalOrphanMessages.add("This TblMle (" + tblMle + ") cannot be destroyed since the TblHosts " + tblHostsCollection1OrphanCheckTblHosts + " in its tblHostsCollection1 field has a non-nullable biosMleId field.");
        }
        Collection<TblPcrManifest> tblPcrManifestCollectionOrphanCheck = tblMle.getTblPcrManifestCollection();
        for (TblPcrManifest tblPcrManifestCollectionOrphanCheckTblPcrManifest : tblPcrManifestCollectionOrphanCheck) {
            if (illegalOrphanMessages == null) {
                illegalOrphanMessages = new ArrayList<String>();
            }
            illegalOrphanMessages.add("This TblMle (" + tblMle + ") cannot be destroyed since the TblPcrManifest " + tblPcrManifestCollectionOrphanCheckTblPcrManifest + " in its tblPcrManifestCollection field has a non-nullable mleId field.");
        }
        if (illegalOrphanMessages != null) {
            throw new IllegalOrphanException(illegalOrphanMessages);
        }
        em.remove(tblMle);
        em.getTransaction().commit();
    } finally {
        em.close();
    }
}
Also used : IllegalOrphanException(com.intel.mtwilson.as.controller.exceptions.IllegalOrphanException) EntityManager(javax.persistence.EntityManager) TblMle(com.intel.mtwilson.as.data.TblMle) TblHosts(com.intel.mtwilson.as.data.TblHosts) NonexistentEntityException(com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException) EntityNotFoundException(javax.persistence.EntityNotFoundException) 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