List of usage examples for javax.servlet.http HttpServletRequest getParameterMap
public Map<String, String[]> getParameterMap();
From source file:com.rockagen.gnext.Filter.AccessFilter.java
/** * Save access log/*from ww w . j av a2 s . c o m*/ * @param request {@link HttpServletRequest} */ private void accessLog(HttpServletRequest request) { AccessLog al = new AccessLog(); al.setIp(getIp(request)); al.setMethod(request.getMethod()); al.setReferer(request.getHeader("Referer")); al.setTimeAt(new Date()); al.setUrl(request.getRequestURL().toString()); al.setUserAgent(request.getHeader("User-Agent")); // Translate params Map<String, String> params = translateParaeters(request.getParameterMap()); // protect sensitive value filterParameters(params); al.setParams(params); mongoTemplate.save(al); }
From source file:gxu.software_engineering.shen10.market.core.MappingJacksonJsonpView.java
@Override public void render(Map<String, ?> model, HttpServletRequest request, HttpServletResponse response) throws Exception { // utf8// w w w . j a v a2 s.c om // String charset = response.getCharacterEncoding(); // if (charset == null || charset.length() == 0) { // response.setCharacterEncoding(DEFAULT_CHARSET); // } if (request.getMethod().toUpperCase().equals("GET")) { if (request.getParameterMap().containsKey("callback")) { ServletOutputStream ostream = response.getOutputStream(); // try ostream.write(new String("try{" + request.getParameter("callback") + "(").getBytes()); super.render(model, request, response); ostream.write(new String(");}catch(e){}").getBytes()); // ????closeflushspring? // ? ostream.flush(); ostream.close(); } else { super.render(model, request, response); } } else { super.render(model, request, response); } }
From source file:org.schedoscope.metascope.controller.MetascopeTableController.java
/** * Adds or removes the business objects from the table * * @param request the HTTPServletRequest from the client * @return the same view the user request came from *//*from ww w .j ava 2 s . c om*/ @RequestMapping(value = "/table/categoryobjects", method = RequestMethod.POST) public String addCategoryObject(HttpServletRequest request, RedirectAttributes redirAttr) { Map<String, String[]> parameterMap = request.getParameterMap(); String[] fqdnArr = parameterMap.get("fqdn"); String[] tagArr = parameterMap.get("tags"); String fqdn = null; String tags = null; if (fqdnArr != null && fqdnArr.length > 0) { fqdn = fqdnArr[0]; } if (tagArr != null && tagArr.length > 0) { tags = tagArr[0]; } if (fqdn != null) { metascopeTableService.setCategoryObjects(fqdn, parameterMap); metascopeTableService.setTags(fqdn, tags); } redirAttr.addFlashAttribute("taxonomy", true); return "redirect:" + request.getHeader("Referer") + "#taxonomyContent"; }
From source file:es.logongas.ix3.web.security.AuthorizationInterceptorImplURL.java
public void checkAuthorized(Principal principal, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, DataSession dataSession) throws BusinessSecurityException { String secureResourceTypeName = SECURE_RESOURCE_TYPE_NAME; String secureResource = getSecureURI(httpServletRequest.getRequestURI(), httpServletRequest.getContextPath()); String permissionName = httpServletRequest.getMethod(); Object arguments = getArguments(httpServletRequest.getParameterMap()); boolean isAuthorized = authorizationManager.authorized(principal, secureResourceTypeName, secureResource, permissionName, arguments, dataSession); if (isAuthorized == false) { throw new BusinessSecurityException( "El usuario " + principal + " no tiene acceso a la URL:" + secureResource); }/* w w w. j a v a2 s . co m*/ }
From source file:org.mitre.provenance.openid.OpenId4JavaProxyConsumer.java
public OpenIDAuthenticationToken endConsumption(HttpServletRequest request) throws OpenIDConsumerException { // extract the parameters from the authentication response // (which comes in as a HTTP request from the OpenID provider) ParameterList openidResp = new ParameterList(request.getParameterMap()); // retrieve the previously stored discovery information DiscoveryInformation discovered = (DiscoveryInformation) request.getSession() .getAttribute(DISCOVERY_INFO_KEY); if (discovered == null) { throw new OpenIDConsumerException( "DiscoveryInformation is not available. Possible causes are lost session or replay attack"); }// ww w. j a v a 2 s . com List<OpenIDAttribute> attributesToFetch = (List<OpenIDAttribute>) request.getSession() .getAttribute(ATTRIBUTE_LIST_KEY); request.getSession().removeAttribute(DISCOVERY_INFO_KEY); request.getSession().removeAttribute(ATTRIBUTE_LIST_KEY); // extract the receiving URL from the HTTP request StringBuffer receivingURL = request.getRequestURL(); String queryString = request.getQueryString(); if (StringUtils.hasLength(queryString)) { receivingURL.append("?").append(request.getQueryString()); } // verify the response VerificationResult verification; try { verification = consumerManager.verify(receivingURL.toString(), openidResp, discovered); } catch (MessageException e) { throw new OpenIDConsumerException("Error verifying openid response", e); } catch (DiscoveryException e) { throw new OpenIDConsumerException("Error verifying openid response", e); } catch (AssociationException e) { throw new OpenIDConsumerException("Error verifying openid response", e); } // examine the verification result and extract the verified identifier Identifier verified = verification.getVerifiedId(); if (verified == null) { Identifier id = discovered.getClaimedIdentifier(); return new OpenIDAuthenticationToken(OpenIDAuthenticationStatus.FAILURE, id == null ? "Unknown" : id.getIdentifier(), "Verification status message: [" + verification.getStatusMsg() + "]", Collections.<OpenIDAttribute>emptyList()); } List<OpenIDAttribute> attributes = fetchAxAttributes(verification.getAuthResponse(), attributesToFetch); return new OpenIDAuthenticationToken(OpenIDAuthenticationStatus.SUCCESS, verified.getIdentifier(), "some message", attributes); }
From source file:org.openmrs.module.camerwa.web.controller.CreateRegimenController.java
@Override protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { // TODO Auto-generated method stub ModelAndView mav = new ModelAndView(); CamerwaService camerwaService = Context.getService(CamerwaService.class); //************************************************************** Map requestMap = request.getParameterMap(); List<String> drugRegimens = new ArrayList<String>(); ArrayList<String> fieldNames = new ArrayList<String>(); for (Object va : requestMap.keySet()) { fieldNames.add((String) va); }/*w w w. j a v a 2 s. c o m*/ if (fieldNames.size() != 0) { for (String str : fieldNames) { //System.out.print("!!!!!!!!!!!!!!!!!!!!!!!!!!!! fieldNames "+fieldNames); if (str.contains("_")) { String suffixId = str.substring(str.indexOf("_") + 1); String drugSuffix = "drugs_" + suffixId; if (drugSuffix != null && !drugSuffix.equals("")) { //System.out.println("************************** str ************* "+drugSuffix); drugRegimens.add(request.getParameter(drugSuffix)); } } } } /*System.out.print("!!!!!!!!!!!!!!!!!!!!!!!!!!!! drugRegimens "+drugRegimens); log.info(" ******************* drugRegimens size == "+drugRegimens.size());*/ //************************************************************** String regimenCategory = ServletRequestUtils.getStringParameter(request, "regimenCategory", null); String regimenName = ServletRequestUtils.getStringParameter(request, "regimenName", null); String arvDrug1 = ServletRequestUtils.getStringParameter(request, "arvDrug1", null); //log.info("this is tha drug one displayed 33333333@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"+regimenCategory+"@@@@@@2222222@@@@@@@@@ "+arvDrug1); /*String arvDrug2 = ServletRequestUtils.getStringParameter(request, "arvDrug2", null); String arvDrug3 = ServletRequestUtils.getStringParameter(request, "arvDrug3", null); String arvDrug4 = ServletRequestUtils.getStringParameter(request, "arvDrug4", null);*/ /*boolean ceationOfRegimen = camerwaService.insertRegimen(regimenCategory, regimenName, arvDrug1I, arvDrug2Int, arvDrug3Int, arvDrug4Int); */ if (drugRegimens.size() != 0 || arvDrug1 != null) { //if (!(arvDrug1 == null) || !(drugRegimens.get(0) == null) || !(drugRegimens.get(1) == null) || !(drugRegimens.get(2) == null)) { /*Object arvDrug1Int = camerwaService.getDrugIdByDrugName(arvDrug1); Object arvDrug2Int = camerwaService.getDrugIdByDrugName(arvDrug2); Object arvDrug3Int = camerwaService.getDrugIdByDrugName(arvDrug3); Object arvDrug4Int = camerwaService.getDrugIdByDrugName(arvDrug4);*/ Object arvDrug1Int = null; Object arvDrug2Int = null;// camerwaService.getDrugIdByDrugName(drugRegimens.get(0)); Object arvDrug3Int = null;//= camerwaService.getDrugIdByDrugName(drugRegimens.get(1)); Object arvDrug4Int = null;//= camerwaService.getDrugIdByDrugName(drugRegimens.get(2)); if (arvDrug1 != null) arvDrug1Int = camerwaService.getConceptIdByDrugName(arvDrug1); if (drugRegimens.size() >= 1) arvDrug2Int = camerwaService.getConceptIdByDrugName(drugRegimens.get(0)); if (drugRegimens.size() >= 2) arvDrug3Int = camerwaService.getConceptIdByDrugName(drugRegimens.get(1)); if (drugRegimens.size() >= 3) arvDrug4Int = camerwaService.getConceptIdByDrugName(drugRegimens.get(2)); boolean ceationOfRegimen = camerwaService.insertRegimen(regimenCategory, regimenName, arvDrug1Int, arvDrug2Int, arvDrug3Int, arvDrug4Int); if (ceationOfRegimen) { mav.addObject("regimenHasBeenCreatedMessage", "The regimen (" + regimenName + ") has been created "); } } mav.addObject("regiemenCategoryNames", camerwaService.getRegimenCategories()); // log.info("@@@@@@@@@@@@@@@@@camerwaService.getArvDrugs()camerwaService.getArvDrugs()camerwaService.getArvDrugs()camerwaService.getArvDrugs()camerwaService.getArvDrugs()"+camerwaService.getArvDrugs()); mav.addObject("arvDrugs", camerwaService.getArvDrugs()); mav.setViewName("module/camerwa/createRegimen"); return mav; }
From source file:com.formkiq.core.api.FolderFilesController.java
/** * Folder File List.//from ww w. j a v a2s. com * @param request {@link HttpServletRequest} * @return {@link FolderFormsListDTO} * @throws MissingServletRequestParameterException Exception */ @Transactional @RequestMapping(value = API_FOLDER_FILE_LIST, method = GET) public FolderFormsListDTO filelist(final HttpServletRequest request) throws MissingServletRequestParameterException { Map<String, String[]> map = request.getParameterMap(); String folder = getParameter(map, "folder", true); String uuid = getParameter(map, "uuid", false); String token = getParameter(map, "token", false); List<FolderFormStatus> status = getParameters(map, "status", Arrays.asList(FolderFormStatus.ACTIVE), FolderFormStatus.class); SortDirection dir = getParameter(map, "orderdir", SortDirection.ASC, SortDirection.class); FormOrderByField orderby = getParameter(map, "order", FormOrderByField.NAME, FormOrderByField.class); FolderFormsSearchCriteria criteria = new FolderFormsSearchCriteria(); criteria.setSearchText(getParameter(map, "text", false)); if (map.containsKey("type")) { criteria.setType(getParameter(map, "type", null, ClientFormType.class)); } criteria.setStatus(status); criteria.setSorter(dir); criteria.setOrderby(orderby); return this.folderService.findForms(folder, uuid, criteria, token); }
From source file:com.ikon.servlet.admin.PropertyGroupsServlet.java
/** * Puts the parameterMap into the NavigableMap. The map is polled first twice to save action and label. Then the resulting * array values is saved as a linkedHashMap to save order. * @param request//from ww w. j a v a2 s. c o m * @param response * @throws Exception */ private void writeToPropertyGroupsXML(HttpServletRequest request, HttpServletResponse response) throws Exception { //get values from form and sort it using navigableSet NavigableMap<String, String[]> propertyGroupMap = new TreeMap<String, String[]>(request.getParameterMap()); String action = propertyGroupMap.pollFirstEntry().getValue()[0]; String propertyGroupLabel = propertyGroupMap.pollFirstEntry().getValue()[0]; Map<String, String> propertyMap = new LinkedHashMap<String, String>(); for (String[] values : propertyGroupMap.values()) { propertyMap.put(values[0], values[1]); } XMLUtils xmlUtils = new XMLUtils(PROPERTY_GROUPS_XML); if (action.equals("register")) { xmlUtils.addPropertyGroup(propertyGroupLabel, propertyMap); } else if (action.equals("edit")) { xmlUtils.editPropertyGroup(propertyGroupLabel, propertyMap); } }
From source file:mx.edu.um.mateo.rh.web.DiaFeriadoController.java
@Transactional @RequestMapping(value = "/graba", method = RequestMethod.POST) public String graba(HttpServletRequest request, HttpServletResponse response, @Valid DiaFeriado diaFeriado, BindingResult bindingResult, Errors errors, Model modelo, RedirectAttributes redirectAttributes) { for (String nombre : request.getParameterMap().keySet()) { log.debug("Param: {} : {}", nombre, request.getParameterMap().get(nombre)); }/*from w w w . j av a2 s. c om*/ if (bindingResult.hasErrors()) { log.debug("Hubo algun error en la forma, regresando"); return Constantes.PATH_DIAFERIADO_NUEVO; } try { Usuario usuario = ambiente.obtieneUsuario(); manager.graba(diaFeriado, usuario); } catch (ConstraintViolationException e) { log.error("No se pudo crear dia feriado", e); return Constantes.PATH_DIAFERIADO_NUEVO; } redirectAttributes.addFlashAttribute(Constantes.CONTAINSKEY_MESSAGE, "diaFeriado.graba.message"); redirectAttributes.addFlashAttribute(Constantes.CONTAINSKEY_MESSAGE_ATTRS, new String[] { diaFeriado.getNombre() }); return "redirect:" + Constantes.PATH_DIAFERIADO_LISTA + "/"; }
From source file:com.nexmo.security.RequestSigning.java
/** * looks at the current http request and verifies that the request signature, if supplied is valid. * * @param request The servlet request object to be verified * @param secretKey the pre-shared secret key used by the sender of the request to create the signature * * @return boolean returns true only if the signature is correct for this request and secret key. *//*from w w w.j ava2 s .c o m*/ public static boolean verifyRequestSignature(HttpServletRequest request, String secretKey) { // identify the signature supplied in the request ... String suppliedSignature = request.getParameter(PARAM_SIGNATURE); if (suppliedSignature == null) return false; // Firstly, extract the timestamp parameter and verify that it is within 5 minutes of 'current time' String timeString = request.getParameter(PARAM_TIMESTAMP); long time = -1; try { if (timeString != null) time = Long.parseLong(timeString) * 1000; } catch (NumberFormatException e) { log.debug("Error parsing 'time' parameter [ " + timeString + " ]", e); time = 0; } long diff = System.currentTimeMillis() - time; if (diff > MAX_ALLOWABLE_TIME_DELTA || diff < -MAX_ALLOWABLE_TIME_DELTA) { log.warn("SECURITY-KEY-VERIFICATION -- BAD-TIMESTAMP ... Timestamp [ " + time + " ] delta [ " + diff + " ] max allowed delta [ " + -MAX_ALLOWABLE_TIME_DELTA + " ] "); return false; } // Next, construct a sorted list of the name-value pair parameters supplied in the request, excluding the signature parameter Map<String, String> sortedParams = new TreeMap<>(); for (Map.Entry<String, String[]> entry : request.getParameterMap().entrySet()) { String name = entry.getKey(); String value = entry.getValue()[0]; if (name.equals(PARAM_SIGNATURE)) continue; if (value == null || value.trim().equals("")) continue; sortedParams.put(name, value); } // walk this sorted list of parameters and construct a string StringBuilder sb = new StringBuilder(); for (Map.Entry<String, String> param : sortedParams.entrySet()) { String name = param.getKey(); String value = param.getValue(); sb.append("&").append(clean(name)).append("=").append(clean(value)); } // append the secret key and calculate an md5 signature of the resultant string sb.append(secretKey); String str = sb.toString(); String md5 = "no signature"; try { md5 = MD5Util.calculateMd5(str); } catch (Exception e) { log.error("error...", e); return false; } log.info("SECURITY-KEY-VERIFICATION -- String [ " + str + " ] Signature [ " + md5 + " ] SUPPLIED SIGNATURE [ " + suppliedSignature + " ] "); // verify that the supplied signature matches generated one // use MessageDigest.isEqual as an alternative to String.equals() to defend against timing based attacks try { if (!MessageDigest.isEqual(md5.getBytes("UTF-8"), suppliedSignature.getBytes("UTF-8"))) return false; } catch (UnsupportedEncodingException e) { log.error("This should not occur!!", e); return false; } return true; }