Hi,

I would like to setup my shiro config programmically.
If have seen this example:
http://mail-archives.apache.org/mod_mbox/shiro-user/201202.mbox/%3CCAETPiXZtvh=vg1f-yenx_egmppuqeejg7ong13jyteekhuq...@mail.gmail.com%3E

Since IniShiroFilter is marked as deprecated, I switched this to
ShiroFilter.

In the example from the mailing list it says, that I have to initialize
the filter with

filter.init(filterConfig);

But where do I get the filterConfig from?

When I only call filter.init(); I get "IllegalArgumentException:
ServletContext argument must not be null."
When I just skip this init call I'll get
"org.apache.shiro.config.ConfigurationException: Shiro INI configuration
was either not found or discovered to be empty/unconfigured."

This is my code:

private static void setupShiro(ServletContextHandler context)
    {
        context.addEventListener(new EnvironmentLoaderListener());

        final Ini ini = new Ini();
        ini.addSection("main");
        ShiroFilter shiroFilter = new ShiroFilter()
        {
            protected Ini loadIniFromConfig()
            {
                return ini;
            }
        };

        context.addFilter(new FilterHolder(shiroFilter), ANY_PATH,
getAllDispatcherTypes());

        Factory<SecurityManager> factory = new
IniSecurityManagerFactory(ini);
        SecurityManager securityManager = factory.getInstance();
        SecurityUtils.setSecurityManager(securityManager);
    }

Any ideas?

Thanks
Gregor

Reply via email to