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:net.groupbuy.plugin.alipayPartner.AlipayPartnerPlugin.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 a va 2 s .  c om
    Map<String, Object> parameterMap = new HashMap<String, Object>();
    parameterMap.put("service", "create_partner_trade_by_buyer");
    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");
    parameterMap.put("logistics_type", "EXPRESS");
    parameterMap.put("logistics_fee", "0");
    parameterMap.put("logistics_payment", "SELLER_PAY");
    parameterMap.put("price", payment.getAmount().setScale(2).toString());
    parameterMap.put("quantity", "1");
    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", "directPay");
    parameterMap.put("exter_invoke_ip", request.getLocalAddr());
    parameterMap.put("extra_common_param", "groupbuy");
    parameterMap.put("sign", generateSign(parameterMap));
    return parameterMap;
}

From source file:net.shopxx.plugin.alipayPartner.AlipayPartnerPlugin.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 o m*/
    Map<String, Object> parameterMap = new HashMap<String, Object>();
    parameterMap.put("service", "create_partner_trade_by_buyer");
    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");
    parameterMap.put("logistics_type", "EXPRESS");
    parameterMap.put("logistics_fee", "0");
    parameterMap.put("logistics_payment", "SELLER_PAY");
    parameterMap.put("price", payment.getAmount().setScale(2).toString());
    parameterMap.put("quantity", "1");
    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", "directPay");
    parameterMap.put("exter_invoke_ip", request.getLocalAddr());
    parameterMap.put("extra_common_param", "shopxx");
    parameterMap.put("sign", generateSign(parameterMap));
    return parameterMap;
}

From source file:com.dp2345.plugin.alipayPartner.AlipayPartnerPlugin.java

@Override
public Map<String, Object> getParameterMap(String sn, String description, HttpServletRequest request) {
    Setting setting = SettingUtils.get();
    PluginConfig pluginConfig = getPluginConfig();
    Payment payment = getPayment(sn);//  ww w  .j a v a 2 s  .  c om
    Map<String, Object> parameterMap = new HashMap<String, Object>();
    parameterMap.put("service", "create_partner_trade_by_buyer");
    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");
    parameterMap.put("logistics_type", "EXPRESS");
    parameterMap.put("logistics_fee", "0");
    parameterMap.put("logistics_payment", "SELLER_PAY");
    parameterMap.put("price", payment.getAmount().setScale(2).toString());
    parameterMap.put("quantity", "1");
    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", "directPay");
    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.alipayPartner.AlipayPartnerPlugin.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 . java2s  . c o  m*/
    Map<String, Object> parameterMap = new HashMap<String, Object>();
    parameterMap.put("service", "create_partner_trade_by_buyer");
    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");
    parameterMap.put("logistics_type", "EXPRESS");
    parameterMap.put("logistics_fee", "0");
    parameterMap.put("logistics_payment", "SELLER_PAY");
    parameterMap.put("price", payment.getAmount().setScale(2).toString());
    parameterMap.put("quantity", "1");
    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", "directPay");
    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.alipayPartner.AlipayPartnerPlugin.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   www . j ava2s . co  m
    Map<String, Object> parameterMap = new HashMap<String, Object>();
    parameterMap.put("service", "create_partner_trade_by_buyer");
    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");
    parameterMap.put("logistics_type", "EXPRESS");
    parameterMap.put("logistics_fee", "0");
    parameterMap.put("logistics_payment", "SELLER_PAY");
    parameterMap.put("price", payment.getAmount().setScale(2).toString());
    parameterMap.put("quantity", "1");
    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", "directPay");
    parameterMap.put("exter_invoke_ip", request.getLocalAddr());
    parameterMap.put("extra_common_param", "osxx");
    parameterMap.put("sign", generateSign(parameterMap));
    return parameterMap;
}

From source file:siddur.solidtrust.site.APIController.java

@RequestMapping(value = "/car_manual")
public @ResponseBody Object carManual(@RequestParam("brand") String brand, @RequestParam("model") String model,
        HttpServletRequest request, HttpServletResponse resp) {
    resp.setHeader("Access-Control-Allow-Origin", "*");
    AccessItem ai = new AccessItem();
    ai.setRequest(brand + " " + model);
    ai.setIp(request.getRemoteHost());/*from w  w w .j  av  a 2  s  .  c o m*/
    ai.setUsername(request.getAttribute(SolidtrustConstants.CLIENT_ID) + "");
    ai.setService(Product.CAR_MANUAL.getId());

    final String address = request.getLocalAddr();
    final int port = request.getLocalPort();
    String portStr = port == 80 ? "" : ":" + port;
    String prex = "http://" + address + portStr + "/solidtrust/images/";

    Object result = null;
    try {
        List<Manual> list = manualRep.findByBrandAndModel(brand, model);
        if (list.size() > 0) {
            siddur.solidtrust.manual.Car car = new siddur.solidtrust.manual.Car();
            Manual m = list.get(0);
            car.setAcceleration(m.getAcceleration());
            car.setAverageMileage(m.getAverageMileage());
            car.setBrand(m.getBrand());
            car.setBuildFrom(m.getBuildFrom());
            car.setBuildTo(m.getBuildTo());
            car.setImage(prex + m.getImage() + "_1.jpg");
            car.setModel(m.getModel());
            car.setNewPrice(m.getNewPrice());
            car.setRoadTax(m.getRoadTax());
            car.setTireSize(m.getTireSize());
            car.setTopspeed(m.getTopspeed());
            for (Manual manual : list) {
                String[] files = manual.getManual().split(";");
                for (String f : files) {
                    ManualItem mi = new ManualItem();
                    mi.setBuildYear(manual.getBuild());
                    mi.setImage(prex + manual.getImage() + "_1.jpg");
                    mi.setUrl(f);
                    car.getManual().add(mi);
                }
            }
            result = car;
        }
    } catch (Exception e) {
        ai.setStatus(-1);
        log4j.info(e.getMessage(), e);
    }
    if (result == null) {
        result = "no data";
        ai.setStatus(0);
    }
    ai.setResponse(result + "");
    free.save(ai);
    return result;
}

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

/**
 * Updates a survey definition   /* w  ww . j av  a  2  s .co  m*/
 * @param proceed
 * @param surveyDefinition
 * @param bindingResult
 * @param uiModel
 * @param httpServletRequest
 * @param principal
 * @return
 */
@Secured({ "ROLE_ADMIN", "ROLE_SURVEY_ADMIN" })
@RequestMapping(method = RequestMethod.PUT, produces = "text/html")
public String update(@RequestParam(value = "_proceed", required = false) String proceed,
        @Valid SurveyDefinition surveyDefinition, BindingResult bindingResult, 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(surveyDefinition.getId(), user)
                && !securityService.userBelongsToDepartment(surveyDefinition.getDepartment().getId(), 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) {
            if (bindingResult.hasErrors()) {
                populateEditForm(uiModel, surveyDefinition, user);
                return "settings/surveyDefinitions/update";
            }
            if (!surveySettingsService.surveyDefinition_ValidateNameIsUnique(surveyDefinition)) {
                bindingResult.rejectValue("name", "field_unique");
                populateEditForm(uiModel, surveyDefinition, user);
                return "settings/surveyDefinitions/update";
            }
            System.out.println("!!!!!!!!! MD: " + surveyDefinition.getAllowMultipleSubmissions()
                    + " #################### PUB: " + surveyDefinition.getIsPublic());
            Policy emailTemplatePolicy = Policy.getInstance(this.getClass().getResource(POLICY_FILE_LOCATION));
            AntiSamy emailAs = new AntiSamy();
            CleanResults crEmail = emailAs.scan(surveyDefinition.getEmailInvitationTemplate(),
                    emailTemplatePolicy);
            surveyDefinition.setEmailInvitationTemplate(crEmail.getCleanHTML());

            Policy completedSurveyPolicy = Policy
                    .getInstance(this.getClass().getResource(POLICY_FILE_LOCATION));
            AntiSamy completedSurveyAs = new AntiSamy();
            CleanResults crCompletedSurvey = completedSurveyAs
                    .scan(surveyDefinition.getCompletedSurveyTemplate(), completedSurveyPolicy);
            surveyDefinition.setCompletedSurveyTemplate(crCompletedSurvey.getCleanHTML());

            uiModel.asMap().clear();
            surveyDefinition = surveySettingsService.surveyDefinition_merge(surveyDefinition);
            System.out.println("!!!!!!!!! MD: " + surveyDefinition.getAllowMultipleSubmissions()
                    + " #################### PUB: " + surveyDefinition.getIsPublic());
            return "settings/surveyDefinitions/saved";

        } else {
            return "redirect:/settings/surveyDefinitions/"
                    + encodeUrlPathSegment(surveyDefinition.getId().toString(), httpServletRequest);
        }
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        throw (new RuntimeException(e));
    }
}

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

/**
 * creates a new survey definition//w  w  w  .  j  ava 2 s .c  o m
 * @param proceed
 * @param surveyDefinition
 * @param bindingResult
 * @param uiModel
 * @param httpServletRequest
 * @param principal
 * @return
 */
@Secured({ "ROLE_ADMIN", "ROLE_SURVEY_ADMIN" })
@RequestMapping(method = RequestMethod.POST, produces = "text/html")
public String createPost(@RequestParam(value = "_proceed", required = false) String proceed,
        @Valid SurveyDefinition surveyDefinition, BindingResult bindingResult, 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.userBelongsToDepartment(surveyDefinition.getDepartment().getId(), user)
                && !securityService.userIsAuthorizedToManageSurvey(surveyDefinition.getId(), 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) {
            if (bindingResult.hasErrors()) {
                populateEditForm(uiModel, surveyDefinition, user);
                return "settings/surveyDefinitions/create";
            }
            if (!surveySettingsService.surveyDefinition_ValidateNameIsUnique(surveyDefinition)) {
                bindingResult.rejectValue("name", "field_unique");
                populateEditForm(uiModel, surveyDefinition, user);
                return "settings/surveyDefinitions/create";
            }

            //if(surveyDefinition.getSendAutoReminders() == true){
            //bindingResult.rejectValue("autoRemindersWeeklyOccurrence", "field_unique");

            //   }   

            Policy emailTemplatePolicy = Policy.getInstance(this.getClass().getResource(POLICY_FILE_LOCATION));
            AntiSamy emailAs = new AntiSamy();
            CleanResults crEmail = emailAs.scan(surveyDefinition.getEmailInvitationTemplate(),
                    emailTemplatePolicy);
            surveyDefinition.setEmailInvitationTemplate(crEmail.getCleanHTML());

            Policy completedSurveyPolicy = Policy
                    .getInstance(this.getClass().getResource(POLICY_FILE_LOCATION));
            AntiSamy completedSurveyAs = new AntiSamy();
            CleanResults crCompletedSurvey = completedSurveyAs
                    .scan(surveyDefinition.getCompletedSurveyTemplate(), completedSurveyPolicy);
            surveyDefinition.setCompletedSurveyTemplate(crCompletedSurvey.getCleanHTML());

            uiModel.asMap().clear();
            surveyDefinition = surveySettingsService.surveyDefinition_merge(surveyDefinition);
            return "redirect:/settings/surveyDefinitions/"
                    + encodeUrlPathSegment(surveyDefinition.getId().toString(), httpServletRequest);
        } else {
            return "redirect:/settings/surveyDefinitions";
        }
    }

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

From source file:com.sammyun.plugin.alipayPartner.AlipayPartnerPlugin.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   www .ja v  a2s.  c  om
    // Order order = payment.getOrder();
    Map<String, Object> parameterMap = new HashMap<String, Object>();
    parameterMap.put("service", "create_partner_trade_by_buyer");
    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");
    parameterMap.put("logistics_type", "EXPRESS");
    parameterMap.put("logistics_fee", "0");
    parameterMap.put("logistics_payment", "SELLER_PAY");
    parameterMap.put("price", payment.getAmount().setScale(2).toString());
    parameterMap.put("quantity", "1");
    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", "directPay");
    parameterMap.put("exter_invoke_ip", request.getLocalAddr());
    parameterMap.put("extra_common_param", "preschoolEdu");
    // ?
    /*
    String receiveAddress = order.getAreaName() + order.getAddress();
    parameterMap.put("receive_address", receiveAddress);
    parameterMap.put("receive_zip", order.getZipCode());
    parameterMap.put("receive_phone", "");
    parameterMap.put("receive_mobile", order.getPhone());
    */
    parameterMap.put("sign", generateSign(parameterMap));

    return parameterMap;
}