Skip to content
Permalink
master
Go to file
 
 
Cannot retrieve contributors at this time
41 lines (32 sloc) 1.28 KB
package com.targa.dev.formation.shiroj.security.configuration;
import org.apache.shiro.web.env.DefaultWebEnvironment;
import org.apache.shiro.web.env.EnvironmentLoaderListener;
import org.apache.shiro.web.env.WebEnvironment;
import org.apache.shiro.web.filter.mgt.FilterChainResolver;
import org.apache.shiro.web.mgt.WebSecurityManager;
import javax.inject.Inject;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.annotation.WebListener;
/**
* Created by nebrass on 17/11/2015.
*/
@WebListener
public class ShiroListener extends EnvironmentLoaderListener {
@Inject
WebSecurityManager securityManager;
@Inject
FilterChainResolver filterChainResolver;
@Override
protected WebEnvironment createEnvironment(ServletContext sc) {
DefaultWebEnvironment webEnvironment = (DefaultWebEnvironment) super.createEnvironment(sc);
webEnvironment.setSecurityManager(securityManager);
webEnvironment.setFilterChainResolver(filterChainResolver);
return webEnvironment;
}
@Override
public void contextInitialized(ServletContextEvent sce) {
sce.getServletContext().setInitParameter(ENVIRONMENT_CLASS_PARAM, DefaultWebEnvironment.class.getName());
super.contextInitialized(sce);
}
}
You can’t perform that action at this time.