Search in sources :

Example 1 with HostDetailsEntityVO

use of com.intel.mountwilson.datamodel.HostDetailsEntityVO in project OpenAttestation by OpenAttestation.

the class ConverterUtil method getHostVOObjectFromTxtHostRecord.

public static HostDetailsEntityVO getHostVOObjectFromTxtHostRecord(TxtHostRecord txtHostDetail) {
    HostDetailsEntityVO entityVO = new HostDetailsEntityVO();
    entityVO.setHostId(getConvertedHostName(txtHostDetail.HostName));
    entityVO.setHostName(txtHostDetail.HostName);
    entityVO.setHostIPAddress(txtHostDetail.IPAddress);
    entityVO.setHostPort(txtHostDetail.Port.toString());
    entityVO.setHostDescription(txtHostDetail.Description);
    entityVO.setBiosName(txtHostDetail.BIOS_Name);
    entityVO.setBiosBuildNo(txtHostDetail.BIOS_Version);
    entityVO.setVmmName(txtHostDetail.VMM_OSName + " " + txtHostDetail.VMM_OSVersion + HelperConstant.OS_VMM_INFORMATION_SEPERATOR + txtHostDetail.VMM_Name);
    entityVO.setVmmBuildNo(txtHostDetail.VMM_Version);
    entityVO.setvCenterDetails(txtHostDetail.AddOn_Connection_String);
    entityVO.setOemName(txtHostDetail.BIOS_Oem);
    entityVO.setLocation(txtHostDetail.Location);
    entityVO.setEmailAddress(txtHostDetail.Email);
    return entityVO;
}
Also used : HostDetailsEntityVO(com.intel.mountwilson.datamodel.HostDetailsEntityVO)

Example 2 with HostDetailsEntityVO

use of com.intel.mountwilson.datamodel.HostDetailsEntityVO in project OpenAttestation by OpenAttestation.

the class DemoPortalDataController method getHostForViewForPage.

/**
	 * Method to get Host list to for View Host Page for given page no.
	 * 
	 * @param req (HttpServletRequest Object)
	 * @param res (HttpServletResponse Object)
	 * @return
	 */
public ModelAndView getHostForViewForPage(HttpServletRequest req, HttpServletResponse res) {
    log.info("DemoPortalDataController.getHostForViewForPage >>");
    ModelAndView responseView = new ModelAndView(new JSONView());
    try {
        int selectedPage = Integer.parseInt(req.getParameter("pageNo"));
        HttpSession session = req.getSession();
        @SuppressWarnings("unchecked") Map<Integer, List<HostDetailsEntityVO>> mapOfData = (Map<Integer, List<HostDetailsEntityVO>>) session.getAttribute("HostVoList");
        responseView.addObject("hostVo", mapOfData.get(selectedPage));
    } catch (Exception 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.getHostForViewForPage<<<");
    return responseView;
}
Also used : JSONView(com.intel.mountwilson.util.JSONView) HttpSession(javax.servlet.http.HttpSession) HostDetailsEntityVO(com.intel.mountwilson.datamodel.HostDetailsEntityVO) ModelAndView(org.springframework.web.servlet.ModelAndView) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) IOException(java.io.IOException) DemoPortalException(com.intel.mountwilson.common.DemoPortalException) JsonParseException(org.codehaus.jackson.JsonParseException)

Example 3 with HostDetailsEntityVO

use of com.intel.mountwilson.datamodel.HostDetailsEntityVO 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;
}
Also used : TxtHostRecord(com.intel.mtwilson.datatypes.TxtHostRecord) HostDetailsEntityVO(com.intel.mountwilson.datamodel.HostDetailsEntityVO) HostTrustResponse(com.intel.mtwilson.datatypes.HostTrustResponse) TrustAssertion(com.intel.mtwilson.saml.TrustAssertion) HostTrustAssertion(com.intel.mtwilson.saml.TrustAssertion.HostTrustAssertion) Hostname(com.intel.mtwilson.util.net.Hostname) TrustedHostVO(com.intel.mountwilson.datamodel.TrustedHostVO) HostTrustAssertion(com.intel.mtwilson.saml.TrustAssertion.HostTrustAssertion) ApiException(com.intel.mtwilson.ApiException) SignatureException(java.security.SignatureException) IOException(java.io.IOException) DemoPortalException(com.intel.mountwilson.common.DemoPortalException)

Example 4 with HostDetailsEntityVO

use of com.intel.mountwilson.datamodel.HostDetailsEntityVO in project OpenAttestation by OpenAttestation.

the class DemoPortalDataController method getAllHostDetailsFromDB.

/**
	 * This method is used as a utility method to get Map Views for all host based on Page_no value.
	 * 
	 * @param req
	 * @return Map<Integer, List<HostDetailsEntityVO>> 
	 * @throws DemoPortalException
	 */
private Map<Integer, List<HostDetailsEntityVO>> getAllHostDetailsFromDB(HttpServletRequest req) throws DemoPortalException {
    Map<Integer, List<HostDetailsEntityVO>> map = new HashMap<Integer, List<HostDetailsEntityVO>>();
    //Get List of all host available. 
    List<HostDetailsEntityVO> listOfVos = demoPortalServices.getHostListFromDB(getAttestationService(req, AttestationService.class));
    int no_row_per_page = Integer.parseInt(TDPConfig.getConfiguration().getString("mtwilson.tdbp.paginationRowCount"));
    //Divide List of all host into a subList based on the value of host per page. 
    List<List<HostDetailsEntityVO>> list = Lists.partition(listOfVos, no_row_per_page);
    //Creating a Map view of host list based on the Page No.
    int i = 1;
    for (List<HostDetailsEntityVO> listForMap : list) {
        map.put(i, listForMap);
        i++;
    }
    //setting map into session attribute;
    HttpSession session = req.getSession();
    session.setAttribute("HostVoList", map);
    return map;
}
Also used : AttestationService(com.intel.mtwilson.AttestationService) HashMap(java.util.HashMap) HostDetailsEntityVO(com.intel.mountwilson.datamodel.HostDetailsEntityVO) HttpSession(javax.servlet.http.HttpSession) List(java.util.List)

Example 5 with HostDetailsEntityVO

use of com.intel.mountwilson.datamodel.HostDetailsEntityVO in project OpenAttestation by OpenAttestation.

the class DemoPortalDataController method getHostTrustSatusForPageNo.

/**
	 * Method is used to get trust status of host for selected page no.
	 * Method will get called when user choose any page no from pagination.
	 * 
	 * @param req
	 * @param res
	 * @return
	 */
public ModelAndView getHostTrustSatusForPageNo(HttpServletRequest req, HttpServletResponse res) {
    log.info("DemoPortalDataController.getHostTrustSatusForPageNo >>");
    ModelAndView responseView = new ModelAndView(new JSONView());
    try {
        //getting selected Page No.
        int selectedPage = Integer.parseInt(req.getParameter("pageNo"));
        boolean forceVerify = Boolean.parseBoolean(req.getParameter("force_verify"));
        HttpSession session = req.getSession();
        @SuppressWarnings("unchecked") Map<Integer, List<HostDetailsEntityVO>> //getting Map view of all Host stored into session while calling getDashBoardData().
        mapOfData = (Map<Integer, List<HostDetailsEntityVO>>) session.getAttribute("HostVoList");
        //calling into a Service layer to get trust status of Host for selected Page No.
        responseView.addObject("hostVo", demoPortalServices.getTrustStatusForHost(mapOfData.get(selectedPage), getAttestationService(req, AttestationService.class), getTrustedCertificates(req), forceVerify));
        responseView.addObject("noOfPages", mapOfData.size());
    } catch (Exception 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.getHostTrustSatusForPageNo <<");
    return responseView;
}
Also used : JSONView(com.intel.mountwilson.util.JSONView) HttpSession(javax.servlet.http.HttpSession) HostDetailsEntityVO(com.intel.mountwilson.datamodel.HostDetailsEntityVO) ModelAndView(org.springframework.web.servlet.ModelAndView) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) IOException(java.io.IOException) DemoPortalException(com.intel.mountwilson.common.DemoPortalException) JsonParseException(org.codehaus.jackson.JsonParseException)

Aggregations

HostDetailsEntityVO (com.intel.mountwilson.datamodel.HostDetailsEntityVO)6 DemoPortalException (com.intel.mountwilson.common.DemoPortalException)4 IOException (java.io.IOException)4 JSONView (com.intel.mountwilson.util.JSONView)3 HashMap (java.util.HashMap)3 List (java.util.List)3 HttpSession (javax.servlet.http.HttpSession)3 JsonParseException (org.codehaus.jackson.JsonParseException)3 JsonMappingException (org.codehaus.jackson.map.JsonMappingException)3 ModelAndView (org.springframework.web.servlet.ModelAndView)3 Map (java.util.Map)2 TrustedHostVO (com.intel.mountwilson.datamodel.TrustedHostVO)1 ApiException (com.intel.mtwilson.ApiException)1 AttestationService (com.intel.mtwilson.AttestationService)1 HostTrustResponse (com.intel.mtwilson.datatypes.HostTrustResponse)1 TxtHostRecord (com.intel.mtwilson.datatypes.TxtHostRecord)1 TrustAssertion (com.intel.mtwilson.saml.TrustAssertion)1 HostTrustAssertion (com.intel.mtwilson.saml.TrustAssertion.HostTrustAssertion)1 Hostname (com.intel.mtwilson.util.net.Hostname)1 SignatureException (java.security.SignatureException)1