use of com.intel.mtwilson.as.data.TblMle in project OpenAttestation by OpenAttestation.
the class MleBO method getTblMle.
/**
*
* @param mleData
* @return
*/
private TblMle getTblMle(MleData mleData, String mleUuid, String osOemUuid) {
TblMle tblMle = new TblMle();
tblMle.setMLEType(mleData.getMleType());
tblMle.setName(mleData.getName());
tblMle.setVersion(mleData.getVersion());
tblMle.setAttestationType(mleData.getAttestationType());
tblMle.setDescription(mleData.getDescription());
tblMle.setRequiredManifestList(getRequiredManifestList(mleData.getManifestList()));
if (mleUuid != null && !mleUuid.isEmpty()) {
tblMle.setUuid_hex(mleUuid);
} else {
tblMle.setUuid_hex(new UUID().toString());
}
if (mleData.getMleType().equals("VMM")) {
tblMle.setOsId(getTblOs(mleData.getOsName(), mleData.getOsVersion()));
tblMle.setOs_uuid_hex(osOemUuid);
} else if (mleData.getMleType().equals("BIOS")) {
tblMle.setOemId(getTblOem(mleData.getOemName()));
tblMle.setOem_uuid_hex(osOemUuid);
}
return tblMle;
}
use of com.intel.mtwilson.as.data.TblMle in project OpenAttestation by OpenAttestation.
the class MleBO method updateMleSource.
/**
* Updates an existing MLE with the name of the white list host that was used to modify the white list values.
* @param mleSourceObj
* @return
*/
public String updateMleSource(MleSource mleSourceObj) {
TblMle tblMle;
MleData mleData = null;
try {
try {
mleData = mleSourceObj.getMleData();
// Verify if the MLE exists in the system.
tblMle = getMleDetails(mleData.getName(), mleData.getVersion(), mleData.getOsName(), mleData.getOsVersion(), mleData.getOemName());
} catch (NoResultException nre) {
throw new ASException(nre, ErrorCode.WS_MLE_DOES_NOT_EXIST, mleData.getName(), mleData.getVersion());
}
MwMleSourceJpaController mleSourceJpaController = new MwMleSourceJpaController(getEntityManagerFactory());
// If the mapping does not exist already in the db, then we need to return back error.
MwMleSource mwMleSource = mleSourceJpaController.findByMleId(tblMle.getId());
if (mwMleSource == null) {
throw new ASException(ErrorCode.WS_MLE_SOURCE_MAPPING_DOES_NOT_EXIST, mleData.getName());
}
mwMleSource.setHostName(mleSourceObj.getHostName());
mleSourceJpaController.edit(mwMleSource);
} catch (ASException ase) {
throw ase;
} catch (Exception e) {
throw new ASException(e);
}
return "true";
}
use of com.intel.mtwilson.as.data.TblMle in project OpenAttestation by OpenAttestation.
the class MleBO method deleteMleSource.
/**
* Deletes an existing mapping between the MLE and the WhiteList host that was used during the creation of MLE.
* This method is called during the deletion of MLEs.
*
* @param mleName
* @param mleVersion
* @param osName
* @param osVersion
* @param oemName
* @return
*/
public String deleteMleSource(String mleName, String mleVersion, String osName, String osVersion, String oemName) {
TblMle tblMle;
try {
try {
// First check if the entry exists in the MLE table.
tblMle = getMleDetails(mleName, mleVersion, osName, osVersion, oemName);
} catch (NoResultException nre) {
throw new ASException(nre, ErrorCode.WS_MLE_DOES_NOT_EXIST, mleName, mleVersion);
}
MwMleSourceJpaController mleSourceJpaController = new MwMleSourceJpaController(getEntityManagerFactory());
MwMleSource mwMleSource = mleSourceJpaController.findByMleId(tblMle.getId());
// configured manully, this entry does not exist.
if (mwMleSource != null)
mleSourceJpaController.destroy(mwMleSource.getId());
} catch (ASException ase) {
throw ase;
} catch (Exception e) {
throw new ASException(e);
}
return "true";
}
use of com.intel.mtwilson.as.data.TblMle 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.TblMle in project OpenAttestation by OpenAttestation.
the class MleBO method deletePCRWhiteList.
/**
*
* Added By: Sudhir on June 20, 2012
*
* Processes the delete request for an existing PCR white list for the specified MLE.
*
* @param pcrName : Name of the PCR, which is usually the number
* @param mleName : Name of the associated MLE
* @param mleVersion : Version of the associated MLE
* @param osName : OS name associated with the VMM MLE
* @param osVersion : OS version associated with the VMM MLE
* @param oemName : OEM Name associated with the BIOS MLE
* @return
*/
public String deletePCRWhiteList(String pcrName, String mleName, String mleVersion, String osName, String osVersion, String oemName) {
TblPcrManifest tblPcr;
TblMle tblMle;
try {
tblMle = getMleDetails(mleName, mleVersion, osName, osVersion, oemName);
if (tblMle == null && oemName != null) {
throw new ASException(ErrorCode.WS_MLE_OEM_DOES_NOT_EXIST, mleName, mleVersion, oemName);
}
if (tblMle == null && osName != null) {
throw new ASException(ErrorCode.WS_MLE_OS_DOES_NOT_EXIST, mleName, mleVersion, osName, osVersion);
}
// Now we need to check if PCR value exists. If it does, then we do delete or else
// we still return true since the data does not exist.
tblPcr = getPCRWhiteListDetails(tblMle.getId(), pcrName);
if (tblPcr == null) {
return "true";
}
// Delete the PCR white list entry.
pcrManifestJpaController.destroy(tblPcr.getId());
} catch (ASException ase) {
throw ase;
} catch (Exception e) {
throw new ASException(e);
}
return "true";
}
Aggregations