Search in sources :

Example 1 with ManifestData

use of com.intel.mtwilson.datatypes.ManifestData in project OpenAttestation by OpenAttestation.

the class ConverterUtil method getManifestListFromApiClient.

private static List<Map<String, String>> getManifestListFromApiClient(List<ManifestData> manifestList) {
    List<Map<String, String>> list = new ArrayList<Map<String, String>>();
    Map<String, String> manifest;
    if (manifestList != null) {
        for (ManifestData manifestData : manifestList) {
            manifest = new HashMap<String, String>();
            manifest.put("Name", manifestData.getName());
            manifest.put("Value", manifestData.getValue());
            list.add(manifest);
        }
    }
    return list;
}
Also used : ArrayList(java.util.ArrayList) HashMap(java.util.HashMap) MultivaluedMap(javax.ws.rs.core.MultivaluedMap) Map(java.util.Map) ManifestData(com.intel.mtwilson.datatypes.ManifestData)

Example 2 with ManifestData

use of com.intel.mtwilson.datatypes.ManifestData 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 3 with ManifestData

use of com.intel.mtwilson.datatypes.ManifestData 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 4 with ManifestData

use of com.intel.mtwilson.datatypes.ManifestData in project OpenAttestation by OpenAttestation.

the class MleBOTest method testUpdateMle.

@Test
public void testUpdateMle() {
    TblMle biosMle = new TblMle(MLE_ID1, "DELL", "A08", "PCR", "BIOS", "0");
    TblMle vmmMle = new TblMle(MLE_ID2, "XEN", "4.3", "PCR", "VMM", "18");
    doReturn(biosMle).when(tblMleJpaController).findBiosMle(anyString(), anyString(), anyString());
    doReturn(vmmMle).when(tblMleJpaController).findVmmMle(anyString(), anyString(), anyString(), anyString());
    List<ManifestData> biosManifestList = new ArrayList<ManifestData>();
    biosManifestList.add(new ManifestData("0", "31B97D97B4679917EC3C1D943635693FFBAB4143"));
    MleData biosMleData = new MleData("DELL", "A08", MleType.BIOS, AttestationType.PCR, biosManifestList, "", "", "", "DELL");
    List<ManifestData> vmmManifestList = new ArrayList<ManifestData>();
    vmmManifestList.add(new ManifestData("18", "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"));
    MleData vmmMleData = new MleData("XEN", "4.3", MleType.VMM, AttestationType.PCR, vmmManifestList, "", "Fedora", "20", "");
    String biosResult = mleBO.updateMle(biosMleData);
    assertEquals("true", biosResult);
    String vmmResult = mleBO.updateMle(vmmMleData);
    assertEquals("true", vmmResult);
}
Also used : TblMle(com.intel.mtwilson.as.data.TblMle) ArrayList(java.util.ArrayList) MleData(com.intel.mtwilson.datatypes.MleData) Matchers.anyString(org.mockito.Matchers.anyString) ManifestData(com.intel.mtwilson.datatypes.ManifestData) Test(org.junit.Test)

Example 5 with ManifestData

use of com.intel.mtwilson.datatypes.ManifestData in project OpenAttestation by OpenAttestation.

the class MleBOTest method testAddMLe.

@Test
public void testAddMLe() {
    TblMle biosMle = null;
    TblMle vmmMle = null;
    TblOem tblOem = new TblOem();
    tblOem.setId(OEM_ID);
    tblOem.setName("DELL");
    TblOs tblOs = new TblOs(OS_ID, "Fedora", "20");
    doReturn(tblOem).when(tblOemJpaController).findTblOemByName(anyString());
    doReturn(tblOs).when(tblOsJpaController).findTblOsByNameVersion(anyString(), anyString());
    doReturn(biosMle).when(tblMleJpaController).findBiosMle(anyString(), anyString(), anyString());
    doReturn(vmmMle).when(tblMleJpaController).findVmmMle(anyString(), anyString(), anyString(), anyString());
    List<ManifestData> biosManifestList = new ArrayList<ManifestData>();
    biosManifestList.add(new ManifestData("0", "31B97D97B4679917EC3C1D943635693FFBAB4143"));
    MleData biosMleData = new MleData("DELL", "A08", MleType.BIOS, AttestationType.PCR, biosManifestList, "", "", "", "DELL");
    List<ManifestData> vmmManifestList = new ArrayList<ManifestData>();
    vmmManifestList.add(new ManifestData("18", "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"));
    MleData vmmMleData = new MleData("XEN", "4.3", MleType.VMM, AttestationType.PCR, vmmManifestList, "", "Fedora", "20", "");
    String biosResult = mleBO.addMLe(biosMleData);
    assertEquals("true", biosResult);
    String vmmResult = mleBO.addMLe(vmmMleData);
    assertEquals("true", vmmResult);
}
Also used : TblMle(com.intel.mtwilson.as.data.TblMle) TblOem(com.intel.mtwilson.as.data.TblOem) ArrayList(java.util.ArrayList) MleData(com.intel.mtwilson.datatypes.MleData) Matchers.anyString(org.mockito.Matchers.anyString) ManifestData(com.intel.mtwilson.datatypes.ManifestData) TblOs(com.intel.mtwilson.as.data.TblOs) Test(org.junit.Test)

Aggregations

ManifestData (com.intel.mtwilson.datatypes.ManifestData)6 TblMle (com.intel.mtwilson.as.data.TblMle)3 TblPcrManifest (com.intel.mtwilson.as.data.TblPcrManifest)3 MleData (com.intel.mtwilson.datatypes.MleData)3 ArrayList (java.util.ArrayList)3 Test (org.junit.Test)2 Matchers.anyString (org.mockito.Matchers.anyString)2 ASException (com.intel.mountwilson.as.common.ASException)1 ASDataException (com.intel.mtwilson.as.controller.exceptions.ASDataException)1 IllegalOrphanException (com.intel.mtwilson.as.controller.exceptions.IllegalOrphanException)1 NonexistentEntityException (com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException)1 TblOem (com.intel.mtwilson.as.data.TblOem)1 TblOs (com.intel.mtwilson.as.data.TblOs)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 NoResultException (javax.persistence.NoResultException)1 MultivaluedMap (javax.ws.rs.core.MultivaluedMap)1