You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@shiro.apache.org by abarquin <ab...@gmail.com> on 2014/10/21 01:20:37 UTC
Override the OncePerRequestFilter isEnabled
Hello! I am new to shiro and I am trying to implement an override for
isEnabled() following the information in:
http://shiro.apache.org/web.html#Web-RequestspecificEnabling%252FDisabling.
I couldn't find a sample but I added:
package com.mycompany.shiro.web.servlet;
import org.apache.shiro.web.servlet.NameableFilter;
public abstract class OncePerRequestFilter extends NameableFilter {
private boolean enabled = true; //most filters wish to execute when
configured, so default to true
public boolean isEnabled() {
if (<condition>))
enabled = false;
return enabled;
}
}
I updated web.xml with the following entry:
<filter>
<filter-name>OncePerRequestFilter</filter-name>
<filter-class>com.mycompany.shiro.web.servlet.OncePerRequestFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>OncePerRequestFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
When I try to run it, I get:
Oct 20, 2014 5:40:47 PM org.apache.catalina.core.StandardContext filterStart
SEVERE: Exception starting filter OncePerRequestFilter
java.lang.InstantiationException
at
sun.reflect.InstantiationExceptionConstructorAccessorImpl.newInstance(InstantiationExceptionConstructorAccessorImpl.java:48)
at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
at java.lang.Class.newInstance0(Class.java:374)
at java.lang.Class.newInstance(Class.java:327)
Any help is going to be appreciated. :)
Thanks!
--
View this message in context: http://shiro-user.582556.n2.nabble.com/Override-the-OncePerRequestFilter-isEnabled-tp7580286.html
Sent from the Shiro User mailing list archive at Nabble.com.