views:

28

answers:

1

Can Spring roles only be defined in relative hierarchical terms as in this example?

Is there any way to define the roles in absolute terms?

<beans:bean id="roleHierarchy"
    class="org.springframework.security.access.hierarchicalroles.RoleHierarchyImpl">
    <beans:property name="hierarchy">
        <beans:value>
            ROLE_ADMIN > ROLE_USER
            ROLE_USER > ROLE_ANONYMOUS
        </beans:value>
    </beans:property>
</beans:bean>
+1  A: 

This might help point you in the right direction: here is an example I wrote which uses explicitly defined roles to permit or reject access to protected data based on roles.

Note how the EmployeeService class checks the role and determines behavior absolutely.

James Earl Douglas