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);
}
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);
}
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;
}
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;
}
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;
}
Aggregations