use of com.intel.mountwilson.as.common.ASException in project OpenAttestation by OpenAttestation.
the class CitrixClient method generateNonce.
public String generateNonce() {
try {
// Create a secure random number generator
SecureRandom sr = SecureRandom.getInstance("SHA1PRNG");
// Get 1024 random bits
byte[] bytes = new byte[16];
sr.nextBytes(bytes);
// nonce = new BASE64Encoder().encode( bytes);
String nonce = Base64.encodeBase64String(bytes);
log.info("Nonce Generated " + nonce);
return nonce;
} catch (NoSuchAlgorithmException e) {
throw new ASException(e);
}
}
use of com.intel.mountwilson.as.common.ASException 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.mountwilson.as.common.ASException 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";
}
use of com.intel.mountwilson.as.common.ASException in project OpenAttestation by OpenAttestation.
the class MleBO method updateMle.
/**
*
* @param mleData
* @return
*/
public String updateMle(MleData mleData) {
try {
TblMle tblMle = getMleDetails(mleData.getName(), mleData.getVersion(), mleData.getOsName(), mleData.getOsVersion(), mleData.getOemName());
if (tblMle == null && mleData.getOemName() != null) {
throw new ASException(ErrorCode.WS_MLE_OEM_DOES_NOT_EXIST, mleData.getName(), mleData.getVersion(), mleData.getOemName());
}
if (tblMle == null && mleData.getOsName() != null) {
throw new ASException(ErrorCode.WS_MLE_OS_DOES_NOT_EXIST, mleData.getName(), mleData.getVersion(), mleData.getOsName(), mleData.getOsVersion());
}
setTblMle(tblMle, mleData);
mleJpaController.edit(tblMle);
updatePcrManifest(tblMle, mleData);
} catch (ASException ase) {
throw ase;
} catch (Exception e) {
new ASException(e);
}
return "true";
}
use of com.intel.mountwilson.as.common.ASException in project OpenAttestation by OpenAttestation.
the class MleBO method addMLe.
/**
* For VMM, the OS Name and OS Version in the new MLE must ALREADY be in the
* database, or this method will throw an error.
*
* @param mleData
* @return
*/
public String addMLe(MleData mleData, String mleUuid) {
String osOemUuid = null;
try {
TblMle tblMle = getMleDetails(mleData.getName(), mleData.getVersion(), mleData.getOsName(), mleData.getOsVersion(), mleData.getOemName());
if (tblMle != null) {
throw new ASException(ErrorCode.WS_MLE_ALREADY_EXISTS, mleData.getName());
}
if (mleData.getName().toUpperCase().contains("ESX")) {
String version = getUpperCase(mleData.getVersion()).substring(0, 2);
if (!version.equals("51") && !version.equals("50")) {
throw new ASException(ErrorCode.WS_ESX_MLE_NOT_SUPPORTED);
}
}
if (mleData.getMleType().equals("VMM")) {
TblOs osObj = new TblOsJpaController(getEntityManagerFactory()).findTblOsByNameVersion(mleData.getOsName(), mleData.getOsVersion());
//TblOs osObj = My.jpa().mwOs().findTblOsByNameVersion(mleData.getOsName(), mleData.getOsVersion());
osOemUuid = osObj.getUuid_hex();
} else if (mleData.getMleType().equals("BIOS")) {
TblOem oemObj = new TblOemJpaController(getEntityManagerFactory()).findTblOemByName(mleData.getOemName());
//TblOem oemObj = My.jpa().mwOem().findTblOemByName(mleData.getOemName());
osOemUuid = oemObj.getUuid_hex();
}
/*
if (mleData.getMleType().equalsIgnoreCase("BIOS")){
if (mleData.getManifestList() != null){
for (ManifestData manifestData : mleData.getManifestList()) {
if (Integer.valueOf(manifestData.getName()).intValue() > 5 || Integer.valueOf(manifestData.getName()).intValue() < 0) {
throw new ASException(ErrorCode.WS_MLE_PCR_NOT_VALID, manifestData.getName());
}
}
}
}
if (mleData.getMleType().equalsIgnoreCase("VMM")){
if (mleData.getManifestList() != null){
for (ManifestData manifestData : mleData.getManifestList()) {
if (Integer.valueOf(manifestData.getName()).intValue() > 20 || Integer.valueOf(manifestData.getName()).intValue() < 17) {
throw new ASException(ErrorCode.WS_MLE_PCR_NOT_VALID, manifestData.getName());
}
}
}
}*/
tblMle = getTblMle(mleData, mleUuid, osOemUuid);
mleJpaController.create(tblMle);
addPcrManifest(tblMle, mleData.getManifestList());
} catch (ASException ase) {
throw ase;
} catch (Exception e) {
throw new ASException(e);
}
return "true";
}
Aggregations