Use Integer.valueOf() in preference to new Integer()
This commit is contained in:
parent
db6da77a5f
commit
2222a7be07
|
@ -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
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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<ObjectIdentity, Acl> 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<Permission> checkPermission = Arrays.asList(BasePermission.READ);
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -40,8 +40,8 @@ public class PortMapperImpl implements PortMapper {
|
|||
|
||||
public PortMapperImpl() {
|
||||
httpsPortMappings = new HashMap<Integer, Integer>();
|
||||
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<String,String> 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)) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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"));
|
||||
}
|
||||
|
||||
|
|
|
@ -36,13 +36,17 @@ import org.springframework.util.Assert;
|
|||
|
||||
|
||||
/**
|
||||
* Represents central information from a <code>HttpServletRequest</code>.<p>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 <code>HttpServletRequest</code>.
|
||||
* <p>
|
||||
* 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}.</p>
|
||||
* <p><em>IMPLEMENTATION NOTE</em>: 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.</p>
|
||||
* <p>This class is based on code in Apache Tomcat.</p>
|
||||
* authentication exception by {@link org.springframework.security.web.access.ExceptionTranslationFilter}.
|
||||
* <p>
|
||||
* <em>IMPLEMENTATION NOTE</em>: 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.
|
||||
* <p>
|
||||
* 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 <code>DefaultSavedRequest</code>.
|
||||
* <p>
|
||||
* All URL arguments are considered but not cookies, locales, headers or parameters.
|
||||
* <p>
|
||||
*
|
||||
* @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() {
|
||||
|
|
|
@ -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)));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue