Since you have no web.xml in a cxf project you need a class which extends
EnvironmentLoaderListener to initialize Shiro. Here is our class that we use
- I omitted everything not related to Shiro from this posting (we use
https://ops4j1.jira.com/wiki/display/PAXSHIRO/OPS4J+Pax+Shiro for CDI
integration):
public class ModuleInitializer extends EnvironmentLoaderListener {
public ModuleInitializer() {
}
@Override
public void contextInitialized(ServletContextEvent sce) {
super.contextInitialized(sce);
initializeShiro(sce);
}
@Override
public void contextDestroyed(ServletContextEvent sce) {
super.contextDestroyed(sce);
}
// we read our configuration from MongoDB database
@Override
protected void customizeEnvironment(WebEnvironment environment) {
MongoClientOptions.Builder builder =
MongoClientOptions.builder().socketKeepAlive(true).connectionsPerHost(1);
MongoClientURI uri = new MongoClientURI("mongodb://" + hostPort +
"/" + dbName + "?" + options, builder);
MongoClient mongo = new MongoClient(uri);
DBCollection collection =
mongo.getDB(dbName).getCollection("shiro-ini");
DBCursor cursor = collection.find().sort(new
BasicDBObject("timestamp", -1)).limit(1);
if (cursor != null && cursor.hasNext()) {
String iniFile = cursor.next().get("conf").toString();
Ini ini = new Ini();
ini.load(iniFile);
((CdiIniWebEnvironment) environment).setIni(ini);
}
mongo.close();
}
@Override
protected Class<?> determineWebEnvironmentClass(ServletContext
servletContext) {
return CdiIniWebEnvironment.class;
}
private void initializeShiro(ServletContextEvent sce) {
FilterRegistration.Dynamic dynamic =
sce.getServletContext().addFilter("ShiroFilter",
"org.apache.shiro.web.servlet.ShiroFilter");
dynamic.setAsyncSupported(true);
EnumSet<DispatcherType> enumSet = EnumSet.of(REQUEST, FORWARD,
INCLUDE, ERROR, ASYNC);
dynamic.addMappingForUrlPatterns(enumSet, true, "/*");
}
...
}
--
View this message in context:
http://shiro-user.582556.n2.nabble.com/Shiro-and-SOAP-WS-tp7581005p7581007.html
Sent from the Shiro User mailing list archive at Nabble.com.