Search in sources :

Example 6 with MleData

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

use of com.intel.mtwilson.datatypes.MleData 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)

Example 8 with MleData

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

the class MLEClientServiceImpl method getMleSourceHost.

/**
         * Retries the name of the host that was used for white listing the MLE.
         * 
         * @param dataVO : Object containing the details of the MLE for which the host information needs to be retrieved.
         * @param apiClientServices: ApiClient object
         * @return : Name of the host
         * @throws WLMPortalException 
         */
@Override
public String getMleSourceHost(MLEDataVO dataVO, WhitelistService apiClientServices) throws WLMPortalException {
    log.info("MLEClientServiceImpl.getMleSourceHost >>");
    String hostName;
    try {
        MleData mleDataObj = ConverterUtil.getMleApiClientObject(dataVO);
        if (dataVO.getOemName() != null) {
            mleDataObj.setOemName(dataVO.getOemName());
            mleDataObj.setOsName("");
            mleDataObj.setOsVersion("");
        } else {
            mleDataObj.setOsName(dataVO.getOsName());
            mleDataObj.setOsVersion(dataVO.getOsVersion());
            mleDataObj.setOemName("");
        }
        hostName = apiClientServices.getMleSource(mleDataObj);
    } catch (Exception e) {
        throw ConnectionUtil.handleException(e);
    }
    log.info("MLEClientServiceImpl.getMleSourceHost <<");
    return hostName;
}
Also used : MleData(com.intel.mtwilson.datatypes.MleData) WLMPortalException(com.intel.mountwilson.common.WLMPortalException)

Example 9 with MleData

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

the class MleBO method createMleDataFromDatabaseRecord.

/**
         * 
         * @param tblMle
         * @param addManifest
         * @return 
         */
public MleData createMleDataFromDatabaseRecord(TblMle tblMle, boolean addManifest) {
    List<ManifestData> manifestList = null;
    if (addManifest) {
        manifestList = new ArrayList<ManifestData>();
        for (TblPcrManifest pcrManifest : tblMle.getTblPcrManifestCollection()) {
            manifestList.add(new ManifestData(pcrManifest.getName(), pcrManifest.getValue()));
        }
    }
    String osName = (tblMle.getOsId() == null) ? null : tblMle.getOsId().getName();
    String osVersion = (tblMle.getOsId() == null) ? null : tblMle.getOsId().getVersion();
    String oemName = (tblMle.getOemId() == null) ? null : tblMle.getOemId().getName();
    MleData s = new MleData(tblMle.getName(), tblMle.getVersion(), MleData.MleType.valueOf(tblMle.getMLEType()), MleData.AttestationType.valueOf(tblMle.getAttestationType()), manifestList, tblMle.getDescription(), osName, osVersion, oemName);
    return s;
}
Also used : MleData(com.intel.mtwilson.datatypes.MleData) TblPcrManifest(com.intel.mtwilson.as.data.TblPcrManifest) ManifestData(com.intel.mtwilson.datatypes.ManifestData)

Example 10 with MleData

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

the class MleBO method listMles.

/**
    * 
    * @param searchCriteria
    * @return 
    */
public List<MleData> listMles(String searchCriteria) {
    List<MleData> mleDataList = new ArrayList<MleData>();
    List<TblMle> tblMleList;
    try {
        if (searchCriteria != null && !searchCriteria.isEmpty())
            tblMleList = mleJpaController.findMleByNameSearchCriteria(searchCriteria);
        else
            tblMleList = mleJpaController.findTblMleEntities();
        if (tblMleList != null) {
            log.info(String.format("Found [%d] mle results for search criteria [%s]", tblMleList.size(), searchCriteria));
            for (TblMle tblMle : tblMleList) {
                MleData mleData = createMleDataFromDatabaseRecord(tblMle, false);
                mleDataList.add(mleData);
            }
        } else {
            log.info(String.format("Found [%d] mle results for search criteria [%s]", 0, searchCriteria));
        }
    } catch (ASException ase) {
        throw ase;
    } catch (Exception e) {
        throw new ASException(e);
    }
    return mleDataList;
}
Also used : TblMle(com.intel.mtwilson.as.data.TblMle) MleData(com.intel.mtwilson.datatypes.MleData) 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)

Aggregations

MleData (com.intel.mtwilson.datatypes.MleData)11 TblMle (com.intel.mtwilson.as.data.TblMle)6 ASException (com.intel.mountwilson.as.common.ASException)4 ASDataException (com.intel.mtwilson.as.controller.exceptions.ASDataException)4 IllegalOrphanException (com.intel.mtwilson.as.controller.exceptions.IllegalOrphanException)4 NonexistentEntityException (com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException)4 ArrayList (java.util.ArrayList)4 NoResultException (javax.persistence.NoResultException)4 ManifestData (com.intel.mtwilson.datatypes.ManifestData)3 MleDetailsEntityVO (com.intel.mountwilson.datamodel.MleDetailsEntityVO)2 MwMleSourceJpaController (com.intel.mtwilson.as.controller.MwMleSourceJpaController)2 MwMleSource (com.intel.mtwilson.as.data.MwMleSource)2 Test (org.junit.Test)2 Matchers.anyString (org.mockito.Matchers.anyString)2 WLMPortalException (com.intel.mountwilson.common.WLMPortalException)1 TblOem (com.intel.mtwilson.as.data.TblOem)1 TblOs (com.intel.mtwilson.as.data.TblOs)1 TblPcrManifest (com.intel.mtwilson.as.data.TblPcrManifest)1