Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1103021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:16:38+00:00 2026-05-17T01:16:38+00:00

I currently running into trouble with spring security, I have been following the two

  • 0

I currently running into trouble with spring security, I have been following the two last tutorials referenced on the spring security article page

Methods secured with the org.springframework.security.access.annotation.Secured don’t seem to trigger any Spring Security logic.

This is my test file:

 public class AclServiceTest {

 @Autowired
 PersonDataOnDemand pdod;

 @Autowired
 MyAclService aclService;

 UserDetailsService uds = new MyUserDetailsService();

 @Test
 public void testWriteResourceAnnotation(){
  Person p0 = pdod.getSpecificPerson(0);
  Person p1 = pdod.getSpecificPerson(1);

  Assert.isTrue(!p0.getId().equals(p1.getId()));

  Resource r = new Resource(p0.getSite(), p0, p0.getPrivateFolder());

  authenticatePerson(p0);
  securedWriteResource(r);

  authenticatePerson(p1);
  try{
   securedWriteResource(r);
   fail();
  } catch(Exception e){

  }
 }


 @Secured("ACL_RESOURCE_WRITE")
 public void securedWriteResource(Resource r){
  return;  
 }

 private void authenticatePerson(Person p){
  UserDetails ud = uds.loadUserByUsername(p.getEmail());
  SecurityContextHolder.getContext().setAuthentication(new RunAsUserToken("user-"+p.getId(), ud, p.getPassword(), ud.getAuthorities().toArray(new GrantedAuthority[0]), null));
 }
}

If added the following lines to my web.xml

<!--Spring security filter-->
<filter>
    <filter-name>springSecurityFilterChain</filter-name>
    <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>

<filter-mapping>
    <filter-name>springSecurityFilterChain</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

And this is my security.xml configuration with the beans that are used:

<?xml version="1.0" encoding="UTF-8"?>

<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans 
     http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
                    http://www.springframework.org/schema/security
                    http://www.springframework.org/schema/security/spring-security-3.0.xsd" >

<beans:bean id="ehCacheBasedAclCache" class="org.springframework.security.acls.domain.EhCacheBasedAclCache">
    <beans:constructor-arg>
        <beans:bean class="org.springframework.cache.ehcache.EhCacheFactoryBean">
            <beans:property name="cacheManager">
                <beans:bean class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"/>
            </beans:property>
            <beans:property name="cacheName" value="aclCache"/>
        </beans:bean>
    </beans:constructor-arg>
</beans:bean>


<!-- 
   Partie gestion de la business logic ACL
 -->

<global-method-security secured-annotations="enabled" access-decision-manager-ref="businessAccessDecisionManager"/>

<beans:bean id="businessAccessDecisionManager" class="org.springframework.security.access.vote.UnanimousBased">
    <beans:property name="allowIfAllAbstainDecisions" value="false"/>
    <beans:property name="decisionVoters">
        <beans:list>
            <beans:ref local="roleVoter"/>
            <beans:ref local="aclResourceReadVoter"/>
            <beans:ref local="aclResourceWriteVoter"/>
            <beans:ref local="aclResourceDeleteVoter"/>
            <beans:ref local="aclResourceAdminVoter"/>
        </beans:list>
    </beans:property>
</beans:bean>

<beans:bean id="roleVoter" class="org.springframework.security.access.vote.RoleVoter"/>

<beans:bean id="aclResourceReadVoter" class="org.springframework.security.acls.AclEntryVoter">
    <beans:constructor-arg ref="jdbcMutableAclService"/>
    <beans:constructor-arg value="ACL_RESOURCE_READ"/>
    <beans:constructor-arg>
        <beans:list>
            <beans:ref local="administrationPermission"/>
            <beans:ref local="readPermission"/>
        </beans:list>
    </beans:constructor-arg>
    <beans:property name="processDomainObjectClass" value="myapp.models.Resource"/>
    <beans:property name="internalMethod" value="getRootFolder"/>
</beans:bean>

<beans:bean id="aclResourceWriteVoter" class="org.springframework.security.acls.AclEntryVoter">
    <beans:constructor-arg ref="jdbcMutableAclService"/>
    <beans:constructor-arg value="ACL_RESOURCE_WRITE"/>
    <beans:constructor-arg>
        <beans:list>
            <beans:ref local="administrationPermission"/>
            <beans:ref local="writePermission"/>
        </beans:list>
    </beans:constructor-arg>
    <beans:property name="processDomainObjectClass" value="myapp.models.Resource"/>
    <beans:property name="internalMethod" value="getRootFolder"/>
</beans:bean>

<beans:bean id="aclResourceDeleteVoter" class="org.springframework.security.acls.AclEntryVoter">
    <beans:constructor-arg ref="jdbcMutableAclService"/>
    <beans:constructor-arg value="ACL_RESOURCE_DELETE"/>
    <beans:constructor-arg>
        <beans:list>
            <beans:ref local="administrationPermission"/>
            <beans:ref local="deletePermission"/>
        </beans:list>
    </beans:constructor-arg>
    <beans:property name="processDomainObjectClass" value="myapp.models.Resource"/>
    <beans:property name="internalMethod" value="getRootFolder"/>
</beans:bean>

<beans:bean id="aclResourceAdminVoter" class="org.springframework.security.acls.AclEntryVoter">
    <beans:constructor-arg ref="jdbcMutableAclService"/>
    <beans:constructor-arg value="ACL_RESOURCE_ADMIN"/>
    <beans:constructor-arg>
        <beans:list>
            <beans:ref local="administrationPermission"/>
        </beans:list>
    </beans:constructor-arg>
    <beans:property name="processDomainObjectClass" value="myapp.models.Resource"/>
    <beans:property name="internalMethod" value="getRootFolder"/>
</beans:bean>


<beans:bean id="administrationPermission" class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean">
    <beans:property name="staticField" value="org.springframework.security.acls.domain.BasePermission.ADMINISTRATION"/>
</beans:bean>

<beans:bean id="readPermission" class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean">
     <beans:property name="staticField" value="org.springframework.security.acls.domain.BasePermission.READ"/>
</beans:bean>

<beans:bean id="writePermission" class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean">
    <beans:property name="staticField" value="org.springframework.security.acls.domain.BasePermission.WRITE"/>
</beans:bean>

<beans:bean id="deletePermission" class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean">
    <beans:property name="staticField" value="org.springframework.security.acls.domain.BasePermission.DELETE"/>
</beans:bean>

The businessAccessDecisionManager bean is created and is given the voters, but the decide method is never called.

Anyone has an idea what’s going wrong ?

Thank for your help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T01:16:39+00:00Added an answer on May 17, 2026 at 1:16 am

    I found out that <global-method-security ../> wasn’t inserted in the right xml file. See here for more details. This file happens to be webmvc-config.xml in my Roo project.

    That unfolded several problem, I need SpEL for ACL so I finally settled for this config:

    <bean class="org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler" id="methodExprHandler">
        <property name="permissionEvaluator" ref="aclPermissionEvaluator" />
    </bean>
    <bean class="org.springframework.security.acls.AclPermissionEvaluator" id="aclPermissionEvaluator">
        <constructor-arg ref="jdbcMutableAclService" />
    </bean>
    
    
    <security:global-method-security pre-post-annotations="enabled">
        <security:expression-handler ref="methodExprHandler"/>
    </security:global-method-security>
    

    No voter logic for authorization.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been running into some troubles recently and I think I need your
I am currently running into a problem where an element is coming back from
I'm currently running into some issues resizing images using GD. Everything works fine until
We're currently running with php 5.2.5. We have now encountered a bug that creates
I am currently running the following code based on Chapter 12.5 of the Python
Currently running Server 2003 but am looking at reinstalling in the near future due
We're currently running a server on Compatibility mode 8 and I want to update
We are currently running a SQL Job that archives data daily at every 10PM.
We're currently running an svnserve instance as NT service. While this works, it's needlessly
I'm currently running Lucene.net in a web application and am wondering about the best

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.