相关疑难解决方法(0)

如果使用RoleHierarchyImpl,则为AccessDeniedException

我在Spring Security中使用角色层次结构.

<beans:bean id="roleVoter" class="org.springframework.security.access.vote.RoleHierarchyVoter">
    <beans:constructor-arg ref="roleHierarchy" />
</beans:bean>

<beans:bean id="roleHierarchy"
        class="org.springframework.security.access.hierarchicalroles.RoleHierarchyImpl">
    <beans:property name="hierarchy">
        <beans:value>
            ROLE_USER > ROLE_GUEST
        </beans:value>
    </beans:property>
</beans:bean>
Run Code Online (Sandbox Code Playgroud)

我正在使用保护切入点来保护方法

<global-method-security secured-annotations="enabled" pre-post-annotations="enabled">
  <protect-pointcut expression="execution(* my.package.*(..))"
     access="ROLE_GUEST"/>
</global-method-security>
Run Code Online (Sandbox Code Playgroud)

但是,如果我使用具有权限ROLE_USER的用户登录,则会出现AccessDeniedException.如果我指定了protect-pointcut,我没有问题access="ROLE_GUEST,ROLE_USER".

我错过了一些步骤吗?仅供参考,我使用的是Spring 3.0.5.

谢谢.

spring spring-security

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

标签 统计

spring ×1

spring-security ×1