use of com.intel.mtwilson.as.data.TblPcrManifest 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.as.data.TblPcrManifest in project OpenAttestation by OpenAttestation.
the class MleBO method updatePcrManifest.
/**
*
* @param tblMle
* @param mleData
* @throws NonexistentEntityException
* @throws ASDataException
*/
private void updatePcrManifest(TblMle tblMle, MleData mleData) throws NonexistentEntityException, ASDataException {
HashMap<String, String> newPCRMap = getPcrMap(mleData);
if (tblMle.getTblPcrManifestCollection() != null) {
for (TblPcrManifest pcrManifest : tblMle.getTblPcrManifestCollection()) {
if (newPCRMap.containsKey(pcrManifest.getName())) {
log.info(String.format("Updating Pcr manifest value for mle %s version %s pcr name %s", pcrManifest.getMleId().getName(), pcrManifest.getMleId().getVersion(), pcrManifest.getName()));
pcrManifest.setValue(newPCRMap.get(pcrManifest.getName()));
pcrManifestJpaController.edit(pcrManifest);
newPCRMap.remove(pcrManifest.getName());
} else {
log.info(String.format("Deleting Pcr manifest value for mle %s version %s pcr name %s", pcrManifest.getMleId().getName(), pcrManifest.getMleId().getVersion(), pcrManifest.getName()));
pcrManifestJpaController.destroy(pcrManifest.getId());
}
}
for (String pcrName : newPCRMap.keySet()) {
TblPcrManifest pcrManifest = new TblPcrManifest();
pcrManifest.setName(pcrName);
pcrManifest.setValue(newPCRMap.get(pcrName));
pcrManifest.setMleId(tblMle);
log.info(String.format("Creating Pcr manifest value for mle %s version %s pcr name %s", pcrManifest.getMleId().getName(), pcrManifest.getMleId().getVersion(), pcrManifest.getName()));
pcrManifestJpaController.create(pcrManifest);
}
}
}
use of com.intel.mtwilson.as.data.TblPcrManifest in project OpenAttestation by OpenAttestation.
the class MleBOTest method testDeletePCRWhiteList.
@Test
public void testDeletePCRWhiteList() {
doReturn(new TblMle(MLE_ID1, "DELL", "A08", "PCR", "BIOS", "0")).when(tblMleJpaController).findBiosMle("DELL", "A08", "DELL");
doReturn(new TblMle(MLE_ID2, "XEN", "4.3", "PCR", "VMM", "18")).when(tblMleJpaController).findVmmMle("XEN", "4.3", "Fedora", "20");
doReturn(new TblPcrManifest(PcrManifest_ID1, "0", "31B97D97B4679917EC3C1D943635693FFBAB4143")).when(tblPcrManifestJpaController).findByMleIdName(MLE_ID1, "0");
doReturn(new TblPcrManifest(PcrManifest_ID2, "18", "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF")).when(tblPcrManifestJpaController).findByMleIdName(MLE_ID2, "18");
String biosResult = mleBO.deletePCRWhiteList("0", "DELL", "A08", "", "", "DELL");
assertEquals("true", biosResult);
String vmmResult = mleBO.deletePCRWhiteList("18", "XEN", "4.3", "Fedora", "20", "");
assertEquals("true", vmmResult);
}
use of com.intel.mtwilson.as.data.TblPcrManifest in project OpenAttestation by OpenAttestation.
the class MleBOTest method testUpdatePCRWhiteList.
@Test
public void testUpdatePCRWhiteList() {
PCRWhiteList biosPcrData = new PCRWhiteList("0", "31B97D97B4679917EC3C1D943635693FFBAB4143", "DELL", "A08", "", "", "DELL");
PCRWhiteList vmmPcrData = new PCRWhiteList("18", "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", "XEN", "4.3", "Fedora", "20", "");
doReturn(new TblMle(MLE_ID1, "DELL", "A08", "PCR", "BIOS", "0")).when(tblMleJpaController).findBiosMle(biosPcrData.getMleName(), biosPcrData.getMleVersion(), biosPcrData.getOemName());
doReturn(new TblMle(MLE_ID2, "XEN", "4.3", "PCR", "VMM", "18")).when(tblMleJpaController).findVmmMle(vmmPcrData.getMleName(), vmmPcrData.getMleVersion(), vmmPcrData.getOsName(), vmmPcrData.getOsVersion());
doReturn(new TblPcrManifest(PcrManifest_ID1, biosPcrData.getPcrName(), biosPcrData.getPcrDigest())).when(tblPcrManifestJpaController).findByMleIdName(MLE_ID1, biosPcrData.getPcrName());
doReturn(new TblPcrManifest(PcrManifest_ID2, vmmPcrData.getPcrName(), vmmPcrData.getPcrDigest())).when(tblPcrManifestJpaController).findByMleIdName(MLE_ID2, vmmPcrData.getPcrName());
String biosResult = mleBO.updatePCRWhiteList(biosPcrData);
assertEquals("true", biosResult);
String vmmResult = mleBO.updatePCRWhiteList(vmmPcrData);
assertEquals("true", vmmResult);
}
Aggregations