Example usage for javax.servlet.http HttpServletRequest getParameterMap

List of usage examples for javax.servlet.http HttpServletRequest getParameterMap

Introduction

In this page you can find the example usage for javax.servlet.http HttpServletRequest getParameterMap.

Prototype

public Map<String, String[]> getParameterMap();

Source Link

Document

Returns a java.util.Map of the parameters of this request.

Usage

From source file:be.fedict.eid.idp.sp.protocol.ws_federation.AuthenticationRequestServlet.java

/**
 * {@inheritDoc}/* www . ja  v  a2s.c o  m*/
 */
@SuppressWarnings("unchecked")
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    LOG.debug("doGet");

    String idpDestination;
    String spDestination;
    String context;
    String language;
    String spRealm;

    AuthenticationRequestService service = this.authenticationRequestServiceLocator.locateService();
    if (null != service) {
        idpDestination = service.getIdPDestination();
        context = service.getContext(request.getParameterMap());
        spDestination = service.getSPDestination();
        language = service.getLanguage();
        spRealm = service.getSPRealm();
    } else {
        idpDestination = this.idpDestination;
        context = null;
        if (null != this.spDestination) {
            spDestination = this.spDestination;
        } else {
            spDestination = request.getScheme() + "://" + request.getServerName() + ":"
                    + request.getServerPort() + request.getContextPath() + this.spDestinationPage;
        }
        language = this.language;
        spRealm = this.spRealm;
    }

    String targetUrl;
    if (null == spRealm) {
        targetUrl = idpDestination + "?wa=wsignin1.0" + "&wtrealm=" + spDestination;
    } else {
        targetUrl = idpDestination + "?wa=wsignin1.0" + "&wtrealm=" + spRealm + "&wreply=" + spDestination;
    }

    if (null != language && !language.trim().isEmpty()) {
        targetUrl += "&language=" + language;
    }
    if (null != context && !context.trim().isEmpty()) {
        targetUrl += "&wctx=" + context;
    }

    LOG.debug("targetURL: " + targetUrl);
    response.sendRedirect(targetUrl);

    // save state on session
    if (null == spRealm) {
        setRecipient(spDestination, request.getSession());
    } else {
        setRecipient(spRealm, request.getSession());
    }
    setContext(context, request.getSession());
}

From source file:fr.paris.lutece.plugins.workflow.modules.notifymylutece.web.NotifyMyLuteceTaskComponent.java

/**
 * {@inheritDoc}//from   ww  w  . j  a v  a2 s  .c o  m
 */
@Override
public String doSaveConfig(HttpServletRequest request, Locale locale, ITask task) {
    // In case there are no errors, then the config is created/updated
    boolean bCreate = false;
    TaskNotifyMyLuteceConfig config = _taskNotifyMyLuteceConfigService.findByPrimaryKey(task.getId());

    if (config == null) {
        config = new TaskNotifyMyLuteceConfig();
        config.setIdTask(task.getId());
        bCreate = true;
    }

    try {
        BeanUtils.populate(config, request.getParameterMap());

        String strApply = request.getParameter(PARAMETER_APPLY);

        // Check if the AdminUser clicked on "Apply" or on "Save"
        if (StringUtils.isEmpty(strApply)) {
            String strJspError = validateConfig(config, request);

            if (StringUtils.isNotBlank(strJspError)) {
                return strJspError;
            }
        }

        // The method is overrided becaus of the following setter
        config.setListUserGuid(getSelectedUsers(request, config));

        if (bCreate) {
            _taskNotifyMyLuteceConfigService.create(config);
        } else {
            _taskNotifyMyLuteceConfigService.update(config);
        }
    } catch (IllegalAccessException e) {
        AppLogService.error(e.getMessage(), e);
    } catch (InvocationTargetException e) {
        AppLogService.error(e.getMessage(), e);
    }

    return null;
}

From source file:mx.edu.um.mateo.contabilidad.web.EjercicioController.java

@SuppressWarnings("unchecked")
@RequestMapping//  w  ww . java2s.  c o  m
public String lista(HttpServletRequest request, HttpServletResponse response,
        @RequestParam(required = false) String filtro, @RequestParam(required = false) Long pagina,
        @RequestParam(required = false) String tipo, @RequestParam(required = false) String correo,
        @RequestParam(required = false) String order, @RequestParam(required = false) String sort,
        Model modelo) {
    log.debug("Mostrando lista de ejercicios");
    Map<String, Object> params = this.convierteParams(request.getParameterMap());
    Long organizacionId = (Long) request.getSession().getAttribute("organizacionId");
    params.put("organizacion", organizacionId);

    if (StringUtils.isNotBlank(tipo)) {
        params.put("reporte", true);
        params = ejercicioDao.lista(params);
        try {
            generaReporte(tipo, (List<Ejercicio>) params.get("ejercicios"), response, "ejercicios",
                    Constantes.ORG, organizacionId);
            return null;
        } catch (ReporteException e) {
            log.error("No se pudo generar el reporte", e);
        }
    }

    if (StringUtils.isNotBlank(correo)) {
        params.put("reporte", true);
        params = ejercicioDao.lista(params);

        params.remove("reporte");
        try {
            enviaCorreo(correo, (List<Ejercicio>) params.get("ejercicios"), request, "ejercicios",
                    Constantes.ORG, organizacionId);
            modelo.addAttribute("message", "lista.enviada.message");
            modelo.addAttribute("messageAttrs",
                    new String[] { messageSource.getMessage("ejercicio.lista.label", null, request.getLocale()),
                            ambiente.obtieneUsuario().getUsername() });
        } catch (ReporteException e) {
            log.error("No se pudo enviar el reporte por correo", e);
        }
    }
    params = ejercicioDao.lista(params);
    modelo.addAttribute("ejercicios", params.get("ejercicios"));

    this.pagina(params, modelo, "ejercicios", pagina);

    return "contabilidad/ejercicio/lista";
}

From source file:mx.edu.um.mateo.contabilidad.web.OrdenPagoController.java

@SuppressWarnings("unchecked")
@RequestMapping/*from  www .  ja  v  a2  s. c  o  m*/
public String lista(HttpServletRequest request, HttpServletResponse response,
        @RequestParam(required = false) String filtro, @RequestParam(required = false) Long pagina,
        @RequestParam(required = false) String tipo, @RequestParam(required = false) String correo,
        @RequestParam(required = false) String order, @RequestParam(required = false) String sort,
        Model modelo) {
    log.debug("Mostrando lista de ordenes de pago");
    Map<String, Object> params = this.convierteParams(request.getParameterMap());
    Long empresaId = (Long) request.getSession().getAttribute("empresaId");
    params.put("empresa", empresaId);

    if (StringUtils.isNotBlank(tipo)) {
        params.put("reporte", true);
        params = mgr.lista(params);
        try {
            generaReporte(tipo, (List<OrdenPago>) params.get(Constantes.ORDENPAGO_LIST), response,
                    Constantes.ORDENPAGO_LIST, Constantes.ORG, empresaId);
            return null;
        } catch (ReporteException e) {
            log.error("No se pudo generar el reporte", e);
        }
    }

    if (StringUtils.isNotBlank(correo)) {
        params.put("reporte", true);
        params = mgr.lista(params);

        params.remove("reporte");
        try {
            enviaCorreo(correo, (List<OrdenPago>) params.get(Constantes.ORDENPAGO_LIST), request,
                    Constantes.ORDENPAGO_LIST, Constantes.ORG, empresaId);
            modelo.addAttribute("message", "lista.enviada.message");
            modelo.addAttribute("messageAttrs",
                    new String[] { messageSource.getMessage("ordenPago.lista.label", null, request.getLocale()),
                            ambiente.obtieneUsuario().getUsername() });
        } catch (ReporteException e) {
            log.error("No se pudo enviar el reporte por correo", e);
        }
    }
    params = mgr.lista(params);
    modelo.addAttribute(Constantes.ORDENPAGO_LIST, params.get(Constantes.ORDENPAGO_LIST));

    this.pagina(params, modelo, Constantes.ORDENPAGO_LIST, pagina);

    return Constantes.ORDENPAGO_PATH_LISTA;
}

From source file:pdl.web.filter.RestAuthenticationFilter.java

@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response,
        FilterChain filterChain) throws ServletException, IOException {

    List<String> headerKeys = Arrays.asList(USER_NAME_PARAM, USER_PASS_PARAM);
    Map<String, String> headerAndParms = new HashMap<String, String>();

    // load header values we care about
    Enumeration e = request.getHeaderNames();
    while (e.hasMoreElements()) {
        String key = (String) e.nextElement();

        if (headerKeys.contains(key)) {
            headerAndParms.put(key, request.getHeader(key));
        }//w  w  w .  j a v a2  s . c  om
    }

    // load parameters
    for (Object key : request.getParameterMap().keySet()) {
        String[] o = (String[]) request.getParameterMap().get(key);
        headerAndParms.put((String) key, o[0]);
    }

    String userName = headerAndParms.get(USER_NAME_PARAM);
    String userPasswd = headerAndParms.get(USER_PASS_PARAM);

    if (userName == null || userPasswd == null) {
        response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "REST signature failed validation.");
        return;
    }
    /*catch (Exception e) {
      response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "The REST Security Server experienced an internal error.");
      return;
      }*/

    filterChain.doFilter(request, response);
}

From source file:dk.dma.msiproxy.web.WmsProxyServlet.java

/**
 * Main GET method//from   w ww  .  ja  va  2 s . c o  m
 * @param request servlet request
 * @param response servlet response
 */
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {

    // Cache for a day
    WebUtils.cache(response, CACHE_TIMEOUT);

    // Check that the WMS provider has been defined using system properties
    if (StringUtils.isBlank(wmsServiceName) || StringUtils.isBlank(wmsProvider) || StringUtils.isBlank(wmsLogin)
            || StringUtils.isBlank(wmsPassword)) {
        response.sendRedirect(BLANK_IMAGE);
        return;
    }

    @SuppressWarnings("unchecked")
    Map<String, String[]> paramMap = (Map<String, String[]>) request.getParameterMap();
    String params = paramMap.entrySet().stream().map(p -> String.format("%s=%s", p.getKey(), p.getValue()[0]))
            .collect(Collectors.joining("&"));
    params += String.format("&SERVICENAME=%s&LOGIN=%s&PASSWORD=%s", wmsServiceName, wmsLogin, wmsPassword);

    String url = wmsProvider + "?" + params;
    log.trace("Loading image " + url);

    try {
        BufferedImage image = ImageIO.read(new URL(url));
        if (image != null) {
            image = transformWhiteToTransparent(image);

            OutputStream out = response.getOutputStream();
            ImageIO.write(image, "png", out);
            image.flush();
            out.close();
            return;
        }
    } catch (Exception e) {
        log.trace("Failed loading WMS image for URL " + url);
    }

    // Fall back to return a blank image
    response.sendRedirect(BLANK_IMAGE);
}

From source file:net.sourceforge.fenixedu.presentationTier.util.ExceptionInformation.java

@SuppressWarnings("unchecked")
private Map<String, String> getRequestParameters(HttpServletRequest request) {
    Map<String, String[]> parametersMap = request.getParameterMap();
    final Function<String[], String> valuesJoiner = new Function<String[], String>() {
        @Override//  w ww.  j  ava 2s. c o m
        public String apply(String[] parameters) {
            return Joiner.on(", ").join(parameters);
        }
    };
    return Maps.newHashMap(Maps.transformValues(parametersMap, valuesJoiner));
}

From source file:jp.co.opentone.bsol.linkbinder.view.exception.LinkBinderExceptionHandler.java

private void logRequest(HttpServletRequest req) {
    log.error("Requested: {} {}", req.getMethod(), req.getRequestURI());
    Enumeration<?> enm = req.getHeaderNames();
    log.error("Header:");
    while (enm.hasMoreElements()) {
        String name = (String) enm.nextElement();
        log.error("   {} = {}", name, req.getHeader(name));
    }/*from ww  w. ja va  2 s.com*/

    log.error(" Parameters:");
    @SuppressWarnings("unchecked")
    Map<String, String[]> parameterMap = req.getParameterMap();
    for (Map.Entry<String, String[]> e : parameterMap.entrySet()) {
        log.error("  {} = {}", e.getKey(), StringUtils.join(e.getValue()));
    }
}

From source file:edu.stanford.muse.webapp.JSPHelper.java

private static Map<String, String> convertRequestToMap(HttpServletRequest request) {
    Map<String, String> result = new LinkedHashMap<String, String>();
    Map<String, String[]> map = (Map) request.getParameterMap();
    for (String key : map.keySet()) {
        String[] values = map.get(key);
        if (values == null || values.length == 0)
            result.put(key, "");
        else//from w w w.  j  a  v a2s. c  o  m
            result.put(key, values[0]);
    }
    return result;
}

From source file:fr.paris.lutece.plugins.workflowcore.web.task.TaskComponent.java

/**
* {@inheritDoc}/*from w w w.jav a 2  s . com*/
*/
@Override
public String doSaveConfig(HttpServletRequest request, Locale locale, ITask task) {
    // In case there are no errors, then the config is created/updated
    boolean bCreate = false;
    ITaskConfig config = _taskConfigService.findByPrimaryKey(task.getId());

    if (config == null) {
        config = _taskFactory.newTaskConfig(_taskType.getKey());

        if (config != null) {
            config.setIdTask(task.getId());
            bCreate = true;
        }
    }

    if (config != null) {
        try {
            BeanUtils.populate(config, request.getParameterMap());

            String strApply = request.getParameter(PARAMETER_APPLY);

            // Check if the AdminUser clicked on "Apply" or on "Save"
            if (StringUtils.isEmpty(strApply)) {
                String strJspError = this.validateConfig(config, request);

                if (StringUtils.isNotBlank(strJspError)) {
                    return strJspError;
                }
            }

            if (bCreate) {
                _taskConfigService.create(config);
            } else {
                _taskConfigService.update(config);
            }
        } catch (IllegalAccessException e) {
            _logger.error(e.getMessage(), e);
        } catch (InvocationTargetException e) {
            _logger.error(e.getMessage(), e);
        }
    } else {
        _logger.error("TaskComponent - could not instanciate a new TaskConfig for type " + _taskType.getKey());
    }

    return null;
}