Tag: servlet filters

CAS单点登出不起作用

我在Apache Tomcat上安装了CAS服务器(v3.5.2),在JBOSS上安装了2个客户端。 除非单点退出,否则一切正常。 我想我所做的一切都很好,但仍然存在这个问题。 我的配置服务器端:在WEB-INF \ deployerConfigContext.xml中: 客户端配置:在web.xml中: CAS Single Sign Out Filter org.jasig.cas.client.session.SingleSignOutFilter artifactParameterName SAMLart CAS Single Sign Out Filter /* REQUEST FORWARD org.jasig.cas.client.session.SingleSignOutHttpSessionListener CAS Authentication Filter org.jasig.cas.client.authentication.AuthenticationFilter casServerLoginUrl http://localhost:8888/cas-server-webapp-3.5.2/login service http://localhost:8080/firstCasClient CAS Validation Filter org.jasig.cas.client.validation.Saml11TicketValidationFilter casServerUrlPrefix http://localhost:8888/cas-server-webapp-3.5.2 service http://localhost:8080/firstCasClient CAS HttpServletRequest Wrapper Filter org.jasig.cas.client.util.HttpServletRequestWrapperFilter CAS Assertion Thread Local Filter org.jasig.cas.client.util.AssertionThreadLocalFilter CAS Authentication Filter […]

如何在Jetty中的/ *上映射servletfilter?

我有一个servletfilter,我想在Jetty中映射到http://127.0.0.1:8888/ 。 我已经使用url pattern /*设置了servletfilter映射。 但是,不会调用filter。 我也尝试过/ mapping。 它也不起作用。 这是怎么造成的,如何解决?

使用自定义身份validation筛选器时,使用getRemoteUser()访问用户名

简短版本:当我使用自定义身份validationfilter时,如何让HttpServletRequest.getRemoteUser()返回用户名? 长版: 我正在修改当前使用声明性安全性(web.xml和tomcat-users.xml)的Tomcat应用程序,而不是使用自定义(由我编写)身份validationfilter(从javax.servlet.Filter派生)。 关于如何做到这一点有很多信息,看起来非常简单。 但是,现有的应用程序调用HttpServletRequest.getRemoteUser() ,我假设除非我在我的filter中设置此属性,否则它将返回null。 我找不到有关如何在filter中填充getRemoteUser()属性的任何信息(没有setRemoteUser() )。 我发现那里的post建议将请求对象包装在filter中。 如果必须,我会这样做,但我希望有一种侵入性较小的方法来实现这一目标。 有人可以帮忙吗?

J2EEfilter:登录页面无法加载css或任何图像

我已经访问了Java FilterImplementation以进行会话检查链接,其中提到了Spring安全性。 我没有得到我需要的帮助。 应用filter后,login.jsp无法加载CSS和图像。 我正在尝试在web.xml中提供filter并在login.jsp以外的页面上应用filter的简单示例。 Web.xml文件是: struts2 org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter struts2 /* AuthenticationFilter2 filter.AuthorizationFilter2 avoid-urls login.jsp ` filter类是: private ArrayList urlList; public void destroy() { // TODO Auto-generated method stub System.out.println(“authorization filter2 destroy method….”); } public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { System.out.println(“authorization filter2 doFilter method….”); HttpServletRequest request = (HttpServletRequest) req; HttpServletResponse […]

Servletfilter在AWS上返回“代理错误”

我已经设置了一个Filter来为我的GWT Web应用程序添加爬虫支持。 我们的想法是捕获包含“ _escaped_fragment_= ”的所有请求,并为爬虫提供快照。 我使用Guice设置了Filter ,如下所示: filter(“/*”).through(CrawlerFilter.class); 以下是CrawlerFilter类的代码(非常感谢Patrick ): @Singleton public class CrawlerFilter implements Filter { private static final Logger logger = Logger.getLogger(CrawlerFilter.class.getName()); /** * Special URL token that gets passed from the crawler to the servlet * filter. This token is used in case there are already existing query * parameters. */ private […]

执行JSF导航时,不会调用映射在前向调度程序上的filter

我正在尝试使用Tomcat 7使用登录系统编写一个简单的JSF Web应用程序。 我有两个页面:index.xhtml和/restricted/welcome.xhtml。 “/ restricted / *”下面的页面只能由登录的用户访问。 直接浏览welcome.xhtml导致我的filter被执行,从index.xhtml转发到welcome.xhtml绕过filter。 我无法想象为什么不执行filter。 RestrictedAreaFilter.java: @WebFilter(value = { “/restricted/*” }, dispatcherTypes = { DispatcherType.FORWARD, DispatcherType.REQUEST, DispatcherType.ASYNC, DispatcherType.ERROR, DispatcherType.INCLUDE }) public class RestrictedAreaFilter implements Filter { @Override public void destroy() { } @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest httpReq = (HttpServletRequest) request; […]

如何使用filter执行输出编码以防止XSS?

我在servlet中使用以下代码: protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out=response.getWriter(); response.setContentType(“text/html”); out.println(“”); out.println(“”); out.println(“alert(1)”); out.println(“”); out.println(“”); } 并遵循filter的代码: public class SampleFilter implements Filter { protected FilterConfig config; public void init(FilterConfig config) throws ServletException { this.config = config; } public void destroy() { } public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws […]

从HttpServletRequest获取AsyncContext

我正在使用Spring的OncePerRequestFilter重写shouldNotFilterAsyncDispatch方法来返回false。 这样它就可以处理异步请求。 在filter中我试图执行以下操作: if (isAsyncDispatch(request)) { request.getAsyncContext().addListener(new AsyncListener() { @Override public void onComplete(AsyncEvent event) throws IOException { System.out.println(“onComplete”); } @Override public void onTimeout(AsyncEvent event) throws IOException { } @Override public void onError(AsyncEvent event) throws IOException { System.out.println(“onError”); } @Override public void onStartAsync(AsyncEvent event) throws IOException { } }); } 所以isAsyncDispatch按预期返回true。 但是,当我尝试getAsyncContext它失败并出现以下exception: IllegalStateException: It is illegal […]

用于防止滥用的Servletfilter? (DoS,垃圾邮件等)

我正在寻找一个servletfilter库,帮助我保护我们的Web服务免受未经授权的使用和DDoS。 我们为我们的Web服务提供了“授权客户”,因此理想情况下,filter可以帮助检测未经授权或行为不当的客户端,或者使用同一帐户检测多个人。 我们还需要一种方法来防止各种服务的DoS,因为我们有一个开放帐户策略 – 限制用户同时连接的数量等。 我们已经看过Tomcat LockOutFilter等等,但这些都是相当原始的,只能防止一种攻击。 当然,解决方案中有许多特定于应用程序的组件,但我想知道是否有人写了一个通用的解决方案作为起点。

如何在弹簧靴中设置过滤链?

我遇到了spring-boot,并打算为传入请求添加一个filter链。 这是应用程序: package example.hello; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.ApplicationContext; @SpringBootApplication public class Application { public static void main(String[] args) { ApplicationContext ctx = SpringApplication.run(Application.class, args); } } 这是控制器: package example.hello; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import java.util.concurrent.atomic.AtomicLong; @RestController public class GreetingController { private static final String template = “Hello, %s!”; private final AtomicLong […]