Hi All, 

Please let me know if there is any mistake in description. 

I am creating rest services using jersey. I have osgi bundles (It does not
have any web.xml)  which registers the application (rest resource) using
jersey servletContainer. Each bundle register application by invoking 

JerseyContainer servlet=  new JerseyContainer(app); 
http_service.registerServlet("/demo/session", servlet, null, null);  
---"/demo/session" for eg. 


I have a subclass which inherits jersey ServletContainer. I am trying to
configure shiro filter in subclass. 
Below is JerseyContainer which is inherited from jersey servletcontainer. 

public class JerseyContainer extends ServletContainer { 
        
         JerseyContainer(Application app) throws ServletException{ 
                super(app); 
                
        } 
                
        protected void initiate(ResourceConfig rc, WebApplication wa) 
        { 
                Map<String,Object> jerseyConfig = new
Hashtable<String,Object>(); 
                jerseyConfig.put(ResourceConfig.FEATURE_TRACE, "true"); 
                jerseyConfig.put(ResourceConfig.FEATURE_TRACE_PER_REQUEST,
"true"); 
               
jerseyConfig.put(ResourceConfig.PROPERTY_CONTAINER_REQUEST_FILTERS,
LoggingFilter.class.getName()); 
               
jerseyConfig.put(ResourceConfig.PROPERTY_CONTAINER_RESPONSE_FILTERS,
LoggingFilter.class.getName()); 

        rc.setPropertiesAndFeatures(jerseyConfig); 

                super.initiate(rc, wa); 
        } 
        
} 


I am trying to configure shiro filter for login and request authentication
and based on result forward the request to rest resource or throw exception
. I am able to configure shiro.ini successfully for custom jdbcrealm and
password service for login/logout in different class. I want to do this in
filter so that every request is authenticated and serviced. 

How can i configure/enable shiro filter in jersey servletcontainer?? I am
unable to figure out where can i enable EnvironmentLoaderListener since i do
not have any web.xml 

Please help me to figure out this. 
Is there any way i can initialize EnvironmentLoaderListener in ini file and
subsequently it configures filters? 

Below is my shiro.ini file. 


[main] 
myRealm = demo.CustomJdbcRealm 
myRealm.authenticationQuery = select password from user where uid=? 
ds = org.postgresql.ds.PGPoolingDataSource 
ds.serverName = localhost 
ds.portNumber = 5432 
ds.user = postgres 
ds.password = 1234 
ds.databaseName = DemoDB 
myRealm.dataSource = $ds 
myFilter =demo.filter.SubShiroFilter 

#PasswordMatcher 
passwordMatcher =demo.password.impl.PasswordMatcherImpl 
passwordService = demo.password.service.MyPasswordService 
passwordMatcher.passwordService = $passwordService 
myRealm.credentialsMatcher = $passwordMatcher 

[urls] 
/demo/session = myFilter-----> this is rest url for which i want shiro
filter to execute. 

Regards 
ankur



--
View this message in context: 
http://shiro-user.582556.n2.nabble.com/EnvironmentLoaderListener-for-shirofilter-in-shiro-ini-tp7577721.html
Sent from the Shiro User mailing list archive at Nabble.com.

Reply via email to