Skip to content

Instantly share code, notes, and snippets.

@jnmronquillo
Created March 15, 2013 18:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jnmronquillo/5171913 to your computer and use it in GitHub Desktop.
Save jnmronquillo/5171913 to your computer and use it in GitHub Desktop.
import javax.servlet.ServletContext;
import org.apache.shiro.guice.web.ShiroWebModule;
import com.google.inject.Key;
import com.google.inject.name.Names;
public class MyShiroWebModule extends ShiroWebModule {
public MyShiroWebModule(ServletContext servletContext) {
super(servletContext);
}
@SuppressWarnings("unchecked")
@Override
protected void configureShiroWeb() {
addFilterChain("/logout", LOGOUT);
Key<HTTPStatusCodeAuthenticationFilter> ACCESSCONTROL = Key.get(HTTPStatusCodeAuthenticationFilter.class);
addFilterChain("/gwtRequest", ACCESSCONTROL);
// addFilterChain("/**", SSL, AUTHC);
addFilterChain("/js/**", ANON);
addFilterChain("/favicon.ico", ANON);
addFilterChain("/**", AUTHC);
bindRealm().to(MyRealm.class);
bindConstant().annotatedWith(Names.named("shiro.loginUrl")).to("/login.jsp");
bindConstant().annotatedWith(Names.named("shiro.globalSessionTimeout")).to(3600000L);//1 hour
bindConstant().annotatedWith(Names.named("shiro.usernameParam")).to("user");
bindConstant().annotatedWith(Names.named("shiro.passwordParam")).to("pass");
// bindConstant().annotatedWith(Names.named("shiro.rememberMeParam")).to("remember");
bindConstant().annotatedWith(Names.named("shiro.successUrl")).to("/index.jsp");
bindConstant().annotatedWith(Names.named("shiro.failureKeyAttribute")).to("shiroLoginFailure");
bindConstant().annotatedWith(Names.named("shiro.unauthorizedUrl")).to("/denied.jsp");
// bindConstant().annotatedWith(Names.named("shiro.port")).to(8443);
bindConstant().annotatedWith(Names.named("shiro.redirectUrl")).to("/login.jsp");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment