使用Shiro的JndiObjectFactory自定义AuthenticationFilter

时间:2017-05-29 14:46:33

标签: java shiro java-ee-7

我将Apache Shiro 1.3.2集成到Java EE 7 Web应用程序中。出于配置目的,我想使用托管bean(CDI和EJB)。

org.apache.shiro.jndi.JndiObjectFactory非常适合设置自定义域:

ini.setSectionProperty("main", "dynamicRealm", JndiObjectFactory.class.getName());
ini.setSectionProperty("main", "dynamicRealm.requiredType", jndiClass.getName());
ini.setSectionProperty("main", "dynamicRealm.resourceName", jndiLookupPath(jndiClass));
ini.setSectionProperty("main", "securityManager.realms", "$dynamicRealm"); // , $...

但它似乎不适用于authc

Ini ini = new Ini();
ini.setSectionProperty("main", "authc", JndiObjectFactory.class.getName());
ini.setSectionProperty("main", "authc.requiredType", jndiClass.getName());
ini.setSectionProperty("main", "authc.resourceName", jndiLookupPath(jndiClass));

Shiro不使用我提供的AuthenticationFilter自定义子类,但始终默认使用FormAuthenticationFilter将我重定向到/login.jsp

是否不支持AuthenticationFilter的JNDI查找,还是有另一种方法?

0 个答案:

没有答案