diff --git a/parent/pom.xml b/parent/pom.xml index 2f708fe1..ff80a5a7 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -554,7 +554,7 @@ org.springframework.security spring-security-core - 3.0.7.RELEASE + 3.1.0.RELEASE org.springframework @@ -565,7 +565,7 @@ org.springframework.security spring-security-core - 3.0.7.RELEASE + 3.1.0.RELEASE tests @@ -577,7 +577,7 @@ org.springframework.security spring-security-config - 3.0.7.RELEASE + 3.1.0.RELEASE diff --git a/security/src/main/java/org/springframework/ws/soap/security/x509/X509AuthenticationToken.java b/security/src/main/java/org/springframework/ws/soap/security/x509/X509AuthenticationToken.java index de96790c..1e6bec1f 100644 --- a/security/src/main/java/org/springframework/ws/soap/security/x509/X509AuthenticationToken.java +++ b/security/src/main/java/org/springframework/ws/soap/security/x509/X509AuthenticationToken.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2010 the original author or authors. + * Copyright 2005-2012 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -58,7 +58,7 @@ public class X509AuthenticationToken extends AbstractAuthenticationToken { * @param credentials the certificate * @param authorities the authorities */ - public X509AuthenticationToken(Object principal, X509Certificate credentials, Collection authorities) { + public X509AuthenticationToken(Object principal, X509Certificate credentials, Collection authorities) { super(authorities); this.principal = principal; this.credentials = credentials; diff --git a/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jMessageInterceptorSpringSecurityCallbackHandlerTestCase.java b/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jMessageInterceptorSpringSecurityCallbackHandlerTestCase.java index fbda3802..ea48269e 100755 --- a/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jMessageInterceptorSpringSecurityCallbackHandlerTestCase.java +++ b/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jMessageInterceptorSpringSecurityCallbackHandlerTestCase.java @@ -1,5 +1,5 @@ /* - * Copyright 2005-2011 the original author or authors. + * Copyright 2005-2012 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,6 @@ import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.authentication.TestingAuthenticationToken; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.core.Authentication; -import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.core.userdetails.memory.InMemoryDaoImpl; import org.springframework.ws.context.DefaultMessageContext; @@ -119,7 +118,7 @@ public abstract class Wss4jMessageInterceptorSpringSecurityCallbackHandlerTestCa else { SpringPlainTextPasswordValidationCallbackHandler callbackHandler = new SpringPlainTextPasswordValidationCallbackHandler(); - Authentication authResult = new TestingAuthenticationToken("Bert", "Ernie", new GrantedAuthority[0]); + Authentication authResult = new TestingAuthenticationToken("Bert", "Ernie"); expect(authenticationManager.authenticate(new UsernamePasswordAuthenticationToken("Bert", "Ernie"))).andReturn(authResult); callbackHandler.setAuthenticationManager(authenticationManager); callbackHandler.afterPropertiesSet(); diff --git a/security/src/test/java/org/springframework/ws/soap/security/wss4j/callback/SpringDigestPasswordValidationCallbackHandlerTest.java b/security/src/test/java/org/springframework/ws/soap/security/wss4j/callback/SpringDigestPasswordValidationCallbackHandlerTest.java index 5ccbb5c8..9106e1ac 100644 --- a/security/src/test/java/org/springframework/ws/soap/security/wss4j/callback/SpringDigestPasswordValidationCallbackHandlerTest.java +++ b/security/src/test/java/org/springframework/ws/soap/security/wss4j/callback/SpringDigestPasswordValidationCallbackHandlerTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2010 the original author or authors. + * Copyright 2005-2012 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -17,10 +17,11 @@ package org.springframework.ws.soap.security.wss4j.callback; import java.util.Collection; +import java.util.Collections; import org.springframework.security.core.Authentication; import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.authority.GrantedAuthorityImpl; +import org.springframework.security.core.authority.SimpleGrantedAuthority; import org.springframework.security.core.context.SecurityContext; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.core.userdetails.User; @@ -39,7 +40,7 @@ public class SpringDigestPasswordValidationCallbackHandlerTest { private SpringDigestPasswordValidationCallbackHandler callbackHandler; - private GrantedAuthorityImpl grantedAuthority; + private SimpleGrantedAuthority grantedAuthority; private UsernameTokenPrincipalCallback callback; @@ -49,8 +50,8 @@ public class SpringDigestPasswordValidationCallbackHandlerTest { public void setUp() throws Exception { callbackHandler = new SpringDigestPasswordValidationCallbackHandler(); - grantedAuthority = new GrantedAuthorityImpl("ROLE_1"); - user = new User("Ernie", "Bert", true, true, true, true, new GrantedAuthority[]{grantedAuthority}); + grantedAuthority = new SimpleGrantedAuthority("ROLE_1"); + user = new User("Ernie", "Bert", true, true, true, true, Collections.singleton(grantedAuthority)); WSUsernameTokenPrincipal principal = new WSUsernameTokenPrincipal("Ernie", true); callback = new UsernameTokenPrincipalCallback(principal); @@ -70,7 +71,7 @@ public class SpringDigestPasswordValidationCallbackHandlerTest { Assert.assertNotNull("SecurityContext must not be null", context); Authentication authentication = context.getAuthentication(); Assert.assertNotNull("Authentication must not be null", authentication); - Collection authorities = authentication.getAuthorities(); + Collection authorities = authentication.getAuthorities(); Assert.assertTrue("GrantedAuthority[] must not be null or empty", (authorities != null && authorities.size() > 0)); Assert.assertEquals("Unexpected authority", grantedAuthority, authorities.iterator().next()); diff --git a/security/src/test/java/org/springframework/ws/soap/security/xwss/callback/SpringCertificateValidationCallbackHandlerTest.java b/security/src/test/java/org/springframework/ws/soap/security/xwss/callback/SpringCertificateValidationCallbackHandlerTest.java index 342bfe79..310384b7 100644 --- a/security/src/test/java/org/springframework/ws/soap/security/xwss/callback/SpringCertificateValidationCallbackHandlerTest.java +++ b/security/src/test/java/org/springframework/ws/soap/security/xwss/callback/SpringCertificateValidationCallbackHandlerTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2010 the original author or authors. + * Copyright 2005-2012 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -19,15 +19,16 @@ package org.springframework.ws.soap.security.xwss.callback; import java.io.InputStream; import java.security.KeyStore; import java.security.cert.X509Certificate; +import java.util.Collections; import org.springframework.core.io.ClassPathResource; import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.authentication.BadCredentialsException; +import org.springframework.security.authentication.TestingAuthenticationToken; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.context.SecurityContextHolder; -import org.springframework.security.authentication.TestingAuthenticationToken; -import org.springframework.ws.soap.security.x509.X509AuthenticationToken; import org.springframework.ws.soap.security.callback.CleanupCallback; +import org.springframework.ws.soap.security.x509.X509AuthenticationToken; import com.sun.xml.wss.impl.callback.CertificateValidationCallback; import org.junit.After; @@ -75,7 +76,7 @@ public class SpringCertificateValidationCallbackHandlerTest { @Test public void testValidateCertificateValid() throws Exception { expect(authenticationManager.authenticate(isA(X509AuthenticationToken.class))) - .andReturn(new TestingAuthenticationToken(certificate, null, new GrantedAuthority[0])); + .andReturn(new TestingAuthenticationToken(certificate, null, Collections.emptyList())); replay(authenticationManager); @@ -105,7 +106,7 @@ public class SpringCertificateValidationCallbackHandlerTest { @Test public void testCleanUp() throws Exception { TestingAuthenticationToken authentication = - new TestingAuthenticationToken(new Object(), new Object(), new GrantedAuthority[0]); + new TestingAuthenticationToken(new Object(), new Object(), Collections.emptyList()); SecurityContextHolder.getContext().setAuthentication(authentication); CleanupCallback cleanupCallback = new CleanupCallback(); diff --git a/security/src/test/java/org/springframework/ws/soap/security/xwss/callback/SpringDigestPasswordValidationCallbackHandlerTest.java b/security/src/test/java/org/springframework/ws/soap/security/xwss/callback/SpringDigestPasswordValidationCallbackHandlerTest.java index 9897b25b..50165912 100644 --- a/security/src/test/java/org/springframework/ws/soap/security/xwss/callback/SpringDigestPasswordValidationCallbackHandlerTest.java +++ b/security/src/test/java/org/springframework/ws/soap/security/xwss/callback/SpringDigestPasswordValidationCallbackHandlerTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2005-2011 the original author or authors. + * Copyright 2005-2012 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,8 @@ package org.springframework.ws.soap.security.xwss.callback; +import java.util.Collections; + import org.springframework.security.authentication.DisabledException; import org.springframework.security.authentication.TestingAuthenticationToken; import org.springframework.security.core.GrantedAuthority; @@ -81,7 +83,7 @@ public class SpringDigestPasswordValidationCallbackHandlerTest { @Test public void testAuthenticateUserDigestValid() throws Exception { - User user = new User(username, password, true, true, true, true, new GrantedAuthority[0]); + User user = new User(username, password, true, true, true, true, Collections.emptyList()); expect(userDetailsService.loadUserByUsername(username)).andReturn(user); replay(userDetailsService); @@ -96,7 +98,7 @@ public class SpringDigestPasswordValidationCallbackHandlerTest { @Test public void testAuthenticateUserDigestValidInvalid() throws Exception { - User user = new User(username, "Big bird", true, true, true, true, new GrantedAuthority[0]); + User user = new User(username, "Big bird", true, true, true, true, Collections.emptyList()); expect(userDetailsService.loadUserByUsername(username)).andReturn(user); replay(userDetailsService); @@ -111,7 +113,7 @@ public class SpringDigestPasswordValidationCallbackHandlerTest { @Test public void testAuthenticateUserDigestDisabled() throws Exception { - User user = new User(username, "Ernie", false, true, true, true, new GrantedAuthority[0]); + User user = new User(username, "Ernie", false, true, true, true, Collections.emptyList()); expect(userDetailsService.loadUserByUsername(username)).andReturn(user); replay(userDetailsService); @@ -128,7 +130,7 @@ public class SpringDigestPasswordValidationCallbackHandlerTest { @Test public void testCleanUp() throws Exception { TestingAuthenticationToken authentication = - new TestingAuthenticationToken(new Object(), new Object(), new GrantedAuthority[0]); + new TestingAuthenticationToken(new Object(), new Object(), Collections.emptyList()); SecurityContextHolder.getContext().setAuthentication(authentication); CleanupCallback cleanupCallback = new CleanupCallback(); diff --git a/security/src/test/java/org/springframework/ws/soap/security/xwss/callback/SpringPlainTextPasswordValidationCallbackHandlerTest.java b/security/src/test/java/org/springframework/ws/soap/security/xwss/callback/SpringPlainTextPasswordValidationCallbackHandlerTest.java index f9a21cf1..d7a96c93 100644 --- a/security/src/test/java/org/springframework/ws/soap/security/xwss/callback/SpringPlainTextPasswordValidationCallbackHandlerTest.java +++ b/security/src/test/java/org/springframework/ws/soap/security/xwss/callback/SpringPlainTextPasswordValidationCallbackHandlerTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2010 the original author or authors. + * Copyright 2005-2012 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -16,13 +16,15 @@ package org.springframework.ws.soap.security.xwss.callback; -import org.springframework.security.core.Authentication; +import java.util.Collections; + import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.authentication.BadCredentialsException; -import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.authentication.TestingAuthenticationToken; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.ws.soap.security.callback.CleanupCallback; import com.sun.xml.wss.impl.callback.PasswordValidationCallback; @@ -64,7 +66,8 @@ public class SpringPlainTextPasswordValidationCallbackHandlerTest { @Test public void testAuthenticateUserPlainTextValid() throws Exception { - Authentication authResult = new TestingAuthenticationToken(username, password, new GrantedAuthority[0]); + Authentication authResult = new TestingAuthenticationToken(username, password, Collections + .emptyList()); expect(authenticationManager.authenticate(new UsernamePasswordAuthenticationToken(username, password))).andReturn(authResult); replay(authenticationManager); @@ -94,7 +97,7 @@ public class SpringPlainTextPasswordValidationCallbackHandlerTest { @Test public void testCleanUp() throws Exception { TestingAuthenticationToken authentication = - new TestingAuthenticationToken(new Object(), new Object(), new GrantedAuthority[0]); + new TestingAuthenticationToken(new Object(), new Object(), Collections.emptyList()); SecurityContextHolder.getContext().setAuthentication(authentication); CleanupCallback cleanupCallback = new CleanupCallback();