diff --git a/acl/src/main/java/org/springframework/security/acls/domain/DefaultPermissionFactory.java b/acl/src/main/java/org/springframework/security/acls/domain/DefaultPermissionFactory.java index a6a77aa906..c64e7c0652 100644 --- a/acl/src/main/java/org/springframework/security/acls/domain/DefaultPermissionFactory.java +++ b/acl/src/main/java/org/springframework/security/acls/domain/DefaultPermissionFactory.java @@ -84,7 +84,7 @@ public class DefaultPermissionFactory implements PermissionFactory { Assert.notNull(perm, "Permission required"); Assert.hasText(permissionName, "Permission name required"); - Integer mask = new Integer(perm.getMask()); + Integer mask = Integer.valueOf(perm.getMask()); // Ensure no existing Permission uses this integer or code Assert.isTrue(!registeredPermissionsByInteger.containsKey(mask), "An existing Permission already provides mask " + mask); @@ -98,7 +98,7 @@ public class DefaultPermissionFactory implements PermissionFactory { public Permission buildFromMask(int mask) { if (registeredPermissionsByInteger.containsKey(Integer.valueOf(mask))) { // The requested mask has an exact match against a statically-defined Permission, so return it - return registeredPermissionsByInteger.get(new Integer(mask)); + return registeredPermissionsByInteger.get(Integer.valueOf(mask)); } // To get this far, we have to use a CumulativePermission diff --git a/acl/src/test/java/org/springframework/security/acls/domain/ObjectIdentityImplTests.java b/acl/src/test/java/org/springframework/security/acls/domain/ObjectIdentityImplTests.java index b23942e299..042fba7bee 100644 --- a/acl/src/test/java/org/springframework/security/acls/domain/ObjectIdentityImplTests.java +++ b/acl/src/test/java/org/springframework/security/acls/domain/ObjectIdentityImplTests.java @@ -140,7 +140,7 @@ public class ObjectIdentityImplTests { @Test public void longAndIntegerIdsWithSameValueAreEqualAndHaveSameHashcode() { ObjectIdentity obj = new ObjectIdentityImpl(Object.class, new Long(5)); - ObjectIdentity obj2 = new ObjectIdentityImpl(Object.class, new Integer(5)); + ObjectIdentity obj2 = new ObjectIdentityImpl(Object.class, Integer.valueOf(5)); assertEquals(obj, obj2); assertEquals(obj.hashCode(), obj2.hashCode()); diff --git a/acl/src/test/java/org/springframework/security/acls/domain/ObjectIdentityRetrievalStrategyImplTests.java b/acl/src/test/java/org/springframework/security/acls/domain/ObjectIdentityRetrievalStrategyImplTests.java index e9f7f9e588..bf05d10953 100644 --- a/acl/src/test/java/org/springframework/security/acls/domain/ObjectIdentityRetrievalStrategyImplTests.java +++ b/acl/src/test/java/org/springframework/security/acls/domain/ObjectIdentityRetrievalStrategyImplTests.java @@ -17,7 +17,7 @@ public class ObjectIdentityRetrievalStrategyImplTests extends TestCase { public void testObjectIdentityCreation() throws Exception { MockIdDomainObject domain = new MockIdDomainObject(); - domain.setId(new Integer(1)); + domain.setId(Integer.valueOf(1)); ObjectIdentityRetrievalStrategy retStrategy = new ObjectIdentityRetrievalStrategyImpl(); ObjectIdentity identity = retStrategy.getObjectIdentity(domain); diff --git a/acl/src/test/java/org/springframework/security/acls/jdbc/BasicLookupStrategyTests.java b/acl/src/test/java/org/springframework/security/acls/jdbc/BasicLookupStrategyTests.java index a24210dce6..42a3ad2961 100644 --- a/acl/src/test/java/org/springframework/security/acls/jdbc/BasicLookupStrategyTests.java +++ b/acl/src/test/java/org/springframework/security/acls/jdbc/BasicLookupStrategyTests.java @@ -128,7 +128,7 @@ public class BasicLookupStrategyTests { ObjectIdentity topParentOid = new ObjectIdentityImpl(TARGET_CLASS, new Long(100)); ObjectIdentity middleParentOid = new ObjectIdentityImpl(TARGET_CLASS, new Long(101)); // Deliberately use an integer for the child, to reproduce bug report in SEC-819 - ObjectIdentity childOid = new ObjectIdentityImpl(TARGET_CLASS, new Integer(102)); + ObjectIdentity childOid = new ObjectIdentityImpl(TARGET_CLASS, Integer.valueOf(102)); Map map = this.strategy.readAclsById(Arrays.asList(topParentOid, middleParentOid, childOid), null); checkEntries(topParentOid, middleParentOid, childOid, map); @@ -136,7 +136,7 @@ public class BasicLookupStrategyTests { @Test public void testAclsRetrievalFromCacheOnly() throws Exception { - ObjectIdentity topParentOid = new ObjectIdentityImpl(TARGET_CLASS, new Integer(100)); + ObjectIdentity topParentOid = new ObjectIdentityImpl(TARGET_CLASS, Integer.valueOf(100)); ObjectIdentity middleParentOid = new ObjectIdentityImpl(TARGET_CLASS, new Long(101)); ObjectIdentity childOid = new ObjectIdentityImpl(TARGET_CLASS, new Long(102)); @@ -153,7 +153,7 @@ public class BasicLookupStrategyTests { @Test public void testAclsRetrievalWithCustomBatchSize() throws Exception { ObjectIdentity topParentOid = new ObjectIdentityImpl(TARGET_CLASS, new Long(100)); - ObjectIdentity middleParentOid = new ObjectIdentityImpl(TARGET_CLASS, new Integer(101)); + ObjectIdentity middleParentOid = new ObjectIdentityImpl(TARGET_CLASS, Integer.valueOf(101)); ObjectIdentity childOid = new ObjectIdentityImpl(TARGET_CLASS, new Long(102)); // Set a batch size to allow multiple database queries in order to retrieve all acls @@ -268,8 +268,8 @@ public class BasicLookupStrategyTests { ObjectIdentity grandParentOid = new ObjectIdentityImpl(TARGET_CLASS, new Long(104)); ObjectIdentity parent1Oid = new ObjectIdentityImpl(TARGET_CLASS, new Long(105)); - ObjectIdentity parent2Oid = new ObjectIdentityImpl(TARGET_CLASS, new Integer(106)); - ObjectIdentity childOid = new ObjectIdentityImpl(TARGET_CLASS, new Integer(107)); + ObjectIdentity parent2Oid = new ObjectIdentityImpl(TARGET_CLASS, Integer.valueOf(106)); + ObjectIdentity childOid = new ObjectIdentityImpl(TARGET_CLASS, Integer.valueOf(107)); // First lookup only child, thus populating the cache with grandParent, parent1 and child List checkPermission = Arrays.asList(BasePermission.READ); diff --git a/config/src/main/java/org/springframework/security/config/authentication/PasswordEncoderParser.java b/config/src/main/java/org/springframework/security/config/authentication/PasswordEncoderParser.java index 5f5e0c478f..5f8eb06423 100644 --- a/config/src/main/java/org/springframework/security/config/authentication/PasswordEncoderParser.java +++ b/config/src/main/java/org/springframework/security/config/authentication/PasswordEncoderParser.java @@ -93,7 +93,7 @@ public class PasswordEncoderParser { BeanDefinitionBuilder beanBldr = BeanDefinitionBuilder.rootBeanDefinition(beanClass); if (OPT_HASH_SHA256.equals(hash)) { - beanBldr.addConstructorArgValue(new Integer(256)); + beanBldr.addConstructorArgValue(Integer.valueOf(256)); } if (useBase64) { diff --git a/config/src/main/java/org/springframework/security/config/http/RememberMeBeanDefinitionParser.java b/config/src/main/java/org/springframework/security/config/http/RememberMeBeanDefinitionParser.java index 30d4cc1451..966ed7625f 100644 --- a/config/src/main/java/org/springframework/security/config/http/RememberMeBeanDefinitionParser.java +++ b/config/src/main/java/org/springframework/security/config/http/RememberMeBeanDefinitionParser.java @@ -100,7 +100,7 @@ class RememberMeBeanDefinitionParser implements BeanDefinitionParser { } if (tokenValiditySet) { - Integer tokenValidity = new Integer(tokenValiditySeconds); + Integer tokenValidity = Integer.valueOf(tokenValiditySeconds); if (tokenValidity.intValue() < 0 && isPersistent) { pc.getReaderContext().error(ATT_TOKEN_VALIDITY + " cannot be negative if using" + " a persistent remember-me token repository", source); diff --git a/core/src/test/java/org/springframework/security/TargetObject.java b/core/src/test/java/org/springframework/security/TargetObject.java index 9a7f045c0f..f754bb3fba 100644 --- a/core/src/test/java/org/springframework/security/TargetObject.java +++ b/core/src/test/java/org/springframework/security/TargetObject.java @@ -28,7 +28,7 @@ public class TargetObject implements ITargetObject { //~ Methods ======================================================================================================== public Integer computeHashCode(String input) { - return new Integer(input.hashCode()); + return Integer.valueOf(input.hashCode()); } public int countLength(String input) { diff --git a/core/src/test/java/org/springframework/security/access/SecurityConfigTests.java b/core/src/test/java/org/springframework/security/access/SecurityConfigTests.java index 54218f725e..c4dcf27b4d 100644 --- a/core/src/test/java/org/springframework/security/access/SecurityConfigTests.java +++ b/core/src/test/java/org/springframework/security/access/SecurityConfigTests.java @@ -74,7 +74,7 @@ public class SecurityConfigTests { MockConfigAttribute mock2 = new MockConfigAttribute("NOT_EQUAL"); Assert.assertTrue(!security1.equals(mock2)); - Integer int1 = new Integer(987); + Integer int1 = Integer.valueOf(987); Assert.assertTrue(!security1.equals(int1)); } diff --git a/core/src/test/java/org/springframework/security/access/intercept/AfterInvocationProviderManagerTests.java b/core/src/test/java/org/springframework/security/access/intercept/AfterInvocationProviderManagerTests.java index cf1f744b0a..24a835f294 100644 --- a/core/src/test/java/org/springframework/security/access/intercept/AfterInvocationProviderManagerTests.java +++ b/core/src/test/java/org/springframework/security/access/intercept/AfterInvocationProviderManagerTests.java @@ -85,7 +85,7 @@ public class AfterInvocationProviderManagerTests extends TestCase { AfterInvocationProviderManager manager = new AfterInvocationProviderManager(); List list = new Vector(); list.add(new MockAfterInvocationProvider("swap1", MethodInvocation.class, new SecurityConfig("GIVE_ME_SWAP1"))); - list.add(new Integer(45)); + list.add(Integer.valueOf(45)); list.add(new MockAfterInvocationProvider("swap3", MethodInvocation.class, new SecurityConfig("GIVE_ME_SWAP3"))); try { diff --git a/core/src/test/java/org/springframework/security/authentication/AbstractAuthenticationTokenTests.java b/core/src/test/java/org/springframework/security/authentication/AbstractAuthenticationTokenTests.java index 908831c626..23a579e0de 100644 --- a/core/src/test/java/org/springframework/security/authentication/AbstractAuthenticationTokenTests.java +++ b/core/src/test/java/org/springframework/security/authentication/AbstractAuthenticationTokenTests.java @@ -95,7 +95,7 @@ public class AbstractAuthenticationTokenTests { assertTrue(!token1.equals(token7)); assertTrue(!token7.equals(token1)); - assertTrue(!token1.equals(new Integer(100))); + assertTrue(!token1.equals(Integer.valueOf(100))); } @Test diff --git a/core/src/test/java/org/springframework/security/core/authority/GrantedAuthorityImplTests.java b/core/src/test/java/org/springframework/security/core/authority/GrantedAuthorityImplTests.java index b896245684..a3d881c914 100644 --- a/core/src/test/java/org/springframework/security/core/authority/GrantedAuthorityImplTests.java +++ b/core/src/test/java/org/springframework/security/core/authority/GrantedAuthorityImplTests.java @@ -50,7 +50,7 @@ public class GrantedAuthorityImplTests { MockGrantedAuthority mock2 = new MockGrantedAuthority("NOT_EQUAL"); assertTrue(!auth1.equals(mock2)); - Integer int1 = new Integer(222); + Integer int1 = Integer.valueOf(222); assertTrue(!auth1.equals(int1)); } diff --git a/core/src/test/java/org/springframework/security/core/token/KeyBasedPersistenceTokenServiceTests.java b/core/src/test/java/org/springframework/security/core/token/KeyBasedPersistenceTokenServiceTests.java index ae3580dc1d..c54bf7cc87 100644 --- a/core/src/test/java/org/springframework/security/core/token/KeyBasedPersistenceTokenServiceTests.java +++ b/core/src/test/java/org/springframework/security/core/token/KeyBasedPersistenceTokenServiceTests.java @@ -25,7 +25,7 @@ public class KeyBasedPersistenceTokenServiceTests { SecureRandomFactoryBean fb = new SecureRandomFactoryBean(); KeyBasedPersistenceTokenService service = new KeyBasedPersistenceTokenService(); service.setServerSecret("MY:SECRET$$$#"); - service.setServerInteger(new Integer(454545)); + service.setServerInteger(Integer.valueOf(454545)); try { SecureRandom rnd = (SecureRandom) fb.getObject(); service.setSecureRandom(rnd); diff --git a/web/src/main/java/org/springframework/security/web/PortMapperImpl.java b/web/src/main/java/org/springframework/security/web/PortMapperImpl.java index 9dcbd496e7..31f79e0e69 100644 --- a/web/src/main/java/org/springframework/security/web/PortMapperImpl.java +++ b/web/src/main/java/org/springframework/security/web/PortMapperImpl.java @@ -40,8 +40,8 @@ public class PortMapperImpl implements PortMapper { public PortMapperImpl() { httpsPortMappings = new HashMap(); - httpsPortMappings.put(new Integer(80), new Integer(443)); - httpsPortMappings.put(new Integer(8080), new Integer(8443)); + httpsPortMappings.put(Integer.valueOf(80), Integer.valueOf(443)); + httpsPortMappings.put(Integer.valueOf(8080), Integer.valueOf(8443)); } //~ Methods ======================================================================================================== @@ -92,8 +92,8 @@ public class PortMapperImpl implements PortMapper { httpsPortMappings.clear(); for (Map.Entry entry : newMappings.entrySet()) { - Integer httpPort = new Integer(entry.getKey()); - Integer httpsPort = new Integer(entry.getValue()); + Integer httpPort = Integer.valueOf(entry.getKey()); + Integer httpsPort = Integer.valueOf(entry.getValue()); if ((httpPort.intValue() < 1) || (httpPort.intValue() > 65535) || (httpsPort.intValue() < 1) || (httpsPort.intValue() > 65535)) { diff --git a/web/src/main/java/org/springframework/security/web/PortResolverImpl.java b/web/src/main/java/org/springframework/security/web/PortResolverImpl.java index 15da2bce66..5ab5a31b8d 100644 --- a/web/src/main/java/org/springframework/security/web/PortResolverImpl.java +++ b/web/src/main/java/org/springframework/security/web/PortResolverImpl.java @@ -50,10 +50,10 @@ public class PortResolverImpl implements PortResolver { String scheme = request.getScheme().toLowerCase(); if ("http".equals(scheme)) { - portLookup = portMapper.lookupHttpPort(new Integer(serverPort)); + portLookup = portMapper.lookupHttpPort(Integer.valueOf(serverPort)); } else if ("https".equals(scheme)) { - portLookup = portMapper.lookupHttpsPort(new Integer(serverPort)); + portLookup = portMapper.lookupHttpsPort(Integer.valueOf(serverPort)); } if (portLookup != null) { diff --git a/web/src/main/java/org/springframework/security/web/authentication/LoginUrlAuthenticationEntryPoint.java b/web/src/main/java/org/springframework/security/web/authentication/LoginUrlAuthenticationEntryPoint.java index 2d21323eca..063d033ac3 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/LoginUrlAuthenticationEntryPoint.java +++ b/web/src/main/java/org/springframework/security/web/authentication/LoginUrlAuthenticationEntryPoint.java @@ -167,7 +167,7 @@ public class LoginUrlAuthenticationEntryPoint implements AuthenticationEntryPoin urlBuilder.setPathInfo(loginForm); if (forceHttps && "http".equals(scheme)) { - Integer httpsPort = portMapper.lookupHttpsPort(new Integer(serverPort)); + Integer httpsPort = portMapper.lookupHttpsPort(Integer.valueOf(serverPort)); if (httpsPort != null) { // Overwrite scheme and port in the redirect URL @@ -189,7 +189,7 @@ public class LoginUrlAuthenticationEntryPoint implements AuthenticationEntryPoin throws IOException, ServletException { int serverPort = portResolver.getServerPort(request); - Integer httpsPort = portMapper.lookupHttpsPort(new Integer(serverPort)); + Integer httpsPort = portMapper.lookupHttpsPort(Integer.valueOf(serverPort)); if (httpsPort != null) { RedirectUrlBuilder urlBuilder = new RedirectUrlBuilder(); diff --git a/web/src/main/java/org/springframework/security/web/authentication/session/ConcurrentSessionControlStrategy.java b/web/src/main/java/org/springframework/security/web/authentication/session/ConcurrentSessionControlStrategy.java index 3d84659aea..9f8fa5e4d0 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/session/ConcurrentSessionControlStrategy.java +++ b/web/src/main/java/org/springframework/security/web/authentication/session/ConcurrentSessionControlStrategy.java @@ -124,7 +124,7 @@ public class ConcurrentSessionControlStrategy extends SessionFixationProtectionS SessionRegistry registry) throws SessionAuthenticationException { if (exceptionIfMaximumExceeded || (sessions == null)) { throw new SessionAuthenticationException(messages.getMessage("ConcurrentSessionControllerImpl.exceededAllowed", - new Object[] {new Integer(allowableSessions)}, + new Object[] {Integer.valueOf(allowableSessions)}, "Maximum sessions of {0} for this principal exceeded")); } diff --git a/web/src/main/java/org/springframework/security/web/savedrequest/DefaultSavedRequest.java b/web/src/main/java/org/springframework/security/web/savedrequest/DefaultSavedRequest.java index 6e4878e671..9ae1d030e6 100644 --- a/web/src/main/java/org/springframework/security/web/savedrequest/DefaultSavedRequest.java +++ b/web/src/main/java/org/springframework/security/web/savedrequest/DefaultSavedRequest.java @@ -36,13 +36,17 @@ import org.springframework.util.Assert; /** - * Represents central information from a HttpServletRequest.

This class is used by {@link - * org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter} and {@link org.springframework.security.web.savedrequest.SavedRequestAwareWrapper} to + * Represents central information from a HttpServletRequest. + *

+ * This class is used by {@link org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter} + * and {@link org.springframework.security.web.savedrequest.SavedRequestAwareWrapper} to * reproduce the request after successful authentication. An instance of this class is stored at the time of an - * authentication exception by {@link org.springframework.security.web.access.ExceptionTranslationFilter}.

- *

IMPLEMENTATION NOTE: It is assumed that this object is accessed only from the context of a single - * thread, so no synchronization around internal collection classes is performed.

- *

This class is based on code in Apache Tomcat.

+ * authentication exception by {@link org.springframework.security.web.access.ExceptionTranslationFilter}. + *

+ * IMPLEMENTATION NOTE: It is assumed that this object is accessed only from the context of a single + * thread, so no synchronization around internal collection classes is performed. + *

+ * This class is based on code in Apache Tomcat. * * @author Craig McClanahan * @author Andrey Grebnev @@ -168,7 +172,10 @@ public class DefaultSavedRequest implements SavedRequest { * Determines if the current request matches the DefaultSavedRequest. *

* All URL arguments are considered but not cookies, locales, headers or parameters. - *

+ * + * @param request the actual request to be matched against this one + * @param portResolver used to obtain the server port of the request + * @return true if the request is deemed to match this one. * */ public boolean doesRequestMatch(HttpServletRequest request, PortResolver portResolver) { @@ -190,8 +197,7 @@ public class DefaultSavedRequest implements SavedRequest { return false; } - if (!propertyEquals("serverPort", new Integer(this.serverPort), new Integer(portResolver.getServerPort(request)))) - { + if (!propertyEquals("serverPort", Integer.valueOf(this.serverPort), Integer.valueOf(portResolver.getServerPort(request)))) { return false; } @@ -269,7 +275,7 @@ public class DefaultSavedRequest implements SavedRequest { } public String[] getParameterValues(String name) { - return ((String[]) parameters.get(name)); + return parameters.get(name); } public String getPathInfo() { diff --git a/web/src/test/java/org/springframework/security/web/PortMapperImplTests.java b/web/src/test/java/org/springframework/security/web/PortMapperImplTests.java index 3b75c4aa4f..7a1f1b4c81 100644 --- a/web/src/test/java/org/springframework/security/web/PortMapperImplTests.java +++ b/web/src/test/java/org/springframework/security/web/PortMapperImplTests.java @@ -33,10 +33,10 @@ public class PortMapperImplTests extends TestCase { public void testDefaultMappingsAreKnown() throws Exception { PortMapperImpl portMapper = new PortMapperImpl(); - assertEquals(new Integer(80), portMapper.lookupHttpPort(new Integer(443))); - assertEquals(new Integer(8080), portMapper.lookupHttpPort(new Integer(8443))); - assertEquals(new Integer(443), portMapper.lookupHttpsPort(new Integer(80))); - assertEquals(new Integer(8443), portMapper.lookupHttpsPort(new Integer(8080))); + assertEquals(Integer.valueOf(80), portMapper.lookupHttpPort(Integer.valueOf(443))); + assertEquals(Integer.valueOf(8080), portMapper.lookupHttpPort(Integer.valueOf(8443))); + assertEquals(Integer.valueOf(443), portMapper.lookupHttpsPort(Integer.valueOf(80))); + assertEquals(Integer.valueOf(8443), portMapper.lookupHttpsPort(Integer.valueOf(8080))); } public void testDetectsEmptyMap() throws Exception { @@ -81,7 +81,7 @@ public class PortMapperImplTests extends TestCase { public void testReturnsNullIfHttpPortCannotBeFound() { PortMapperImpl portMapper = new PortMapperImpl(); - assertTrue(portMapper.lookupHttpPort(new Integer("34343")) == null); + assertTrue(portMapper.lookupHttpPort(Integer.valueOf("34343")) == null); } public void testSupportsCustomMappings() { @@ -91,7 +91,7 @@ public class PortMapperImplTests extends TestCase { portMapper.setPortMappings(map); - assertEquals(new Integer(79), portMapper.lookupHttpPort(new Integer(442))); - assertEquals(new Integer(442), portMapper.lookupHttpsPort(new Integer(79))); + assertEquals(Integer.valueOf(79), portMapper.lookupHttpPort(Integer.valueOf(442))); + assertEquals(Integer.valueOf(442), portMapper.lookupHttpsPort(Integer.valueOf(79))); } }