mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-06-28 23:02:15 +00:00
Fix bug related to detecting incorrect use of SecureContext property.
This commit is contained in:
parent
3e37b74e3f
commit
2996d67b06
@ -100,7 +100,7 @@ public abstract class AbstractIntegrationFilter implements InitializingBean,
|
|||||||
|
|
||||||
public void afterPropertiesSet() throws Exception {
|
public void afterPropertiesSet() throws Exception {
|
||||||
if ((this.secureContext == null)
|
if ((this.secureContext == null)
|
||||||
|| (!this.secureContext.isAssignableFrom(SecureContext.class))) {
|
|| (!SecureContext.class.isAssignableFrom(this.secureContext))) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"secureContext must be defined and implement SecureContext");
|
"secureContext must be defined and implement SecureContext");
|
||||||
}
|
}
|
||||||
|
@ -152,13 +152,26 @@ public class AbstractIntegrationFilterTests extends TestCase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSecureContextSettersGetters() throws Exception {
|
public void testRejectsInvalidSecureContextClass()
|
||||||
|
throws Exception {
|
||||||
MockAbstractIntegrationFilterImpl filter = new MockAbstractIntegrationFilterImpl(null);
|
MockAbstractIntegrationFilterImpl filter = new MockAbstractIntegrationFilterImpl(null);
|
||||||
|
|
||||||
// check the default
|
// Test rejects classes not implementing SecureContext
|
||||||
assertEquals(SecureContextImpl.class, filter.getSecureContext());
|
filter.setSecureContext(String.class);
|
||||||
|
|
||||||
// check null causes exception
|
try {
|
||||||
|
filter.afterPropertiesSet();
|
||||||
|
fail("Should have thrown IllegalArgumentException");
|
||||||
|
} catch (IllegalArgumentException expected) {
|
||||||
|
assertTrue(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test accepts classes implementing SecureContext
|
||||||
|
filter.setSecureContext(SecureContextImpl.class);
|
||||||
|
filter.afterPropertiesSet();
|
||||||
|
assertTrue(true);
|
||||||
|
|
||||||
|
// Test rejects null
|
||||||
filter.setSecureContext(null);
|
filter.setSecureContext(null);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -169,6 +182,17 @@ public class AbstractIntegrationFilterTests extends TestCase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testSecureContextSettersGetters() throws Exception {
|
||||||
|
MockAbstractIntegrationFilterImpl filter = new MockAbstractIntegrationFilterImpl(null);
|
||||||
|
|
||||||
|
// check the default
|
||||||
|
assertEquals(SecureContextImpl.class, filter.getSecureContext());
|
||||||
|
|
||||||
|
// check the setter
|
||||||
|
filter.setSecureContext(null);
|
||||||
|
assertNull(filter.getSecureContext());
|
||||||
|
}
|
||||||
|
|
||||||
public void testSuccessWhenConcreteClassReturnsValidAuthenticationObject()
|
public void testSuccessWhenConcreteClassReturnsValidAuthenticationObject()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
PrincipalAcegiUserToken principal = new PrincipalAcegiUserToken("key",
|
PrincipalAcegiUserToken principal = new PrincipalAcegiUserToken("key",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user