Shiro.ini file configuration, but in Java class?

I want to know if it is possible to configure Shiro without the shiro.ini file, I mean, instead of using the INI file, what if I need the Shiro configuration to be hard-coded in the Java class?

+6
source share
3 answers

Yes it is possible. The documentation shows how to do this:

http://shiro.apache.org/configuration.html#Configuration-ProgrammaticConfiguration

+4
source

see Credential Reconciliation

or use jdbc custom realm here

+2
source

Yes you can do it through

ServletContextHandler context = new ServletContextHandler( ServletContextHandler.SESSIONS ); context.setContextPath( "/" ); context.addEventListener( new EnvironmentLoaderListener() ); // Add root ShiroFilter, all remaining filters and filter chains are defined in shiro.ini [urls] section. FilterHolder filterHolder = new FilterHolder( new ShiroFilter() ); ServletHolder servletHolder = new ServletHolder( new MockServlet() ); EnumSet<DispatcherType> types = EnumSet.allOf( DispatcherType.class ); context.addFilter( filterHolder, "/*", types ); context.addFilter( new FilterHolder( new TestFilter() ), "/*", types ); context.addServlet( servletHolder, "/*" ); 

And for the siro.ini file, refer to this doc:

0
source

Source: https://habr.com/ru/post/978979/


All Articles