Java 如何为ApacheShiro中的不同角色使用不同的未授权url

Java 如何为ApacheShiro中的不同角色使用不同的未授权url,java,jsf-2.2,shiro,Java,Jsf 2.2,Shiro,我一直在尝试为一个web应用程序的shiro.ini文件的url部分中的不同角色分配不同的未经授权的url,但似乎我无法这样做。下面是我尝试过的代码 shiro.ini文件 [main] authc1 = org.apache.shiro.web.filter.authc.FormAuthenticationFilter authc2 = org.apache.shiro.web.filter.authc.FormAuthenticationFilter authc1

我一直在尝试为一个web应用程序的shiro.ini文件的url部分中的不同角色分配不同的未经授权的url,但似乎我无法这样做。下面是我尝试过的代码

shiro.ini文件

[main]

    authc1 = org.apache.shiro.web.filter.authc.FormAuthenticationFilter
    authc2 = org.apache.shiro.web.filter.authc.FormAuthenticationFilter

    authc1.loginUrl = /login.xhtml
    authc2.loginUrl = /secLoginPage.xhtml 


[urls]
    /login.xhtml = authc1
    /secLoginPage.xhtml  = authc2
    /testapp/** = authc1, roles[admin,unauthorizedUrl=/adminAuthPage.xhtml]
    /userfld/**=authc2,roles[user,unauthorizedUrl=/abortPage.xhtml]
    /** = authc1
    /** = authc2
登录到应用程序后,将其重定向到授权页面,出现错误
错误401:SRVE0295E:error reported:401

此错误发生在我添加了未经授权的durl=/adminAuthPage.xhtml之后。
如果代码中有任何错误,请提出建议。

我认为这不是应该采用的方法,您基本上希望在角色中添加权限

这个

/testapp/**=authc1,角色[admin,unauthorizedUrl=/adminAuthPage.xhtml]

应该是:


/testapp/**=authc1,角色[admin],perms[“admin::”]

如何将一个未经授权的页面重定向到所需页面,该页面现在在其页面上充当入口点

403.jsp

<shiro:hasRole name="admin">
    <c:redirect url="adminAuthPage.xhtml"/>
</shiro:hasRole>

<shiro:hasRole name="user">
    <c:redirect url="abortPage.xhtml"/>
</shiro:hasRole>

或者更好,如果你只是想管理员有另一个页面,然后

 <shiro:hasRole name="admin">
        <c:redirect url="adminAuthPage.xhtml"/>
 </shiro:hasRole>
<shiro:lacksRole name="admin">
    <c:redirect url="abortPage.xhtml"/>
</shiro:lacksRole>


但是有没有办法通过shiro ini映射来实现呢。如果找到任何使用shiro.ini文件映射的解决方案,请共享我遵循的文档和源代码,但我无法找到这样的映射。可能你可以向开发人员提出改进请求。这是我尝试过的,但不起作用,/testapp/**=authc1,roles[admin],perms[“admin:unauthorizedUrl=/adminAuthPage.xhtml”]/userfld/**=authc2,roles[user],perms[“user:unauthorizedUrl=/abortPage.xhtml”]