Search in sources :

Example 6 with DemoPortalException

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

Example 7 with DemoPortalException

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

Example 8 with DemoPortalException

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;
}
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 9 with DemoPortalException

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

Example 10 with DemoPortalException

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;
}
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)

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