Results 1 to 3 of 3

Thread: AffirmativeBased bug (2.0.3)

  1. #1
    Join Date
    Dec 2009
    Posts
    4

    Default AffirmativeBased bug (2.0.3)

    I know that this is occurring in an older version but since I did not check the current version to see if the issue is still there I would write it here...

    It not really a bug but more like a performance issue. The loop below should terminate right away when a single deny is encounter


    Code:
    public void decide(Authentication authentication, Object object, ConfigAttributeDefinition config)
            throws AccessDeniedException {
            Iterator iter = this.getDecisionVoters().iterator();
            int deny = 0;
    
            while (iter.hasNext()) {
                AccessDecisionVoter voter = (AccessDecisionVoter) iter.next();
                int result = voter.vote(authentication, object, config);
    
                switch (result) {
                case AccessDecisionVoter.ACCESS_GRANTED:
                    return;
    
                case AccessDecisionVoter.ACCESS_DENIED:
                    deny++;
    
                    break;
    
                default:
                    break;
                }
            }
    
            if (deny > 0) {
                throw new AccessDeniedException(messages.getMessage("AbstractAccessDecisionManager.accessDenied",
                        "Access is denied"));

    A very easy fix is this

    Code:
    while (iter.hasNext() && deny == 0) {

  2. #2
    Luke Taylor is offline Senior Member Acegi Security System TeamSpring Team
    Join Date
    Aug 2004
    Location
    Glasgow, Scotland
    Posts
    3,449

    Default

    It's not a bug. Check the Javadoc. AffirmativeBase "Denies access only if there was a deny vote AND no affirmative votes".

    Breaking without checking all voters will break that contract.
    Spring - by Pivotal
    twitter @tekul

  3. #3
    Join Date
    Dec 2009
    Posts
    4

    Default

    Makes perfect sense - my bad!

    Quote Originally Posted by Luke Taylor View Post
    It's not a bug. Check the Javadoc. AffirmativeBase "Denies access only if there was a deny vote AND no affirmative votes".


    Breaking without checking all voters will break that contract.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •