相关疑难解决方法(0)

无法在自定义Apache Shiro AuthorizingRealm中@Inject我的DAO

我正在尝试将我的UserDAO注入Apache Shiro正在使用的自定义AuthorizingRealm中,但是......我得到了null.

我究竟做错了什么?

shiro.ini

[main]
user = demo.shiro.security.FacesAjaxAwareUserFilter
realmA = demo.shiro.security.JpaRealm
credentialsMatcher = org.apache.shiro.authc.credential.SimpleCredentialsMatcher
realmA.credentialsMatcher = $credentialsMatcher
securityManager.realms = $realmA
user.loginUrl = /pages/public/login.xhtml

[users]
admin = admin
user = user

[urls]
# public files and folders
/index.html = anon
/resources/** = anon
/pages/public/** = anon

# restricted files and folders
/pages/admin/** = user
/pages/user/** = user
Run Code Online (Sandbox Code Playgroud)

JpaRealm.java

public class JpaRealm extends AuthorizingRealm {

    @Inject
    private UserDao userDao;

    public JpaRealm() {
        setCredentialsMatcher(new Sha256CredentialsMatcher());
    }

    protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authToken) throws AuthenticationException { …
Run Code Online (Sandbox Code Playgroud)

java jsf shiro cdi

3
推荐指数
1
解决办法
4398
查看次数

标签 统计

cdi ×1

java ×1

jsf ×1

shiro ×1