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