use of com.intel.mountwilson.common.DemoPortalException in project OpenAttestation by OpenAttestation.
the class DemoPortalServicesImpl method getHostTrustReport.
@Override
public List<HostReportTypeVO> getHostTrustReport(List<String> hostNames, ApiClient client) throws DemoPortalException {
AttestationService service = (AttestationService) client;
HostsTrustReportType report = null;
List<HostReportTypeVO> hostReportTypeVO = new ArrayList<HostReportTypeVO>();
try {
List<Hostname> hostList = new ArrayList<Hostname>();
for (String host : hostNames) {
hostList.add(new Hostname(host));
}
report = service.getHostTrustReport(hostList);
} catch (Exception e) {
log.error(e.getMessage());
throw ConnectionUtil.handleException(e);
}
List<HostType> list = report.getHost();
for (HostType hostType : list) {
HostReportTypeVO vo = new HostReportTypeVO();
vo.setHostName(hostType.getHostName());
vo.setMleInfo(hostType.getMLEInfo());
vo.setCreatedOn("");
vo.setTrustStatus(hostType.getTrustStatus());
vo.setVerifiedOn(formatter.format(hostType.getVerifiedOn().toGregorianCalendar().getTime()));
hostReportTypeVO.add(vo);
}
return hostReportTypeVO;
}
use of com.intel.mountwilson.common.DemoPortalException in project OpenAttestation by OpenAttestation.
the class DemoPortalServicesImpl method getOSAndVMMInfo.
/**
* This method is used to Get All OS details from REST Services.
*
* @param client (Object of ApiClient)
* @return
* @throws DemoPortalException
*/
@Override
public Map<String, Boolean> getOSAndVMMInfo(ApiClient client) throws DemoPortalException {
List<MleDetailsEntityVO> mleList = null;
//This is a MAP of OS/VMM name and boolean variable which denote about current os/vmm info is VMWare type or not.
Map<String, Boolean> maps = new HashMap<String, Boolean>();
WhitelistService service = (WhitelistService) client;
try {
//Call to REST Services to get all details of MLE, will extract all MLE from that data where OEM info is null.
mleList = ConverterUtil.getMleVOListWhereOEMIsNull(service.searchMLE(""));
for (MleDetailsEntityVO mleDetailsEntityVO : mleList) {
maps.put(ConverterUtil.getOSAndVMMInfoString(mleDetailsEntityVO), mleDetailsEntityVO.getOsName().toLowerCase().contains(HelperConstant.OS_IMAGE_VMWARE.toLowerCase()) ? true : false);
}
} catch (Exception e) {
throw ConnectionUtil.handleException(e);
}
return maps;
}
use of com.intel.mountwilson.common.DemoPortalException in project OpenAttestation by OpenAttestation.
the class DemoPortalDataController method getHostsReport.
/**
* Method to Bulk Update trust status for selected host.
*
* @param req (HttpServletRequest Object)
* @param res (HttpServletResponse Object)
* @return
*/
public ModelAndView getHostsReport(HttpServletRequest req, HttpServletResponse res) {
log.info("DemoPortalDataController.getHostsReport >>");
ModelAndView responseView = new ModelAndView(new JSONView());
String[] list = req.getParameterValues("selectedHost");
if (list == null) {
responseView.addObject("message", "No hosts were selected for reports.");
log.info("DemoPortalDataController.getHostsReport<<<");
return responseView;
}
List<String> hosts = Arrays.asList(list);
try {
responseView.addObject("reports", demoPortalServices.getHostTrustReport(hosts, getAttestationService(req, ApiClient.class)));
responseView.addObject("result", true);
} catch (DemoPortalException e) {
log.error(e.getMessage());
responseView.addObject("result", false);
responseView.addObject("message", e.getMessage());
return responseView;
}
responseView.addObject("message", "");
log.info("DemoPortalDataController.getHostsReport<<<");
return responseView;
}
use of com.intel.mountwilson.common.DemoPortalException in project OpenAttestation by OpenAttestation.
the class DemoPortalDataController method trustVerificationDetailsXML.
/**
* Method to get Trust Verification Details using SAML.
*
* @param req (HttpServletRequest Object)
* @param res (HttpServletResponse Object)
* @return
*/
public ModelAndView trustVerificationDetailsXML(HttpServletRequest req, HttpServletResponse res) {
log.info("DemoPortalDataController.trustVerificationDetailsXML >>");
ModelAndView responseView = new ModelAndView(new JSONView());
String hostName = req.getParameter("hostName");
try {
responseView.addObject("trustSamlDetails", demoPortalServices.trustVerificationDetails(hostName, getAttestationService(req, AttestationService.class), getTrustedCertificates(req)));
responseView.addObject("hostName", hostName);
responseView.addObject("result", true);
} catch (DemoPortalException e) {
log.error(e.toString());
e.printStackTrace();
responseView.addObject("result", false);
responseView.addObject("message", e.getMessage());
e.printStackTrace();
return responseView;
}
responseView.addObject("message", "");
responseView.addObject("result", true);
return responseView;
}
use of com.intel.mountwilson.common.DemoPortalException in project OpenAttestation by OpenAttestation.
the class DemoPortalDataController method getAttestationService.
/**
* This method will return a AttestationService/ApiClient Object from a Session.
* This object is stored into Session at time of user login.
* Check CheckLoginController.java for more Clarification.
*
* @param req
* @return
* @return AttestationService
* @throws DemoPortalException
*/
@SuppressWarnings("unchecked")
private <T> T getAttestationService(HttpServletRequest req, Class<T> type) throws DemoPortalException {
//getting already created session object by passing false while calling into getSession();
HttpSession session = req.getSession(false);
T service = null;
if (session != null) {
try {
//getting ApiClient Object from Session and downcast that object to Type T.
service = (T) session.getAttribute("apiClientObject");
} catch (Exception e) {
log.error("Error while creating ApiCliennt Object. " + e.getMessage());
throw new DemoPortalException("Error while creating ApiCliennt Object. " + e.getMessage(), e);
}
}
return service;
}
Aggregations