use of com.intel.mtwilson.as.data.TblPcrManifest in project OpenAttestation by OpenAttestation.
the class PcrGKVStrategyTest method mockFindBiosMle.
public TblMle mockFindBiosMle() {
String biosName = "DELL";
String biosVersion = "A08";
String oemName = "DELL";
TblMle biosMle = new TblMle();
biosMle.setId(1);
biosMle.setName(biosName);
biosMle.setVersion(biosVersion);
TblOem oem = new TblOem();
oem.setId(1);
oem.setName(oemName);
biosMle.setOemId(oem);
Collection<TblPcrManifest> tblPcrManifestCollection = new ArrayList<TblPcrManifest>();
TblPcrManifest tblPcrManifest = new TblPcrManifest();
tblPcrManifest.setId(1);
tblPcrManifest.setName("0");
tblPcrManifestCollection.add(tblPcrManifest);
biosMle.setTblPcrManifestCollection(tblPcrManifestCollection);
return biosMle;
}
use of com.intel.mtwilson.as.data.TblPcrManifest 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.as.data.TblPcrManifest 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.as.data.TblPcrManifest in project OpenAttestation by OpenAttestation.
the class MleBO method deleteMle.
/**
*
* @param mleName
* @param mleVersion
* @param osName
* @param osVersion
* @param oemName
* @return
*/
public String deleteMle(String mleName, String mleVersion, String osName, String osVersion, String oemName) {
try {
TblMle tblMle = getMleDetails(mleName, mleVersion, osName, osVersion, oemName);
if (tblMle == null) {
throw new ASException(ErrorCode.WS_MLE_DOES_NOT_EXIST, mleName, mleVersion);
}
Collection<TblHosts> tblHostsCollection;
if (oemName == null || oemName.isEmpty()) {
tblHostsCollection = tblMle.getTblHostsCollection();
} else {
tblHostsCollection = tblMle.getTblHostsCollection1();
}
if (tblHostsCollection != null) {
log.info(String.format("MLE '%s' is currently associated with '%d' hosts. ", mleName, tblHostsCollection.size()));
if (!tblHostsCollection.isEmpty()) {
throw new ASException(ErrorCode.WS_MLE_ASSOCIATION_EXISTS, mleName, mleVersion, tblHostsCollection.size());
}
}
for (TblPcrManifest manifest : tblMle.getTblPcrManifestCollection()) {
pcrManifestJpaController.destroy(manifest.getId());
}
// We also need to delete entries in the MleSource table for the MLE. This table would store the host
// name that was used to white list the MLE.
deleteMleSource(mleName, mleVersion, osName, osVersion, oemName);
mleJpaController.destroy(tblMle.getId());
} catch (ASException ase) {
throw ase;
} catch (Exception e) {
throw new ASException(e);
}
return "true";
}
use of com.intel.mtwilson.as.data.TblPcrManifest in project OpenAttestation by OpenAttestation.
the class MleBO method getPCRWhiteListDetails.
/**
* Added By: Sudhir on June 20, 2012
*
* Retrieves the details of the PCR manifest entry if exists.
*
* @param mle_id : Identity of the MLE
* @param pcrName : Name of the PCR
* @return : Data row containing the PCR manifest details.
*/
private TblPcrManifest getPCRWhiteListDetails(Integer mle_id, String pcrName) {
TblPcrManifest tblPcr;
validateNull("pcrName", pcrName);
tblPcr = pcrManifestJpaController.findByMleIdName(mle_id, pcrName);
return tblPcr;
}
Aggregations