Example usage for javax.servlet.http HttpServletRequest getLocalAddr

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

Introduction

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

Prototype

public String getLocalAddr();

Source Link

Document

Returns the Internet Protocol (IP) address of the interface on which the request was received.

Usage

From source file:com.jd.survey.web.survey.PrivateSurveyController.java

/**
 * Shows a previously submitted survey as read only
 * @param surveyId/*  ww w .j  a v  a 2 s .  c om*/
 * @param principal
 * @param uiModel
 * @param httpServletRequest
 * @return
 */
@Secured({ "ROLE_ADMIN", "ROLE_SURVEY_ADMIN", "ROLE_SURVEY_PARTICIPANT" })
@RequestMapping(value = "/{id}", produces = "text/html")
public String showSurvey(@PathVariable("id") Long surveyId, Principal principal, Model uiModel,
        HttpServletRequest httpServletRequest) {
    log.info("showSurvey surveyId=" + surveyId + " no pageOrder");
    try {
        Survey survey = surveyService.survey_findById(surveyId);
        String login = principal.getName();
        //Check if the user is authorized
        if (!survey.getLogin().equals(login)) {
            log.warn(UNAUTHORIZED_ATTEMPT_TO_ACCESS_SURVEY_WARNING_MESSAGE + surveyId
                    + REQUEST_PATH_WARNING_MESSAGE + httpServletRequest.getPathInfo()
                    + FROM_USER_LOGIN_WARNING_MESSAGE + principal.getName() + FROM_IP_WARNING_MESSAGE
                    + httpServletRequest.getLocalAddr());
            return "accessDenied";

        }

        List<SurveyPage> surveyPages = surveyService.surveyPage_getAll(surveyId,
                messageSource.getMessage(DATE_FORMAT, null, LocaleContextHolder.getLocale()));
        if (survey.getStatus() == SurveyStatus.I) {
            return "redirect:/private/" + encodeUrlPathSegment(surveyId.toString(), httpServletRequest) + "/1";
        } else {
            uiModel.addAttribute("survey_base_path", "private");
            uiModel.addAttribute("survey", survey);
            uiModel.addAttribute("surveyDefinition",
                    surveySettingsService.surveyDefinition_findById(survey.getTypeId()));
            uiModel.addAttribute("surveyPages", surveyPages);
            return "surveys/survey";
        }

    } catch (Exception e) {
        log.error(e.getMessage(), e);
        throw (new RuntimeException(e));
    }
}

From source file:net.groupbuy.plugin.tenpayPartner.TenpayPartnerPlugin.java

@Override
public Map<String, Object> getParameterMap(String sn, String description, HttpServletRequest request) {
    PluginConfig pluginConfig = getPluginConfig();
    Payment payment = getPayment(sn);/*ww  w . j ava 2s  .co  m*/
    Map<String, Object> parameterMap = new HashMap<String, Object>();
    parameterMap.put("trade_mode", "2");
    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 ]", ""), 30));
    parameterMap.put("body",
            StringUtils.abbreviate(description.replaceAll("[^0-9a-zA-Z\\u4e00-\\u9fa5 ]", ""), 30));
    parameterMap.put("trans_type", "1");
    parameterMap.put("seller_id", pluginConfig.getAttribute("partner"));
    parameterMap.put("total_fee", payment.getAmount().multiply(new BigDecimal(100)).setScale(0).toString());
    parameterMap.put("fee_type", "1");
    parameterMap.put("spbill_create_ip", request.getLocalAddr());
    parameterMap.put("attach", "shopxx");
    parameterMap.put("sign", generateSign(parameterMap));
    return parameterMap;
}

From source file:com.dp2345.plugin.tenpayPartner.TenpayPartnerPlugin.java

@Override
public Map<String, Object> getParameterMap(String sn, String description, HttpServletRequest request) {
    PluginConfig pluginConfig = getPluginConfig();
    Payment payment = getPayment(sn);/*from   ww w .jav  a2  s  . c om*/
    Map<String, Object> parameterMap = new HashMap<String, Object>();
    parameterMap.put("trade_mode", "2");
    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 ]", ""), 30));
    parameterMap.put("body",
            StringUtils.abbreviate(description.replaceAll("[^0-9a-zA-Z\\u4e00-\\u9fa5 ]", ""), 30));
    parameterMap.put("trans_type", "1");
    parameterMap.put("seller_id", pluginConfig.getAttribute("partner"));
    parameterMap.put("total_fee", payment.getAmount().multiply(new BigDecimal(100)).setScale(0).toString());
    parameterMap.put("fee_type", "1");
    parameterMap.put("spbill_create_ip", request.getLocalAddr());
    parameterMap.put("attach", "dp2345");
    parameterMap.put("sign", generateSign(parameterMap));
    return parameterMap;
}

From source file:com.jd.survey.web.settings.QuestionController.java

@Secured({ "ROLE_ADMIN", "ROLE_SURVEY_ADMIN" })
@RequestMapping(value = "/{id}", params = "create", produces = "text/html")
public String createQuestion(@PathVariable("id") Long surveyDefinitionPageId, Principal principal,
        Model uiModel, HttpServletRequest httpServletRequest) {
    log.info("createForm(): handles param form");
    try {/*from w  w  w.  j ava 2 s .com*/
        String login = principal.getName();
        User user = userService.user_findByLogin(login);
        SurveyDefinitionPage surveyDefinitionPage = surveySettingsService
                .surveyDefinitionPage_findById(surveyDefinitionPageId);
        //Check if the user is authorized
        if (!securityService.userIsAuthorizedToManageSurvey(surveyDefinitionPage.getSurveyDefinition().getId(),
                user)
                && !securityService.userBelongsToDepartment(
                        surveyDefinitionPage.getSurveyDefinition().getDepartment().getId(), user)) {
            log.warn("Unauthorized access to url path " + httpServletRequest.getPathInfo()
                    + " attempted by user login:" + principal.getName() + "from IP:"
                    + httpServletRequest.getLocalAddr());
            return "accessDenied";
        }
        //User user = userService.user_findByLogin(principal.getName());
        //SurveyDefinitionPage surveyDefinitionPage =  surveySettingsService.surveyDefinitionPage_findById(surveyDefinitionPageId);
        Question question = new Question(surveyDefinitionPage);
        size = (short) question.getPage().getQuestions().size();
        populateEditForm(uiModel, question, user);

        return "settings/questions/create";
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        throw (new RuntimeException(e));
    }
}

From source file:gov.guilin.plugin.tenpayPartner.TenpayPartnerPlugin.java

@Override
public Map<String, Object> getParameterMap(String sn, String description, HttpServletRequest request) {
    PluginConfig pluginConfig = getPluginConfig();
    Payment payment = getPayment(sn);/*from   ww w .j a va 2s . c  om*/
    Map<String, Object> parameterMap = new HashMap<String, Object>();
    parameterMap.put("trade_mode", "2");
    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 ]", ""), 30));
    parameterMap.put("body",
            StringUtils.abbreviate(description.replaceAll("[^0-9a-zA-Z\\u4e00-\\u9fa5 ]", ""), 30));
    parameterMap.put("trans_type", "1");
    parameterMap.put("seller_id", pluginConfig.getAttribute("partner"));
    parameterMap.put("total_fee", payment.getAmount().multiply(new BigDecimal(100)).setScale(0).toString());
    parameterMap.put("fee_type", "1");
    parameterMap.put("spbill_create_ip", request.getLocalAddr());
    parameterMap.put("attach", "guilin");
    parameterMap.put("sign", generateSign(parameterMap));
    return parameterMap;
}

From source file:net.osxx.plugin.tenpayPartner.TenpayPartnerPlugin.java

@Override
public Map<String, Object> getParameterMap(String sn, String description, HttpServletRequest request) {
    PluginConfig pluginConfig = getPluginConfig();
    Payment payment = getPayment(sn);/*from w w  w . j a  va  2  s  . c  o  m*/
    Map<String, Object> parameterMap = new HashMap<String, Object>();
    parameterMap.put("trade_mode", "2");
    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 ]", ""), 30));
    parameterMap.put("body",
            StringUtils.abbreviate(description.replaceAll("[^0-9a-zA-Z\\u4e00-\\u9fa5 ]", ""), 30));
    parameterMap.put("trans_type", "1");
    parameterMap.put("seller_id", pluginConfig.getAttribute("partner"));
    parameterMap.put("total_fee", payment.getAmount().multiply(new BigDecimal(100)).setScale(0).toString());
    parameterMap.put("fee_type", "1");
    parameterMap.put("spbill_create_ip", request.getLocalAddr());
    parameterMap.put("attach", "osxx");
    parameterMap.put("sign", generateSign(parameterMap));
    return parameterMap;
}

From source file:com.sammyun.plugin.tenpayPartner.TenpayPartnerPlugin.java

@Override
public Map<String, Object> getParameterMap(String sn, String description, HttpServletRequest request) {
    PluginConfig pluginConfig = getPluginConfig();
    Payment payment = getPayment(sn);// w  w w .jav  a 2  s.  c  o m
    Map<String, Object> parameterMap = new HashMap<String, Object>();
    parameterMap.put("trade_mode", "2");
    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 ]", ""), 30));
    parameterMap.put("body",
            StringUtils.abbreviate(description.replaceAll("[^0-9a-zA-Z\\u4e00-\\u9fa5 ]", ""), 30));
    parameterMap.put("trans_type", "1");
    parameterMap.put("seller_id", pluginConfig.getAttribute("partner"));
    parameterMap.put("total_fee", payment.getAmount().multiply(new BigDecimal(100)).setScale(0).toString());
    parameterMap.put("fee_type", "1");
    parameterMap.put("spbill_create_ip", request.getLocalAddr());
    parameterMap.put("attach", "preschoolEdu");
    parameterMap.put("sign", generateSign(parameterMap));
    return parameterMap;
}

From source file:net.groupbuy.plugin.tenpayDirect.TenpayDirectPlugin.java

@Override
public Map<String, Object> getParameterMap(String sn, String description, HttpServletRequest request) {
    PluginConfig pluginConfig = getPluginConfig();
    Payment payment = getPayment(sn);/*from  w  w  w  .  j av  a 2  s.com*/
    Map<String, Object> parameterMap = new HashMap<String, Object>();
    parameterMap.put("trade_mode", "1");
    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 ]", ""), 30));
    parameterMap.put("body",
            StringUtils.abbreviate(description.replaceAll("[^0-9a-zA-Z\\u4e00-\\u9fa5 ]", ""), 30));
    parameterMap.put("bank_type", "DEFAULT");
    parameterMap.put("seller_id", pluginConfig.getAttribute("partner"));
    parameterMap.put("total_fee", payment.getAmount().multiply(new BigDecimal(100)).setScale(0).toString());
    parameterMap.put("fee_type", "1");
    parameterMap.put("spbill_create_ip", request.getLocalAddr());
    parameterMap.put("attach", "shopxx");
    parameterMap.put("sign", generateSign(parameterMap));
    return parameterMap;
}

From source file:com.dp2345.plugin.tenpayDirect.TenpayDirectPlugin.java

@Override
public Map<String, Object> getParameterMap(String sn, String description, HttpServletRequest request) {
    PluginConfig pluginConfig = getPluginConfig();
    Payment payment = getPayment(sn);//from  ww w  .  ja va  2s.  c  om
    Map<String, Object> parameterMap = new HashMap<String, Object>();
    parameterMap.put("trade_mode", "1");
    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 ]", ""), 30));
    parameterMap.put("body",
            StringUtils.abbreviate(description.replaceAll("[^0-9a-zA-Z\\u4e00-\\u9fa5 ]", ""), 30));
    parameterMap.put("bank_type", "DEFAULT");
    parameterMap.put("seller_id", pluginConfig.getAttribute("partner"));
    parameterMap.put("total_fee", payment.getAmount().multiply(new BigDecimal(100)).setScale(0).toString());
    parameterMap.put("fee_type", "1");
    parameterMap.put("spbill_create_ip", request.getLocalAddr());
    parameterMap.put("attach", "dp2345");
    parameterMap.put("sign", generateSign(parameterMap));
    return parameterMap;
}

From source file:gov.guilin.plugin.tenpayDirect.TenpayDirectPlugin.java

@Override
public Map<String, Object> getParameterMap(String sn, String description, HttpServletRequest request) {
    PluginConfig pluginConfig = getPluginConfig();
    Payment payment = getPayment(sn);//from w ww .j  av a 2s. co  m
    Map<String, Object> parameterMap = new HashMap<String, Object>();
    parameterMap.put("trade_mode", "1");
    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 ]", ""), 30));
    parameterMap.put("body",
            StringUtils.abbreviate(description.replaceAll("[^0-9a-zA-Z\\u4e00-\\u9fa5 ]", ""), 30));
    parameterMap.put("bank_type", "DEFAULT");
    parameterMap.put("seller_id", pluginConfig.getAttribute("partner"));
    parameterMap.put("total_fee", payment.getAmount().multiply(new BigDecimal(100)).setScale(0).toString());
    parameterMap.put("fee_type", "1");
    parameterMap.put("spbill_create_ip", request.getLocalAddr());
    parameterMap.put("attach", "guilin");
    parameterMap.put("sign", generateSign(parameterMap));
    return parameterMap;
}