use of com.intel.mountwilson.as.common.ASException in project OpenAttestation by OpenAttestation.
the class Host method get.
/**
* Returns the trust status of a host.
*
* Sample request:
* GET http://localhost:8080/AttestationService/resources/hosts/trust?hostName=Some+TXT+Host
*
* Sample output for untrusted host:
* BIOS:0,VMM:0
*
* Sample output for trusted host:
* BIOS:1,VMM:1
*
* @param hostName unique name of the host to query
* @return a string like BIOS:0,VMM:0 representing the trust status
*/
@GET
@Produces({ MediaType.APPLICATION_JSON })
@Path("/trust")
public HostTrustResponse get(@QueryParam("hostName") String hostName) {
try {
// 0.5.1 returned MediaType.TEXT_PLAIN string like "BIOS:0,VMM:0" : return new HostTrustBO().getTrustStatusString(new Hostname(hostName)); // datatype.Hostname
Hostname hostname = new Hostname(hostName);
HostTrustStatus trust = new ASComponentFactory().getHostTrustBO().getTrustStatus(hostname);
return new HostTrustResponse(hostname, trust);
} catch (ASException e) {
throw e;
} catch (Exception e) {
throw new ASException(e);
}
}
use of com.intel.mountwilson.as.common.ASException in project OpenAttestation by OpenAttestation.
the class CitrixAgentStrategy method getPcrList.
private String getPcrList(TblHosts tblHosts) {
// Get the Bios MLE without accessing cache
TblMle biosMle = new TblMleJpaController(getEntityManagerFactory()).findMleById(tblHosts.getBiosMleId().getId());
String biosPcrList = biosMle.getRequiredManifestList();
if (biosPcrList.isEmpty()) {
throw new ASException(ErrorCode.AS_MISSING_MLE_REQD_MANIFEST_LIST, tblHosts.getBiosMleId().getName(), tblHosts.getBiosMleId().getVersion());
}
// Get the Vmm MLE without accessing cache
TblMle vmmMle = new TblMleJpaController(getEntityManagerFactory()).findMleById(tblHosts.getVmmMleId().getId());
String vmmPcrList = vmmMle.getRequiredManifestList();
if (vmmPcrList == null || vmmPcrList.isEmpty()) {
throw new ASException(ErrorCode.AS_MISSING_MLE_REQD_MANIFEST_LIST, tblHosts.getVmmMleId().getName(), tblHosts.getVmmMleId().getVersion());
}
return biosPcrList + "," + vmmPcrList;
}
use of com.intel.mountwilson.as.common.ASException 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.mountwilson.as.common.ASException 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.mountwilson.as.common.ASException 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";
}
Aggregations