List of usage examples for javax.servlet.http HttpServletRequest getLocalAddr
public String getLocalAddr();
From source file:com.dp2345.plugin.alipayBank.AlipayBankPlugin.java
@Override public Map<String, Object> getParameterMap(String sn, String description, HttpServletRequest request) { Setting setting = SettingUtils.get(); PluginConfig pluginConfig = getPluginConfig(); Payment payment = getPayment(sn);//from w ww. j a v a 2 s. c o m Map<String, Object> parameterMap = new HashMap<String, Object>(); parameterMap.put("service", "create_direct_pay_by_user"); parameterMap.put("partner", pluginConfig.getAttribute("partner")); parameterMap.put("_input_charset", "utf-8"); parameterMap.put("sign_type", "MD5"); parameterMap.put("return_url", getNotifyUrl(sn, NotifyMethod.sync)); parameterMap.put("notify_url", getNotifyUrl(sn, NotifyMethod.async)); parameterMap.put("out_trade_no", sn); parameterMap.put("subject", StringUtils.abbreviate(description.replaceAll("[^0-9a-zA-Z\\u4e00-\\u9fa5 ]", ""), 60)); parameterMap.put("body", StringUtils.abbreviate(description.replaceAll("[^0-9a-zA-Z\\u4e00-\\u9fa5 ]", ""), 600)); parameterMap.put("payment_type", "1"); String bank = request.getParameter(BANK_PARAMETER_NAME); parameterMap.put("defaultbank", StringUtils.isNotEmpty(bank) ? bank : DEFAULT_BANK); parameterMap.put("seller_id", pluginConfig.getAttribute("partner")); parameterMap.put("total_fee", payment.getAmount().setScale(2).toString()); parameterMap.put("show_url", setting.getSiteUrl()); parameterMap.put("paymethod", "bankPay"); parameterMap.put("exter_invoke_ip", request.getLocalAddr()); parameterMap.put("extra_common_param", "dp2345"); parameterMap.put("sign", generateSign(parameterMap)); return parameterMap; }
From source file:gov.guilin.plugin.alipayBank.AlipayBankPlugin.java
@Override public Map<String, Object> getParameterMap(String sn, String description, HttpServletRequest request) { Setting setting = SettingUtils.get(); PluginConfig pluginConfig = getPluginConfig(); Payment payment = getPayment(sn);/*from ww w . j a v a2s. c o m*/ Map<String, Object> parameterMap = new HashMap<String, Object>(); parameterMap.put("service", "create_direct_pay_by_user"); parameterMap.put("partner", pluginConfig.getAttribute("partner")); parameterMap.put("_input_charset", "utf-8"); parameterMap.put("sign_type", "MD5"); parameterMap.put("return_url", getNotifyUrl(sn, NotifyMethod.sync)); parameterMap.put("notify_url", getNotifyUrl(sn, NotifyMethod.async)); parameterMap.put("out_trade_no", sn); parameterMap.put("subject", StringUtils.abbreviate(description.replaceAll("[^0-9a-zA-Z\\u4e00-\\u9fa5 ]", ""), 60)); parameterMap.put("body", StringUtils.abbreviate(description.replaceAll("[^0-9a-zA-Z\\u4e00-\\u9fa5 ]", ""), 600)); parameterMap.put("payment_type", "1"); String bank = request.getParameter(BANK_PARAMETER_NAME); parameterMap.put("defaultbank", StringUtils.isNotEmpty(bank) ? bank : DEFAULT_BANK); parameterMap.put("seller_id", pluginConfig.getAttribute("partner")); parameterMap.put("total_fee", payment.getAmount().setScale(2).toString()); parameterMap.put("show_url", setting.getSiteUrl()); parameterMap.put("paymethod", "bankPay"); parameterMap.put("exter_invoke_ip", request.getLocalAddr()); parameterMap.put("extra_common_param", "guilin"); parameterMap.put("sign", generateSign(parameterMap)); return parameterMap; }
From source file:net.osxx.plugin.alipayBank.AlipayBankPlugin.java
@Override public Map<String, Object> getParameterMap(String sn, String description, HttpServletRequest request) { Setting setting = SettingUtils.get(); PluginConfig pluginConfig = getPluginConfig(); Payment payment = getPayment(sn);/*w w w.j av a 2 s .co m*/ Map<String, Object> parameterMap = new HashMap<String, Object>(); parameterMap.put("service", "create_direct_pay_by_user"); parameterMap.put("partner", pluginConfig.getAttribute("partner")); parameterMap.put("_input_charset", "utf-8"); parameterMap.put("sign_type", "MD5"); parameterMap.put("return_url", getNotifyUrl(sn, NotifyMethod.sync)); parameterMap.put("notify_url", getNotifyUrl(sn, NotifyMethod.async)); parameterMap.put("out_trade_no", sn); parameterMap.put("subject", StringUtils.abbreviate(description.replaceAll("[^0-9a-zA-Z\\u4e00-\\u9fa5 ]", ""), 60)); parameterMap.put("body", StringUtils.abbreviate(description.replaceAll("[^0-9a-zA-Z\\u4e00-\\u9fa5 ]", ""), 600)); parameterMap.put("payment_type", "1"); String bank = request.getParameter(BANK_PARAMETER_NAME); parameterMap.put("defaultbank", StringUtils.isNotEmpty(bank) ? bank : DEFAULT_BANK); parameterMap.put("seller_id", pluginConfig.getAttribute("partner")); parameterMap.put("total_fee", payment.getAmount().setScale(2).toString()); parameterMap.put("show_url", setting.getSiteUrl()); parameterMap.put("paymethod", "bankPay"); parameterMap.put("exter_invoke_ip", request.getLocalAddr()); parameterMap.put("extra_common_param", "osxx"); parameterMap.put("sign", generateSign(parameterMap)); return parameterMap; }
From source file:com.jd.survey.web.settings.SurveyDefinitionController.java
/** * Prepares the page to update the survey logo * @param departmentId//w w w. jav a2s . c o m * @param uiModel * @param httpServletRequest * @return */ @Secured({ "ROLE_ADMIN", "ROLE_SURVEY_ADMIN" }) @RequestMapping(value = "/logo", method = RequestMethod.GET, produces = "text/html") public String updateLogoPrepare(@RequestParam(value = "id", required = false) Long surveyDefinitionId, Model uiModel, Principal principal, HttpServletRequest httpServletRequest) { try { User user = userService.user_findByLogin(principal.getName()); //Check if the user is authorized if (!securityService.userIsAuthorizedToManageSurvey(surveyDefinitionId, user)) { log.warn("Unauthorized access to url path " + httpServletRequest.getPathInfo() + " attempted by user login:" + principal.getName() + "from IP:" + httpServletRequest.getLocalAddr()); return "accessDenied"; } uiModel.addAttribute("surveyDefinition", surveySettingsService.surveyDefinition_findById(surveyDefinitionId)); return "settings/surveyDefinitions/logo"; } catch (Exception e) { log.error(e.getMessage(), e); throw (new RuntimeException(e)); } }
From source file:com.sammyun.plugin.alipayBank.AlipayBankPlugin.java
@Override public Map<String, Object> getParameterMap(String sn, String description, HttpServletRequest request) { Setting setting = SettingUtils.get(); PluginConfig pluginConfig = getPluginConfig(); Payment payment = getPayment(sn);//from w w w. java 2 s .c om Map<String, Object> parameterMap = new HashMap<String, Object>(); parameterMap.put("service", "create_direct_pay_by_user"); parameterMap.put("partner", pluginConfig.getAttribute("partner")); parameterMap.put("_input_charset", "utf-8"); parameterMap.put("sign_type", "MD5"); parameterMap.put("return_url", getNotifyUrl(sn, NotifyMethod.sync)); parameterMap.put("notify_url", getNotifyUrl(sn, NotifyMethod.async)); parameterMap.put("out_trade_no", sn); parameterMap.put("subject", StringUtils.abbreviate(description.replaceAll("[^0-9a-zA-Z\\u4e00-\\u9fa5 ]", ""), 60)); parameterMap.put("body", StringUtils.abbreviate(description.replaceAll("[^0-9a-zA-Z\\u4e00-\\u9fa5 ]", ""), 600)); parameterMap.put("payment_type", "1"); String bank = request.getParameter(BANK_PARAMETER_NAME); parameterMap.put("defaultbank", StringUtils.isNotEmpty(bank) ? bank : DEFAULT_BANK); parameterMap.put("seller_id", pluginConfig.getAttribute("partner")); parameterMap.put("total_fee", payment.getAmount().setScale(2).toString()); parameterMap.put("show_url", setting.getSiteUrl()); parameterMap.put("paymethod", "bankPay"); parameterMap.put("exter_invoke_ip", request.getLocalAddr()); parameterMap.put("extra_common_param", "preschoolEdu"); parameterMap.put("sign", generateSign(parameterMap)); return parameterMap; }
From source file:com.jd.survey.web.settings.SurveyDefinitionController.java
/** * Updates the survey logo/*from w ww. ja v a 2 s . co m*/ * @param file * @param surveyDefinitionId * @param proceed * @param principal * @param uiModel * @param httpServletRequest * @return */ @SuppressWarnings("unchecked") @Secured({ "ROLE_ADMIN", "ROLE_SURVEY_ADMIN" }) @RequestMapping(value = "/logo", method = RequestMethod.POST, produces = "text/html") public String updateLogo(@RequestParam("file") MultipartFile file, @RequestParam("id") Long surveyDefinitionId, @RequestParam(value = "_proceed", required = false) String proceed, Principal principal, Model uiModel, HttpServletRequest httpServletRequest) { try { User user = userService.user_findByLogin(principal.getName()); //Check if the user is authorized if (!securityService.userIsAuthorizedToManageSurvey(surveyDefinitionId, user)) { log.warn("Unauthorized access to url path " + httpServletRequest.getPathInfo() + " attempted by user login:" + principal.getName() + "from IP:" + httpServletRequest.getLocalAddr()); return "accessDenied"; } GlobalSettings globalSettings = applicationSettingsService.getSettings(); //validate content type if (file.isEmpty() || !globalSettings.getValidImageTypesAsList().contains(file.getContentType().toLowerCase())) { uiModel.addAttribute("surveyDefinition", surveySettingsService.surveyDefinition_findById(surveyDefinitionId)); uiModel.addAttribute("invalidFile", true); return "settings/surveyDefinitions/logo"; } SurveyDefinition surveyDefinition = surveySettingsService .surveyDefinition_updateLogo(surveyDefinitionId, file.getBytes()); uiModel.asMap().clear(); return "settings/surveyDefinitions/saved"; } catch (Exception e) { log.error(e.getMessage(), e); throw (new RuntimeException(e)); } }
From source file:com.jd.survey.web.settings.SurveyDefinitionController.java
@Secured({ "ROLE_ADMIN", "ROLE_SURVEY_ADMIN" }) @RequestMapping(value = "/browsetemplate", produces = "text/html") public String browseTemplate(@RequestParam(value = "id", required = false) Long departmentId, @RequestParam(value = "sid", required = false) Long sectorId, Principal principal, Model uiModel, HttpServletRequest httpServletRequest) { try {/* w ww . j a v a 2 s . c o m*/ String login = principal.getName(); User user = userService.user_findByLogin(login); //Check if the user is authorized if (!securityService.userBelongsToDepartment(departmentId, user)) { log.warn("Unauthorized access to url path " + httpServletRequest.getPathInfo() + " attempted by user login:" + principal.getName() + "from IP:" + httpServletRequest.getLocalAddr()); return "accessDenied"; } uiModel.addAttribute("department", surveySettingsService.department_findById(departmentId)); uiModel.addAttribute("sector", surveySettingsService.sector_findById(sectorId)); uiModel.addAttribute("templates", surveySettingsService.surveyTemplate_findBySectorId(sectorId)); return "settings/surveyDefinitions/browsetemplate"; } catch (Exception e) { log.error(e.getMessage(), e); throw (new RuntimeException(e)); } }
From source file:net.groupbuy.plugin.unionpay.UnionpayPlugin.java
@Override public Map<String, Object> getParameterMap(String sn, String description, HttpServletRequest request) { Setting setting = SettingUtils.get(); PluginConfig pluginConfig = getPluginConfig(); Payment payment = getPayment(sn);//from w w w . j a v a2s. co m Map<String, Object> parameterMap = new HashMap<String, Object>(); parameterMap.put("version", "1.0.0"); parameterMap.put("charset", "UTF-8"); parameterMap.put("transType", "01"); parameterMap.put("origQid", ""); parameterMap.put("merId", pluginConfig.getAttribute("partner")); parameterMap.put("merAbbr", StringUtils.abbreviate(setting.getSiteName().replaceAll("[^0-9a-zA-Z\\u4e00-\\u9fa5 ]", ""), 40)); parameterMap.put("acqCode", ""); parameterMap.put("merCode", ""); parameterMap.put("commodityUrl", setting.getSiteUrl()); parameterMap.put("commodityName", StringUtils.abbreviate(description.replaceAll("[^0-9a-zA-Z\\u4e00-\\u9fa5 ]", ""), 200)); parameterMap.put("commodityUnitPrice", ""); parameterMap.put("commodityQuantity", ""); parameterMap.put("commodityDiscount", ""); parameterMap.put("transferFee", ""); parameterMap.put("orderNumber", sn); parameterMap.put("orderAmount", payment.getAmount().multiply(new BigDecimal(100)).setScale(0).toString()); parameterMap.put("orderCurrency", CURRENCY); parameterMap.put("orderTime", new SimpleDateFormat("yyyyMMddHHmmss").format(new Date())); parameterMap.put("customerIp", request.getLocalAddr()); parameterMap.put("customerName", ""); parameterMap.put("defaultPayType", ""); parameterMap.put("defaultBankNumber", ""); parameterMap.put("transTimeout", getTimeout() * 60000); parameterMap.put("frontEndUrl", getNotifyUrl(sn, NotifyMethod.sync)); parameterMap.put("backEndUrl", getNotifyUrl(sn, NotifyMethod.async)); parameterMap.put("merReserved", ""); parameterMap.put("signMethod", "MD5"); parameterMap.put("signature", generateSign(parameterMap)); return parameterMap; }
From source file:com.jd.survey.web.settings.SurveyDefinitionController.java
@Secured({ "ROLE_ADMIN", "ROLE_SURVEY_ADMIN" }) @RequestMapping(value = "/importtemplate", method = RequestMethod.POST, produces = "text/html") public String importTemplatePost(@RequestParam("id") Long departmentId, @RequestParam("secId") Long sectorId, @RequestParam(value = "_proceed", required = false) String proceed, Principal principal, Model uiModel, HttpServletRequest httpServletRequest) { try {/*ww w. ja v a2 s . co m*/ String login = principal.getName(); User user = userService.user_findByLogin(login); //Check if the user is authorized if (!securityService.userBelongsToDepartment(departmentId, user)) { log.warn("Unauthorized access to url path " + httpServletRequest.getPathInfo() + " attempted by user login:" + principal.getName() + "from IP:" + httpServletRequest.getLocalAddr()); return "accessDenied"; } if (proceed != null) { uiModel.addAttribute("department", surveySettingsService.department_findById(departmentId)); uiModel.addAttribute("sector", surveySettingsService.sector_findById(sectorId)); uiModel.addAttribute("templates", surveySettingsService.surveyTemplate_findBySectorId(sectorId)); return "redirect:/settings/surveyDefinitions/browsetemplate?id=" + encodeUrlPathSegment(departmentId.toString(), httpServletRequest) + "&sid=" + encodeUrlPathSegment(sectorId.toString(), httpServletRequest); } else { //Cancel button return "settings/surveyDefinitions"; } } catch (Exception e) { log.error(e.getMessage(), e); throw (new RuntimeException(e)); } }
From source file:com.jd.survey.web.settings.SurveyDefinitionController.java
/** * changes the state of a previously published survey to inactive, Survey participant can no longer create new surveys of this type, * but they may however finish an existing incomplete survey * @param surveyDefinitionId//ww w .j a v a 2s . co m * @param response * @param httpServletRequest * @param uiModel * @return */ @Secured({ "ROLE_ADMIN", "ROLE_SURVEY_ADMIN" }) @RequestMapping(value = "/{id}", params = "unpublish", produces = "text/html") public String DeactivateSurveyDefinition(@PathVariable("id") Long surveyDefinitionId, HttpServletResponse response, Principal principal, Model uiModel, HttpServletRequest httpServletRequest) { try { String login = principal.getName(); User user = userService.user_findByLogin(login); //Check if the user is authorized if (!securityService.userIsAuthorizedToManageSurvey(surveyDefinitionId, user)) { log.warn("Unauthorized access to url path " + httpServletRequest.getPathInfo() + " attempted by user login:" + principal.getName() + "from IP:" + httpServletRequest.getLocalAddr()); return "accessDenied"; } SurveyDefinition surveyDefinition = surveySettingsService .surveyDefinition_deactivate(surveyDefinitionId); return "redirect:/settings/surveyDefinitions/" + encodeUrlPathSegment(surveyDefinitionId.toString(), httpServletRequest); } catch (Exception e) { log.error(e.getMessage(), e); throw (new RuntimeException(e)); } }