Search in sources :

Example 1 with DemoPortalException

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;
}
Also used : HostType(com.intel.mountwilson.as.hosttrustreport.data.HostType) AttestationService(com.intel.mtwilson.AttestationService) HostsTrustReportType(com.intel.mountwilson.as.hosttrustreport.data.HostsTrustReportType) ArrayList(java.util.ArrayList) Hostname(com.intel.mtwilson.util.net.Hostname) HostReportTypeVO(com.intel.mountwilson.datamodel.HostReportTypeVO) ApiException(com.intel.mtwilson.ApiException) SignatureException(java.security.SignatureException) IOException(java.io.IOException) DemoPortalException(com.intel.mountwilson.common.DemoPortalException)

Example 2 with DemoPortalException

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;
}
Also used : WhitelistService(com.intel.mtwilson.WhitelistService) HashMap(java.util.HashMap) MleDetailsEntityVO(com.intel.mountwilson.datamodel.MleDetailsEntityVO) ApiException(com.intel.mtwilson.ApiException) SignatureException(java.security.SignatureException) IOException(java.io.IOException) DemoPortalException(com.intel.mountwilson.common.DemoPortalException)

Example 3 with DemoPortalException

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;
}
Also used : JSONView(com.intel.mountwilson.util.JSONView) ModelAndView(org.springframework.web.servlet.ModelAndView) DemoPortalException(com.intel.mountwilson.common.DemoPortalException)

Example 4 with DemoPortalException

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;
}
Also used : JSONView(com.intel.mountwilson.util.JSONView) ModelAndView(org.springframework.web.servlet.ModelAndView) DemoPortalException(com.intel.mountwilson.common.DemoPortalException)

Example 5 with DemoPortalException

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;
}
Also used : HttpSession(javax.servlet.http.HttpSession) DemoPortalException(com.intel.mountwilson.common.DemoPortalException) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) IOException(java.io.IOException) DemoPortalException(com.intel.mountwilson.common.DemoPortalException) JsonParseException(org.codehaus.jackson.JsonParseException)

Aggregations

DemoPortalException (com.intel.mountwilson.common.DemoPortalException)17 IOException (java.io.IOException)10 JSONView (com.intel.mountwilson.util.JSONView)8 ModelAndView (org.springframework.web.servlet.ModelAndView)8 ApiException (com.intel.mtwilson.ApiException)7 SignatureException (java.security.SignatureException)7 Hostname (com.intel.mtwilson.util.net.Hostname)5 List (java.util.List)3 JsonParseException (org.codehaus.jackson.JsonParseException)3 JsonMappingException (org.codehaus.jackson.map.JsonMappingException)3 HostDetailsEntityVO (com.intel.mountwilson.datamodel.HostDetailsEntityVO)2 MleDetailsEntityVO (com.intel.mountwilson.datamodel.MleDetailsEntityVO)2 AttestationService (com.intel.mtwilson.AttestationService)2 WhitelistService (com.intel.mtwilson.WhitelistService)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 HttpSession (javax.servlet.http.HttpSession)2 HostType (com.intel.mountwilson.as.hosttrustreport.data.HostType)1 HostsTrustReportType (com.intel.mountwilson.as.hosttrustreport.data.HostsTrustReportType)1 HostReportTypeVO (com.intel.mountwilson.datamodel.HostReportTypeVO)1