use of com.intel.mountwilson.common.DemoPortalException in project OpenAttestation by OpenAttestation.
the class DemoPortalDataController method getOSVMMInfo.
/**
* @param req (HttpServletRequest Object)
* @param res (HttpServletResponse Object)
* @return
*/
public ModelAndView getOSVMMInfo(HttpServletRequest req, HttpServletResponse res) {
log.info("DemoPortalDataController.getOSVMMInfo >>");
ModelAndView responseView = new ModelAndView(new JSONView());
try {
responseView.addObject("osInfo", demoPortalServices.getOSAndVMMInfo(getAttestationService(req, ApiClient.class)));
} catch (DemoPortalException e) {
log.error(e.toString());
e.printStackTrace();
responseView.addObject("osInfo", "");
responseView.addObject("result", false);
responseView.addObject("message", e.getMessage());
return responseView;
}
responseView.addObject("result", true);
responseView.addObject("message", "");
log.info("DemoPortalDataController.getOSVMMInfo <<<");
return responseView;
}
use of com.intel.mountwilson.common.DemoPortalException in project OpenAttestation by OpenAttestation.
the class DemoPortalDataController method getTrustedCertificates.
/**
* This method will return a X509Certificate Object from a Request Session.
* This object is stored into Session at time of user login.
* Check CheckLoginController.java for more Clarification.
*
* @param req
* @return
* @throws DemoPortalException
*/
private X509Certificate[] getTrustedCertificates(HttpServletRequest req) throws DemoPortalException {
HttpSession session = req.getSession(false);
X509Certificate[] trustedCertificate;
if (session != null) {
try {
//getting Object from Session and downcast that object to X509Certificate.
trustedCertificate = (X509Certificate[]) session.getAttribute("trustedCertificates");
} catch (Exception e) {
log.error("Error while creating ApiCliennt Object. " + e.getMessage());
throw new DemoPortalException("Error while creating ApiCliennt Object. " + e.getMessage(), e);
}
} else {
return null;
}
return trustedCertificate;
}
use of com.intel.mountwilson.common.DemoPortalException in project OpenAttestation by OpenAttestation.
the class DemoPortalServicesImpl method deleteHostDetails.
/**
* This method will delete HOST information from Services.
* Also it will delete all entry from HOST VM Mapping information for that host, which is used to store Policy of VM.
*
* @param hostID
* @param hostName
* @param apiClientServices
* @param vmMappingData
* @return
* @throws DemoPortalException
*/
@Override
public boolean deleteHostDetails(String hostID, String hostName, AttestationService apiClientServices) throws DemoPortalException {
boolean result = false;
try {
//Call to Services to delete HOST.
apiClientServices.deleteHost(new Hostname(hostName));
result = true;
} catch (Exception e) {
log.error("Errror While Deleting Host.");
throw ConnectionUtil.handleException(e);
}
return result;
}
use of com.intel.mountwilson.common.DemoPortalException in project OpenAttestation by OpenAttestation.
the class DemoPortalServicesImpl method getAllOemInfo.
/**
* This method is used to get all OEM details from REST Services.
* Call to searchMLE method present in ApiClient class by passing empty string as parameter. this Method will return all MLE from services.
*
* @param client (Object of ApiClient)
* @return
* @throws DemoPortalException
*/
@Override
public Map<String, List<Map<String, String>>> getAllOemInfo(ApiClient client) throws DemoPortalException {
Map<String, List<Map<String, String>>> map = new HashMap<String, List<Map<String, String>>>();
List<MleDetailsEntityVO> mleList = null;
List<Map<String, String>> list = new ArrayList<Map<String, String>>();
try {
WhitelistService service = (WhitelistService) client;
//This statement will get all MLE information from REST services, will get only OEM information from that list.
mleList = ConverterUtil.getMleVOListWhereOEMNotNull(service.searchMLE(""));
//convert data into a MAP of Strings which is used in UI (JQuery) to display on screen.
if (mleList != null && mleList.size() > 0) {
for (MleDetailsEntityVO mleDetailsEntityVO : mleList) {
if (map.get(mleDetailsEntityVO.getOemName()) == null) {
list = new ArrayList<Map<String, String>>();
map.put(mleDetailsEntityVO.getOemName(), list);
} else {
list = map.get(mleDetailsEntityVO.getOemName());
}
Map<String, String> oemInfo = new HashMap<String, String>();
oemInfo.put(mleDetailsEntityVO.getMleName(), mleDetailsEntityVO.getMleVersion());
list.add(oemInfo);
}
} else {
throw new DemoPortalException("Currently no MLEs are configured in the system.");
}
} catch (Exception e) {
throw ConnectionUtil.handleException(e);
}
return map;
}
use of com.intel.mountwilson.common.DemoPortalException in project OpenAttestation by OpenAttestation.
the class DemoPortalServicesImpl method getSingleHostTrust.
/**
* This Method is used to get Trust Status for Single Host.
*
* @param hostName
* @param apiClientServices
* @param trustedCertificates
* @return
* @throws DemoPortalException
*/
@Override
public TrustedHostVO getSingleHostTrust(String hostName, AttestationService apiClientServices, X509Certificate[] trustedCertificates, boolean forceVerify) throws DemoPortalException {
TrustedHostVO hostVO = null;
HostDetailsEntityVO hostDetailsEntityVO = new HostDetailsEntityVO();
hostDetailsEntityVO.setHostName(hostName);
String xmloutput = null;
HostTrustResponse hostTrustResponse = null;
try {
log.info("Getting trust Information for Host " + hostName);
//xmloutput = apiClientServices.getSamlForHost(new Hostname(hostName), false);
// forceVerify=false when loading dashboard, it is true when refreshing host (Refresh button)
xmloutput = apiClientServices.getSamlForHost(new Hostname(hostName), forceVerify);
TrustAssertion trustAssertion = new TrustAssertion(trustedCertificates, xmloutput);
HostTrustAssertion hostTrustAssertion = trustAssertion.getTrustAssertion(hostName);
//Set<Hostname> hostnames = new HashSet<Hostname>();
//hostnames.add(new Hostname(hostName));
//xmloutput = ConverterUtil.formateXMLString(apiClientServices.getSamlForMultipleHosts(hostnames, false));
hostTrustResponse = apiClientServices.getHostTrust(new Hostname(hostDetailsEntityVO.getHostName()));
List<TxtHostRecord> hosts = apiClientServices.queryForHosts(hostDetailsEntityVO.getHostName());
TxtHostRecord txtHostRecord = null;
for (TxtHostRecord record : hosts) {
if (record.HostName.equals(hostDetailsEntityVO.getHostName())) {
txtHostRecord = record;
}
}
hostVO = ConverterUtil.getTrustedHostVoFromHostTrustResponseAndTxtHostRecord(hostTrustResponse, txtHostRecord, hostTrustAssertion);
} catch (Exception e) {
hostVO = ConverterUtil.getTrustedHostVoFromHostTrustResponseAndErrorMessage(hostName, e.getMessage());
}
return hostVO;
}
Aggregations