List of usage examples for org.springframework.security.web.util RedirectUrlBuilder RedirectUrlBuilder
RedirectUrlBuilder
From source file:com.springsource.hq.plugin.tcserver.serverconfig.web.support.HqAuthenticationEntryPoint.java
@Override protected String buildRedirectUrlToLoginPage(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) { String loginForm = determineUrlToUseForThisRequest(request, response, authException); int serverPort = getPortResolver().getServerPort(request); String scheme = request.getScheme(); RedirectUrlBuilder urlBuilder = new RedirectUrlBuilder(); urlBuilder.setScheme(scheme);/*from www . j a v a 2s .c o m*/ urlBuilder.setServerName(request.getServerName()); urlBuilder.setPort(serverPort); logger.debug("contextPath = " + request.getContextPath()); urlBuilder.setPathInfo(loginForm); if (isForceHttps() && "http".equals(scheme)) { Integer httpsPort = getPortMapper().lookupHttpsPort(Integer.valueOf(serverPort)); if (httpsPort != null) { // Overwrite scheme and port in the redirect URL urlBuilder.setScheme("https"); urlBuilder.setPort(httpsPort.intValue()); } else { logger.warn("Unable to redirect to HTTPS as no port mapping found for HTTP port " + serverPort); } } logger.debug("Redirecting to " + urlBuilder.getUrl()); return urlBuilder.getUrl(); }
From source file:br.com.flucianofeijao.security.JsfLoginUrlAuthenticationEntryPoint.java
protected String buildRedirectUrlToLoginPage(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) { String loginForm = determineUrlToUseForThisRequest(request, response, authException); if (UrlUtils.isAbsoluteUrl(loginForm)) { return loginForm; }/*from ww w. j a v a2s .c om*/ int serverPort = portResolver.getServerPort(request); String scheme = request.getScheme(); RedirectUrlBuilder urlBuilder = new RedirectUrlBuilder(); urlBuilder.setScheme(scheme); urlBuilder.setServerName(request.getServerName()); urlBuilder.setPort(serverPort); urlBuilder.setContextPath(request.getContextPath()); urlBuilder.setPathInfo(loginForm); if (forceHttps && "http".equals(scheme)) { Integer httpsPort = portMapper.lookupHttpsPort(Integer.valueOf(serverPort)); if (httpsPort != null) { // Overwrite scheme and port in the redirect URL urlBuilder.setScheme("https"); urlBuilder.setPort(httpsPort.intValue()); } else { logger.warn("Unable to redirect to HTTPS as no port mapping found for HTTP port " + serverPort); } } return urlBuilder.getUrl(); }
From source file:br.com.gerenciapessoal.security.JsfLoginUrlAuthenticationEntryPoint.java
protected String buildRedirectUrlToLoginPage(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) { String loginForm = determineUrlToUseForThisRequest(request, response, authException); if (UrlUtils.isAbsoluteUrl(loginForm)) { return loginForm; }/*from w w w . ja va 2 s .c o m*/ int serverPort = portResolver.getServerPort(request); String scheme = request.getScheme(); RedirectUrlBuilder urlBuilder = new RedirectUrlBuilder(); urlBuilder.setScheme(scheme); urlBuilder.setServerName(request.getServerName()); urlBuilder.setPort(serverPort); urlBuilder.setContextPath(request.getContextPath()); urlBuilder.setPathInfo(loginForm); if (forceHttps && "http".equals(scheme)) { Integer httpsPort = portMapper.lookupHttpsPort(serverPort); if (httpsPort != null) { // Overwrite scheme and port in the redirect URL urlBuilder.setScheme("https"); urlBuilder.setPort(httpsPort); } else { logger.warn("Unable to redirect to HTTPS as no port mapping found for HTTP port " + serverPort); } } return urlBuilder.getUrl(); }
From source file:com.sibvisions.rad.server.security.spring.authentication.SecurityManagerPreparer.java
/** * Builds the absolute logout process URL based on the request instance <code>pRequest</code> and <code>logoutProcessUrl</code>. * //from w ww . j a va 2s. c om * @param pRequest the request to build the logout process URL * * @return the absolute logout process URL */ protected String buildAbsoluteLogoutProcessUrl(HttpServletRequest pRequest) { if (logoutProcessUrl.startsWith("./") || UrlUtils.isAbsoluteUrl(logoutProcessUrl)) { return logoutProcessUrl; } RedirectUrlBuilder urlBuilder = new RedirectUrlBuilder(); urlBuilder.setScheme(pRequest.getScheme()); urlBuilder.setServerName(pRequest.getServerName()); urlBuilder.setPort(portResolver.getServerPort(pRequest)); urlBuilder.setContextPath(pRequest.getContextPath()); urlBuilder.setPathInfo(logoutProcessUrl); return urlBuilder.getUrl(); }
From source file:org.xine.marketplace.frontend.views.security.JsfLoginUrlAuthenticationEntryPoint.java
protected String buildRedirectUrlToLoginPage(final HttpServletRequest request, final HttpServletResponse response, final AuthenticationException authException) { final String loginForm = determineUrlToUseForThisRequest(request, response, authException); if (UrlUtils.isAbsoluteUrl(loginForm)) { return loginForm; }/*from www.j ava2 s . c om*/ final int serverPort = this.portResolver.getServerPort(request); final String scheme = request.getScheme(); final RedirectUrlBuilder urlBuilder = new RedirectUrlBuilder(); urlBuilder.setScheme(scheme); urlBuilder.setServerName(request.getServerName()); urlBuilder.setPort(serverPort); urlBuilder.setContextPath(request.getContextPath()); urlBuilder.setPathInfo(loginForm); if (this.forceHttps && "http".equals(scheme)) { final Integer httpsPort = this.portMapper.lookupHttpsPort(Integer.valueOf(serverPort)); if (httpsPort != null) { // Overwrite scheme and port in the redirect URL urlBuilder.setScheme("https"); urlBuilder.setPort(httpsPort.intValue()); } else { logger.warn("Unable to redirect to HTTPS as no port mapping found for HTTP port " + serverPort); } } return urlBuilder.getUrl(); }
From source file:br.com.flucianofeijao.security.JsfLoginUrlAuthenticationEntryPoint.java
/** * Builds a URL to redirect the supplied request to HTTPS. Used to redirect the current request * to HTTPS, before doing a forward to the login page. *///from w ww .jav a 2 s . c om protected String buildHttpsRedirectUrlForRequest(HttpServletRequest request) throws IOException, ServletException { int serverPort = portResolver.getServerPort(request); Integer httpsPort = portMapper.lookupHttpsPort(Integer.valueOf(serverPort)); if (httpsPort != null) { RedirectUrlBuilder urlBuilder = new RedirectUrlBuilder(); urlBuilder.setScheme("https"); urlBuilder.setServerName(request.getServerName()); urlBuilder.setPort(httpsPort.intValue()); urlBuilder.setContextPath(request.getContextPath()); urlBuilder.setServletPath(request.getServletPath()); urlBuilder.setPathInfo(request.getPathInfo()); urlBuilder.setQuery(request.getQueryString()); return urlBuilder.getUrl(); } // Fall through to server-side forward with warning message logger.warn("Unable to redirect to HTTPS as no port mapping found for HTTP port " + serverPort); return null; }
From source file:br.com.sg.security.SgLoginUrlAuthenticationEntryPoint.java
protected String buildRedirectUrlToLoginPage(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) { String loginForm = determineUrlToUseForThisRequest(request, response, authException); Integer serverPort = portResolver.getServerPort(request); String scheme = request.getScheme(); RedirectUrlBuilder urlBuilder = new RedirectUrlBuilder(); urlBuilder.setScheme(scheme);//from w w w . ja v a2 s. c om urlBuilder.setServerName(request.getServerName()); urlBuilder.setPort(serverPort); urlBuilder.setContextPath(request.getContextPath()); urlBuilder.setPathInfo(loginForm); if (forceHttps && "http".equals(scheme)) { Integer httpsPort = portMapper.lookupHttpsPort(new Integer(serverPort)); if (httpsPort != null) { // Overwrite scheme and port in the redirect URL urlBuilder.setScheme("https"); urlBuilder.setPort(httpsPort.intValue()); } else { logger.warn("Unable to redirect to HTTPS as no port mapping found for HTTP port " + serverPort); } } return urlBuilder.getUrl(); }
From source file:br.com.gerenciapessoal.security.JsfLoginUrlAuthenticationEntryPoint.java
/** * Builds a URL to redirect the supplied request to HTTPS. Used to redirect * the current request to HTTPS, before doing a forward to the login page. * * @param request//from ww w .ja v a2s . co m * @return * @throws java.io.IOException * @throws javax.servlet.ServletException */ protected String buildHttpsRedirectUrlForRequest(HttpServletRequest request) throws IOException, ServletException { int serverPort = portResolver.getServerPort(request); Integer httpsPort = portMapper.lookupHttpsPort(serverPort); if (httpsPort != null) { RedirectUrlBuilder urlBuilder = new RedirectUrlBuilder(); urlBuilder.setScheme("https"); urlBuilder.setServerName(request.getServerName()); urlBuilder.setPort(httpsPort); urlBuilder.setContextPath(request.getContextPath()); urlBuilder.setServletPath(request.getServletPath()); urlBuilder.setPathInfo(request.getPathInfo()); urlBuilder.setQuery(request.getQueryString()); return urlBuilder.getUrl(); } // Fall through to server-side forward with warning message logger.warn("Unable to redirect to HTTPS as no port mapping found for HTTP port " + serverPort); return null; }
From source file:org.xine.marketplace.frontend.views.security.JsfLoginUrlAuthenticationEntryPoint.java
/** * Builds a URL to redirect the supplied request to HTTPS. Used to redirect the current request * to HTTPS, before doing a forward to the login page. */// w w w .j a v a2 s. c o m protected String buildHttpsRedirectUrlForRequest(final HttpServletRequest request) throws IOException, ServletException { final int serverPort = this.portResolver.getServerPort(request); final Integer httpsPort = this.portMapper.lookupHttpsPort(Integer.valueOf(serverPort)); if (httpsPort != null) { final RedirectUrlBuilder urlBuilder = new RedirectUrlBuilder(); urlBuilder.setScheme("https"); urlBuilder.setServerName(request.getServerName()); urlBuilder.setPort(httpsPort.intValue()); urlBuilder.setContextPath(request.getContextPath()); urlBuilder.setServletPath(request.getServletPath()); urlBuilder.setPathInfo(request.getPathInfo()); urlBuilder.setQuery(request.getQueryString()); return urlBuilder.getUrl(); } // Fall through to server-side forward with warning message logger.warn("Unable to redirect to HTTPS as no port mapping found for HTTP port " + serverPort); return null; }