Search in sources :

Example 11 with DemoPortalException

use of com.intel.mountwilson.common.DemoPortalException in project OpenAttestation by OpenAttestation.

the class DemoPortalServicesImpl method getFailureReportData.

/**
	 * This method is used to get failure report for Host. 
	 * 
	 * @param hostName
	 * @param attestationService
	 * @return
	 * @throws DemoPortalException
	 * @throws Exception
	 */
@Override
public List<PcrLogReport> getFailureReportData(String hostName, ApiClient attestationService) throws Exception {
    log.info("DemoPortalServicesImpl.getFailureReportData >>");
    AttestationReport report;
    try {
        report = attestationService.getAttestationReport(new Hostname(hostName));
    } catch (Exception e) {
        log.error(e.getMessage());
        throw ConnectionUtil.handleException(e);
    }
    return report.getPcrLogs();
}
Also used : AttestationReport(com.intel.mtwilson.datatypes.AttestationReport) Hostname(com.intel.mtwilson.util.net.Hostname) ApiException(com.intel.mtwilson.ApiException) SignatureException(java.security.SignatureException) IOException(java.io.IOException) DemoPortalException(com.intel.mountwilson.common.DemoPortalException)

Example 12 with DemoPortalException

use of com.intel.mountwilson.common.DemoPortalException in project OpenAttestation by OpenAttestation.

the class DemoPortalServicesImpl method updateHostData.

/**
	 * This method is used to Update Host information, which was already configure.
	 * 
	 * @param dataVO
	 * @param apiClientServices
	 * @return
	 * @throws DemoPortalException
	 */
@Override
public boolean updateHostData(HostDetailsEntityVO dataVO, AttestationService apiClientServices) throws DemoPortalException {
    boolean result = false;
    try {
        //Call to Services to Update pre-configure host information.
        apiClientServices.updateHost(ConverterUtil.getTxtHostFromHostVO(dataVO));
        // Updating the SAML host report
        apiClientServices.getSamlForHost(new Hostname(dataVO.getHostName()), true);
        result = true;
    } catch (Exception e) {
        log.error("Errror While Updating Host.");
        throw ConnectionUtil.handleException(e);
    }
    return result;
}
Also used : Hostname(com.intel.mtwilson.util.net.Hostname) ApiException(com.intel.mtwilson.ApiException) SignatureException(java.security.SignatureException) IOException(java.io.IOException) DemoPortalException(com.intel.mountwilson.common.DemoPortalException)

Example 13 with DemoPortalException

use of com.intel.mountwilson.common.DemoPortalException in project OpenAttestation by OpenAttestation.

the class DemoPortalDataController method saveNewHostInfo.

public ModelAndView saveNewHostInfo(HttpServletRequest req, HttpServletResponse res) {
    log.info("WLMDataController.saveNewHostInfo >>");
    ModelAndView responseView = new ModelAndView(new JSONView());
    String hostObject = null;
    boolean newhost = false;
    try {
        hostObject = req.getParameter("hostObject");
        newhost = Boolean.parseBoolean(req.getParameter("newhost"));
    } catch (Exception e1) {
        responseView.addObject("result", false);
        responseView.addObject("message", e1.getMessage());
    }
    System.out.println(hostObject);
    ObjectMapper mapper = new ObjectMapper();
    HostDetailsEntityVO dataVO = new HostDetailsEntityVO();
    try {
        dataVO = mapper.readValue(hostObject, HostDetailsEntityVO.class);
    } catch (JsonParseException e) {
        log.error("Error While Parsing request parameters Data. " + e.getMessage());
        responseView.addObject("result", false);
        responseView.addObject("message", "Error While Parsing request parameters Data.");
        return responseView;
    } catch (JsonMappingException e) {
        log.error("Error While Mapping request parameters to Mle Data Object. " + e.getMessage());
        responseView.addObject("result", false);
        responseView.addObject("message", "Error While Mapping request parameters to Mle Data Object.");
        return responseView;
    } catch (IOException e) {
        log.error("IO Exception " + e.getMessage());
        responseView.addObject("result", false);
        responseView.addObject("message", "Error While Mapping request parameters to Mle Data Object.");
        return responseView;
    }
    dataVO.setUpdatedOn(new Date(System.currentTimeMillis()));
    try {
        if (newhost) {
            System.err.println("dataForNew : " + dataVO);
            responseView.addObject("result", demoPortalServices.saveNewHostData(dataVO, getAttestationService(req, AttestationService.class)));
        } else {
            System.err.println("dataForOLD : " + dataVO);
            responseView.addObject("result", demoPortalServices.updateHostData(dataVO, getAttestationService(req, AttestationService.class)));
        }
    } catch (DemoPortalException e) {
        log.error(e.getMessage());
        responseView.addObject("result", false);
        responseView.addObject("message", e.getMessage());
        return responseView;
    }
    log.info("WLMDataController.saveNewHostInfo <<<");
    return responseView;
}
Also used : JSONView(com.intel.mountwilson.util.JSONView) HostDetailsEntityVO(com.intel.mountwilson.datamodel.HostDetailsEntityVO) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) ModelAndView(org.springframework.web.servlet.ModelAndView) IOException(java.io.IOException) DemoPortalException(com.intel.mountwilson.common.DemoPortalException) JsonParseException(org.codehaus.jackson.JsonParseException) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) IOException(java.io.IOException) DemoPortalException(com.intel.mountwilson.common.DemoPortalException) JsonParseException(org.codehaus.jackson.JsonParseException) ObjectMapper(org.codehaus.jackson.map.ObjectMapper) Date(java.util.Date)

Example 14 with DemoPortalException

use of com.intel.mountwilson.common.DemoPortalException in project OpenAttestation by OpenAttestation.

the class DemoPortalDataController method deleteHostDetails.

/**
	 * @param req (HttpServletRequest Object)
	 * @param res (HttpServletResponse Object)
	 * @return
	 */
public ModelAndView deleteHostDetails(HttpServletRequest req, HttpServletResponse res) {
    log.info("DemoPortalDataController.deleteHostDetails >>");
    ModelAndView responseView = new ModelAndView(new JSONView());
    int selectedPage;
    try {
        selectedPage = Integer.parseInt(req.getParameter("selectedPageNo"));
        boolean updateDone = demoPortalServices.deleteHostDetails(req.getParameter("hostID"), req.getParameter("hostName"), getAttestationService(req, AttestationService.class));
        if (updateDone) {
            Map<Integer, List<HostDetailsEntityVO>> mapOfData = getAllHostDetailsFromDB(req);
            if (selectedPage > mapOfData.size()) {
                selectedPage = mapOfData.size();
            }
            responseView.addObject("hostVo", mapOfData.get(selectedPage));
            responseView.addObject("noOfPages", mapOfData.size());
            responseView.addObject("result", updateDone);
        } else {
            log.error("Error Wile deleting OS Data. Server Error.");
            responseView.addObject("result", false);
            responseView.addObject("message", "Api Client return false.");
        }
    } catch (DemoPortalException e) {
        log.error(e.toString());
        e.printStackTrace();
        responseView.addObject("result", false);
        responseView.addObject("message", e.getMessage());
        return responseView;
    }
    responseView.addObject("message", "");
    log.info("DemoPortalDataController.deleteHostDetails<<<");
    return responseView;
}
Also used : JSONView(com.intel.mountwilson.util.JSONView) AttestationService(com.intel.mtwilson.AttestationService) ModelAndView(org.springframework.web.servlet.ModelAndView) List(java.util.List) DemoPortalException(com.intel.mountwilson.common.DemoPortalException)

Example 15 with DemoPortalException

use of com.intel.mountwilson.common.DemoPortalException in project OpenAttestation by OpenAttestation.

the class DemoPortalDataController method getAllHostForView.

/**
	 * Method to get Host list to for View Host page.
	 * 
	 * @param req (HttpServletRequest Object)
	 * @param res (HttpServletResponse Object)
	 * @return
	 */
public ModelAndView getAllHostForView(HttpServletRequest req, HttpServletResponse res) {
    log.info("DemoPortalDataController.getAllHostForView >>");
    Map<Integer, List<HostDetailsEntityVO>> map = null;
    ModelAndView responseView = new ModelAndView(new JSONView());
    try {
        map = getAllHostDetailsFromDB(req);
        responseView.addObject("hostVo", map.get(1));
        responseView.addObject("noOfPages", map.size());
    } catch (DemoPortalException e) {
        log.error(e.toString());
        e.printStackTrace();
        responseView.addObject("hostVo", "");
        responseView.addObject("result", false);
        responseView.addObject("message", e.getMessage());
        return responseView;
    }
    responseView.addObject("result", true);
    responseView.addObject("message", "");
    log.info("DemoPortalDataController.getAllHostForView<<<");
    return responseView;
}
Also used : JSONView(com.intel.mountwilson.util.JSONView) ModelAndView(org.springframework.web.servlet.ModelAndView) List(java.util.List) DemoPortalException(com.intel.mountwilson.common.DemoPortalException)

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