List of usage examples for javax.servlet.http HttpServletRequest getScheme
public String getScheme();
From source file:com.qcadoo.mes.integration.cfcSimple.IntegrationController.java
protected final String handleUpload(final HttpServletRequest request, final MultipartFile file, final Locale locale) { try {//from w w w . j av a2 s. com String redirect = getIntegrationPerformer().performImport(file.getInputStream()); String context = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort(); return redirect.replaceAll("\\$\\{root\\}", context); } catch (IOException e) { throw new IllegalStateException("Error while reading file", e); } }
From source file:org.kuali.kfs.sys.web.struts.KualiBalanceInquiryReportMenuAction.java
/** * Takes care of storing the action form in the user session and forwarding to the balance inquiry lookup action. * /*from w w w . ja v a2 s . c o m*/ * @param mapping * @param form * @param request * @param response * @return ActionForward * @throws Exception */ public ActionForward performBalanceInquiryLookup(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath(); // parse out the important strings from our methodToCall parameter String fullParameter = (String) request.getAttribute(KFSConstants.METHOD_TO_CALL_ATTRIBUTE); // parse out business object class name for lookup String boClassName = StringUtils.substringBetween(fullParameter, KFSConstants.METHOD_TO_CALL_BOPARM_LEFT_DEL, KFSConstants.METHOD_TO_CALL_BOPARM_RIGHT_DEL); if (StringUtils.isBlank(boClassName)) { throw new RuntimeException("Illegal call to perform lookup, no business object class name specified."); } // build the parameters for the lookup url Properties parameters = new Properties(); String conversionFields = StringUtils.substringBetween(fullParameter, KFSConstants.METHOD_TO_CALL_PARM1_LEFT_DEL, KFSConstants.METHOD_TO_CALL_PARM1_RIGHT_DEL); if (StringUtils.isNotBlank(conversionFields)) { parameters.put(KFSConstants.CONVERSION_FIELDS_PARAMETER, conversionFields); } // pass values from form that should be pre-populated on lookup search String parameterFields = StringUtils.substringBetween(fullParameter, KFSConstants.METHOD_TO_CALL_PARM2_LEFT_DEL, KFSConstants.METHOD_TO_CALL_PARM2_RIGHT_DEL); if (StringUtils.isNotBlank(parameterFields)) { String[] lookupParams = parameterFields.split(KFSConstants.FIELD_CONVERSIONS_SEPERATOR); for (int i = 0; i < lookupParams.length; i++) { String[] keyValue = lookupParams[i].split(KFSConstants.FIELD_CONVERSION_PAIR_SEPERATOR); // hard-coded passed value if (StringUtils.contains(keyValue[0], "'")) { parameters.put(keyValue[1], StringUtils.replace(keyValue[0], "'", "")); } // passed value should come from property else if (StringUtils.isNotBlank(request.getParameter(keyValue[0]))) { parameters.put(keyValue[1], request.getParameter(keyValue[0])); } } } // grab whether or not the "return value" link should be hidden or not String hideReturnLink = StringUtils.substringBetween(fullParameter, KFSConstants.METHOD_TO_CALL_PARM3_LEFT_DEL, KFSConstants.METHOD_TO_CALL_PARM3_RIGHT_DEL); if (StringUtils.isNotBlank(hideReturnLink)) { parameters.put(KFSConstants.HIDE_LOOKUP_RETURN_LINK, hideReturnLink); } // anchor, if it exists if (form instanceof KualiForm && StringUtils.isNotEmpty(((KualiForm) form).getAnchor())) { parameters.put(KFSConstants.LOOKUP_ANCHOR, ((KualiForm) form).getAnchor()); } // determine what the action path is String actionPath = StringUtils.substringBetween(fullParameter, KFSConstants.METHOD_TO_CALL_PARM4_LEFT_DEL, KFSConstants.METHOD_TO_CALL_PARM4_RIGHT_DEL); if (StringUtils.isBlank(actionPath)) { throw new IllegalStateException( "The \"actionPath\" attribute is an expected parameter for the <gl:balanceInquiryLookup> tag - it " + "should never be blank."); } // now add required parameters parameters.put(KFSConstants.DISPATCH_REQUEST_PARAMETER, "start"); parameters.put(KFSConstants.DOC_FORM_KEY, GlobalVariables.getUserSession().addObjectWithGeneratedKey(form)); parameters.put(KFSConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, boClassName); parameters.put(KFSConstants.RETURN_LOCATION_PARAMETER, basePath + mapping.getPath() + ".do"); String lookupUrl = UrlFactory.parameterizeUrl(basePath + "/" + actionPath, parameters); return new ActionForward(lookupUrl, true); }
From source file:com.camel.framework.tag.CssLinkTag.java
/** * ????Coogle Minify?,??// w ww . java2 s . c o m */ private void parse() { StringBuffer sb = new StringBuffer(); // jspJspWriter JspWriter out = this.pageContext.getOut(); // environmentConfig.xml?????value String resourcesUrl = null; if (null != ConfigParamMap.getConfigParamMap()) { ConfigParamMap.getValue(IEnvironmentConfigBasic.RESOURCES_URL); } // ?null??URL if (null == resourcesUrl) { HttpServletRequest request = (HttpServletRequest) this.pageContext.getRequest(); resourcesUrl = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath(); } /** * ?environmentConfig.xml?resources_merger * ?jscss?,Ygoogle minify N? */ String resourcesMerger = null; if (null != ConfigParamMap.getConfigParamMap()) { ConfigParamMap.getValue(IEnvironmentConfigBasic.RESOURCES_MERGER); } if (ITagBasic.USER_MINIFY_CODE.equals(resourcesMerger)) { // ?? Minify?link?? parseToMinifyStyle(sb, resourcesUrl, out); } else { // path????? // ??? Minify?script?? parseToConventionalStyle(sb, resourcesUrl, out); } }
From source file:com.jaeksoft.searchlib.web.AbstractServlet.java
private void buildUrls(HttpServletRequest request) throws MalformedURLException { serverBaseURL = new URL(request.getScheme(), request.getServerName(), request.getServerPort(), request.getContextPath()).toString(); StringBuilder sbUrl = new StringBuilder(request.getRequestURI()); String qs = request.getQueryString(); if (qs != null) { sbUrl.append('?'); sbUrl.append(qs);/* w w w .ja va 2 s . co m*/ } URL url = new URL(request.getScheme(), request.getServerName(), request.getServerPort(), sbUrl.toString()); serverURL = url.toString(); }
From source file:fr.aliasource.webmail.server.OBMSSOProvider.java
@Override public Credentials obtainCredentials(Map<String, String> settings, HttpServletRequest req) { String ticket = req.getParameter("ticket"); if (ticket == null) { logger.warn("no ticket in url"); return null; }/*from w w w .ja va2 s . c o m*/ try { String logoutUrl = req.getScheme() + "://" + req.getServerName() + ":" + req.getServerPort() + req.getContextPath() + "/session;jsessionid=" + req.getSession().getId(); URL url = new URL(settings.get(SSO_SERVER_URL) + "?action=validate&ticket=" + ticket + "&logout=" + URLEncoder.encode(logoutUrl, "UTF-8")); InputStream in = url.openStream(); String content = IOUtils.toString(in); in.close(); if (logger.isDebugEnabled()) { logger.debug("SSO server returned:\n" + content); } Credentials creds = null; if (!content.equals("invalidOBMTicket")) { String[] ssoServerReturn = content.split("&password="); String login = ssoServerReturn[0].substring("login=".length()); String pass = ssoServerReturn[1]; creds = new Credentials(URLDecoder.decode(login, "UTF-8"), URLDecoder.decode(pass, "UTF-8")); } return creds; } catch (Exception e) { logger.error("Ticket validation error: " + e.getMessage(), e); return null; } }
From source file:org.apache.jetspeed.security.mfa.util.ServerData.java
/** * A C'tor that takes a HTTP Request object and * builds the server data from its contents * * @param req The HTTP Request/* w w w . j av a2 s . c o m*/ */ public ServerData(HttpServletRequest req) { setServerName(req.getServerName()); setServerPort(req.getServerPort()); setServerScheme(req.getScheme()); setScriptName(req.getServletPath()); setContextPath(req.getContextPath()); }
From source file:com.sun.socialsite.web.filters.RedirectorFilter.java
private String getRedirectionUri(HttpServletRequest httpReq) { if (baseUri == null) { return null; }/*from w ww. ja v a 2s . co m*/ String serverName = httpReq.getServerName(); String scheme = httpReq.getScheme(); int port = httpReq.getServerPort(); for (String exception : exceptions) { if (httpReq.getServletPath().startsWith(exception)) { return null; } } if (serverName.equalsIgnoreCase(baseUri.getHost()) && scheme.equalsIgnoreCase(baseUri.getScheme()) && (port == basePort)) { return null; } else { log.debug(String.format("Redirecting Because ((%s != %s) || (%s != %s) || (%d != %d))", serverName, baseUri.getHost(), scheme, baseUri.getScheme(), port, basePort)); StringBuilder sb = new StringBuilder(baseUri.toString()); if (httpReq.getServletPath() != null) sb.append(httpReq.getServletPath()); if (httpReq.getPathInfo() != null) sb.append(httpReq.getPathInfo()); if (httpReq.getQueryString() != null) sb.append("?").append(httpReq.getQueryString()); return sb.toString(); } }
From source file:org.hoteia.qalingo.core.service.AbstractUrlService.java
public String cleanAbsoluteUrl(final RequestData requestData, String absoluteUrl) throws Exception { final HttpServletRequest request = requestData.getRequest(); if (absoluteUrl != null && absoluteUrl.startsWith(request.getScheme())) { String domainePathUrl = buildDomainePathUrl(requestData); absoluteUrl = absoluteUrl.replace(domainePathUrl, ""); }// w w w . j a v a2 s.c o m return absoluteUrl; }
From source file:com.camel.framework.tag.ScriptTag.java
/** * ?????Coogle Minify?,??/* w ww .j av a 2 s . c o m*/ */ private void parse() { StringBuffer sb = new StringBuffer(); // jspJspWriter JspWriter out = this.pageContext.getOut(); // environmentConfig.xml?????value String resourcesUrl = null; if (null != ConfigParamMap.getConfigParamMap()) { ConfigParamMap.getValue(IEnvironmentConfigBasic.RESOURCES_URL); } // ?null??URL if (null == resourcesUrl) { HttpServletRequest request = (HttpServletRequest) this.pageContext.getRequest(); resourcesUrl = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath(); } /** * ?environmentConfig.xml?resources_merger * ?jscss?,Ygoogle minify N? */ String resourcesMerger = null; if (null != ConfigParamMap.getConfigParamMap()) { ConfigParamMap.getValue(IEnvironmentConfigBasic.RESOURCES_MERGER); } if (ITagBasic.USER_MINIFY_CODE.equals(resourcesMerger)) { // ?? Minify?script?? parseToMinifyStyle(sb, resourcesUrl, out); } else { // ??? Minify?script?? parseToConventionalStyle(sb, resourcesUrl, out); } }
From source file:org.broadleafcommerce.core.web.controller.account.BroadleafLoginController.java
public String getResetPasswordScheme(HttpServletRequest request) { return request.getScheme(); }