📄 captchaentrypoint.java
字号:
/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.acegisecurity.captcha;import org.acegisecurity.securechannel.ChannelEntryPoint;import org.acegisecurity.util.PortMapper;import org.acegisecurity.util.PortMapperImpl;import org.acegisecurity.util.PortResolver;import org.acegisecurity.util.PortResolverImpl;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;import org.springframework.beans.factory.InitializingBean;import org.springframework.util.Assert;import java.io.IOException;import java.io.UnsupportedEncodingException;import java.net.URLEncoder;import java.util.Enumeration;import javax.servlet.ServletException;import javax.servlet.ServletRequest;import javax.servlet.ServletResponse;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;/** * The captcha entry point : redirect to the captcha test page. * <p> * This entry point can force the use of SSL : see {@link #getForceHttps()} * </p> * <p> * This entry point allows internal OR external redirect : see {@link #setOutsideWebApp(boolean)}<br /> * / Original request can be added to the redirect path using a custom translation : see * {@link #setIncludeOriginalRequest(boolean)}<br /> * The original request is translated using URLEncoding and the following translation mapping in the redirect url : * <ul> * <li>original url => {@link #getOriginalRequestUrlParameterName()}</li> * <li>If {@link #isIncludeOriginalParameters()}</li> * <li>original method => {@link #getOriginalRequestMethodParameterName()}</li> * <li>original parameters => {@link #getOriginalRequestParametersParameterName()}</li> * <li>The original parameters string is contructed using : * <ul> * <li>a parameter separator {@link #getOriginalRequestParametersSeparator()}</li> * <li>a parameter name value pair separator for each parameter {@link * #getOriginalRequestParametersNameValueSeparator()}</li> * </ul> * </li> * </ul> * <br><br> * Default values : * <pre> * forceHttps = false * includesOriginalRequest = true * includesOriginalParameters = false * isOutsideWebApp = false * originalRequestUrlParameterName = original_requestUrl * originalRequestParametersParameterName = original_request_parameters * originalRequestParametersNameValueSeparator = __ * originalRequestParametersSeparator = ;; * originalRequestMethodParameterName = original_request_method * urlEncodingCharset = UTF-8 * </pre> * </p> * * @author marc antoine Garrigue * @version $Id: CaptchaEntryPoint.java 1784 2007-02-24 21:00:24Z luke_t $ */public class CaptchaEntryPoint implements ChannelEntryPoint, InitializingBean { //~ Static fields/initializers ===================================================================================== private static final Log logger = LogFactory.getLog(CaptchaEntryPoint.class); //~ Instance fields ================================================================================================ // ~ Instance fields // ======================================================== private PortMapper portMapper = new PortMapperImpl(); private PortResolver portResolver = new PortResolverImpl(); private String captchaFormUrl; private String originalRequestMethodParameterName = "original_request_method"; private String originalRequestParametersNameValueSeparator = "__"; private String originalRequestParametersParameterName = "original_request_parameters"; private String originalRequestParametersSeparator = ";;"; private String originalRequestUrlParameterName = "original_requestUrl"; private String urlEncodingCharset = "UTF-8"; private boolean forceHttps = false; private boolean includeOriginalParameters = false; private boolean includeOriginalRequest = true; private boolean isOutsideWebApp = false; //~ Methods ======================================================================================================== public void afterPropertiesSet() throws Exception { Assert.hasLength(captchaFormUrl, "captchaFormUrl must be specified"); Assert.hasLength(originalRequestMethodParameterName, "originalRequestMethodParameterName must be specified"); Assert.hasLength(originalRequestParametersNameValueSeparator, "originalRequestParametersNameValueSeparator must be specified"); Assert.hasLength(originalRequestParametersParameterName, "originalRequestParametersParameterName must be specified"); Assert.hasLength(originalRequestParametersSeparator, "originalRequestParametersSeparator must be specified"); Assert.hasLength(originalRequestUrlParameterName, "originalRequestUrlParameterName must be specified"); Assert.hasLength(urlEncodingCharset, "urlEncodingCharset must be specified"); Assert.notNull(portMapper, "portMapper must be specified"); Assert.notNull(portResolver, "portResolver must be specified"); URLEncoder.encode(" fzaef
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -