Skip to content

Commit

Permalink
SEC-2507: WebExpressionVoter.supports support subclasses of FilterInv…
Browse files Browse the repository at this point in the history
…ocation
  • Loading branch information
rwinch committed Mar 10, 2014
1 parent 974105e commit bb56396
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public boolean supports(ConfigAttribute attribute) {
}

public boolean supports(Class<?> clazz) {
return clazz.isAssignableFrom(FilterInvocation.class);
return FilterInvocation.class.isAssignableFrom(clazz);
}

public void setExpressionHandler(SecurityExpressionHandler<FilterInvocation> expressionHandler) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.springframework.security.web.access.expression;

import static org.fest.assertions.Assertions.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
Expand All @@ -19,6 +20,10 @@

import java.util.ArrayList;

import javax.servlet.FilterChain;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

/**
* @author Luke Taylor
*/
Expand Down Expand Up @@ -63,4 +68,29 @@ public void grantsAccessIfExpressionIsTrueDeniesIfFalse() {
assertEquals(AccessDecisionVoter.ACCESS_DENIED, voter.vote(user, fi, attributes));
}

// SEC-2507
@Test
public void supportFilterInvocationSubClass() {
WebExpressionVoter voter = new WebExpressionVoter();
assertThat(voter.supports(FilterInvocationChild.class)).isTrue();
}

private static class FilterInvocationChild extends FilterInvocation {
public FilterInvocationChild(ServletRequest request,
ServletResponse response, FilterChain chain) {
super(request, response, chain);
}
}

@Test
public void supportFilterInvocation() {
WebExpressionVoter voter = new WebExpressionVoter();
assertThat(voter.supports(FilterInvocation.class)).isTrue();
}

@Test
public void supportsObjectIsFalse() {
WebExpressionVoter voter = new WebExpressionVoter();
assertThat(voter.supports(Object.class)).isFalse();
}
}

0 comments on commit bb56396

Please sign in to comment.