I am developing abi-ring with Jersey and want to use Google Guice for dependency injection and Apache Shiro as a security framework.
For authentication, I created a custom Realm to which I must add a custom Authenticator that is connected to the EntityManager.
However, addiction is not introduced into the kingdom. I assume that shiro.ini (in which I have to determine the area used) is not guice controlled.
How can I embed dependencies in Apache Shiro, especially the one used by Realm?
My web.xml has only a filter displayed as
<?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <filter> <filter-name>guiceFilter</filter-name> <filter-class>com.google.inject.servlet.GuiceFilter</filter-class> </filter> <filter-mapping> <filter-name>guiceFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <listener> <listener-class>GuiceServletConfig</listener-class> </listener> </web-app>
My GuiceServletConfig configures all dependencies, including CustomRealm
public class GuiceServletConfig extends GuiceServletContextListener { @Override protected Injector getInjector() { return Guice.createInjector(new DbModule(), new JerseyServletModule() { @Override protected void configureServlets() {
Shiro only defines the area
[main] myRealm = CustomRealm [users] # for testing root = secret,admin [roles] # for testing admin = * [urls] /api
user524824
source share