Use diamond type

This commit is contained in:
Johnny Lim 2017-11-20 02:25:30 +09:00 committed by Rob Winch
parent cfe40358bd
commit 57353d18e5
221 changed files with 423 additions and 428 deletions

View File

@ -52,7 +52,7 @@ public class AclPermissionCacheOptimizer implements PermissionCacheOptimizer {
return; return;
} }
List<ObjectIdentity> oidsToCache = new ArrayList<ObjectIdentity>(objects.size()); List<ObjectIdentity> oidsToCache = new ArrayList<>(objects.size());
for (Object domainObject : objects) { for (Object domainObject : objects) {
if (domainObject == null) { if (domainObject == null) {

View File

@ -52,7 +52,7 @@ class ArrayFilterer<T> implements Filterer<T> {
// Collect the removed objects to a HashSet so that // Collect the removed objects to a HashSet so that
// it is fast to lookup them when a filtered array // it is fast to lookup them when a filtered array
// is constructed. // is constructed.
removeList = new HashSet<T>(); removeList = new HashSet<>();
} }
// ~ Methods // ~ Methods

View File

@ -56,7 +56,7 @@ class CollectionFilterer<T> implements Filterer<T> {
// to the method may not necessarily be re-constructable (as // to the method may not necessarily be re-constructable (as
// the Collection(collection) constructor is not guaranteed and // the Collection(collection) constructor is not guaranteed and
// manually adding may lose sort order or other capabilities) // manually adding may lose sort order or other capabilities)
removeList = new HashSet<T>(); removeList = new HashSet<>();
} }
// ~ Methods // ~ Methods

View File

@ -44,7 +44,7 @@ public class AclImpl implements Acl, MutableAcl, AuditableAcl, OwnershipAcl {
private Acl parentAcl; private Acl parentAcl;
private transient AclAuthorizationStrategy aclAuthorizationStrategy; private transient AclAuthorizationStrategy aclAuthorizationStrategy;
private transient PermissionGrantingStrategy permissionGrantingStrategy; private transient PermissionGrantingStrategy permissionGrantingStrategy;
private final List<AccessControlEntry> aces = new ArrayList<AccessControlEntry>(); private final List<AccessControlEntry> aces = new ArrayList<>();
private ObjectIdentity objectIdentity; private ObjectIdentity objectIdentity;
private Serializable id; private Serializable id;
private Sid owner; // OwnershipAcl private Sid owner; // OwnershipAcl
@ -173,7 +173,7 @@ public class AclImpl implements Acl, MutableAcl, AuditableAcl, OwnershipAcl {
public List<AccessControlEntry> getEntries() { public List<AccessControlEntry> getEntries() {
// Can safely return AccessControlEntry directly, as they're immutable outside the // Can safely return AccessControlEntry directly, as they're immutable outside the
// ACL package // ACL package
return new ArrayList<AccessControlEntry>(aces); return new ArrayList<>(aces);
} }
@Override @Override

View File

@ -38,8 +38,8 @@ import org.springframework.util.Assert;
* @since 2.0.3 * @since 2.0.3
*/ */
public class DefaultPermissionFactory implements PermissionFactory { public class DefaultPermissionFactory implements PermissionFactory {
private final Map<Integer, Permission> registeredPermissionsByInteger = new HashMap<Integer, Permission>(); private final Map<Integer, Permission> registeredPermissionsByInteger = new HashMap<>();
private final Map<String, Permission> registeredPermissionsByName = new HashMap<String, Permission>(); private final Map<String, Permission> registeredPermissionsByName = new HashMap<>();
/** /**
* Registers the <tt>Permission</tt> fields from the <tt>BasePermission</tt> class. * Registers the <tt>Permission</tt> fields from the <tt>BasePermission</tt> class.
@ -156,7 +156,7 @@ public class DefaultPermissionFactory implements PermissionFactory {
return Collections.emptyList(); return Collections.emptyList();
} }
List<Permission> permissions = new ArrayList<Permission>(names.size()); List<Permission> permissions = new ArrayList<>(names.size());
for (String name : names) { for (String name : names) {
permissions.add(buildFromName(name)); permissions.add(buildFromName(name));

View File

@ -57,7 +57,7 @@ public class SidRetrievalStrategyImpl implements SidRetrievalStrategy {
public List<Sid> getSids(Authentication authentication) { public List<Sid> getSids(Authentication authentication) {
Collection<? extends GrantedAuthority> authorities = roleHierarchy Collection<? extends GrantedAuthority> authorities = roleHierarchy
.getReachableGrantedAuthorities(authentication.getAuthorities()); .getReachableGrantedAuthorities(authentication.getAuthorities());
List<Sid> sids = new ArrayList<Sid>(authorities.size() + 1); List<Sid> sids = new ArrayList<>(authorities.size() + 1);
sids.add(new PrincipalSid(authentication)); sids.add(new PrincipalSid(authentication));

View File

@ -291,13 +291,13 @@ public class BasicLookupStrategy implements LookupStrategy {
Assert.notEmpty(objects, "Objects to lookup required"); Assert.notEmpty(objects, "Objects to lookup required");
// Map<ObjectIdentity,Acl> // Map<ObjectIdentity,Acl>
Map<ObjectIdentity, Acl> result = new HashMap<ObjectIdentity, Acl>(); // contains Map<ObjectIdentity, Acl> result = new HashMap<>(); // contains
// FULLY // FULLY
// loaded // loaded
// Acl // Acl
// objects // objects
Set<ObjectIdentity> currentBatchToLoad = new HashSet<ObjectIdentity>(); Set<ObjectIdentity> currentBatchToLoad = new HashSet<>();
for (int i = 0; i < objects.size(); i++) { for (int i = 0; i < objects.size(); i++) {
final ObjectIdentity oid = objects.get(i); final ObjectIdentity oid = objects.get(i);
@ -371,7 +371,7 @@ public class BasicLookupStrategy implements LookupStrategy {
final Collection<ObjectIdentity> objectIdentities, List<Sid> sids) { final Collection<ObjectIdentity> objectIdentities, List<Sid> sids) {
Assert.notEmpty(objectIdentities, "Must provide identities to lookup"); Assert.notEmpty(objectIdentities, "Must provide identities to lookup");
final Map<Serializable, Acl> acls = new HashMap<Serializable, Acl>(); // contains final Map<Serializable, Acl> acls = new HashMap<>(); // contains
// Acls // Acls
// with // with
// StubAclParents // StubAclParents
@ -408,7 +408,7 @@ public class BasicLookupStrategy implements LookupStrategy {
} }
// Finally, convert our "acls" containing StubAclParents into true Acls // Finally, convert our "acls" containing StubAclParents into true Acls
Map<ObjectIdentity, Acl> resultMap = new HashMap<ObjectIdentity, Acl>(); Map<ObjectIdentity, Acl> resultMap = new HashMap<>();
for (Acl inputAcl : acls.values()) { for (Acl inputAcl : acls.values()) {
Assert.isInstanceOf(AclImpl.class, inputAcl, Assert.isInstanceOf(AclImpl.class, inputAcl,
@ -463,7 +463,7 @@ public class BasicLookupStrategy implements LookupStrategy {
List<AccessControlEntryImpl> aces = readAces(inputAcl); List<AccessControlEntryImpl> aces = readAces(inputAcl);
// Create a list in which to store the "aces" for the "result" AclImpl instance // Create a list in which to store the "aces" for the "result" AclImpl instance
List<AccessControlEntryImpl> acesNew = new ArrayList<AccessControlEntryImpl>(); List<AccessControlEntryImpl> acesNew = new ArrayList<>();
// Iterate over the "aces" input and replace each nested // Iterate over the "aces" input and replace each nested
// AccessControlEntryImpl.getAcl() with the new "result" AclImpl instance // AccessControlEntryImpl.getAcl() with the new "result" AclImpl instance
@ -581,7 +581,7 @@ public class BasicLookupStrategy implements LookupStrategy {
* @throws SQLException * @throws SQLException
*/ */
public Set<Long> extractData(ResultSet rs) throws SQLException { public Set<Long> extractData(ResultSet rs) throws SQLException {
Set<Long> parentIdsToLookup = new HashSet<Long>(); // Set of parent_id Longs Set<Long> parentIdsToLookup = new HashSet<>(); // Set of parent_id Longs
while (rs.next()) { while (rs.next()) {
// Convert current row into an Acl (albeit with a StubAclParent) // Convert current row into an Acl (albeit with a StubAclParent)

View File

@ -237,13 +237,13 @@ public class AclImplTests {
true, new PrincipalSid("joe")); true, new PrincipalSid("joe"));
Sid ben = new PrincipalSid("ben"); Sid ben = new PrincipalSid("ben");
try { try {
acl.isGranted(new ArrayList<Permission>(0), Arrays.asList(ben), false); acl.isGranted(new ArrayList<>(0), Arrays.asList(ben), false);
fail("It should have thrown IllegalArgumentException"); fail("It should have thrown IllegalArgumentException");
} }
catch (IllegalArgumentException expected) { catch (IllegalArgumentException expected) {
} }
try { try {
acl.isGranted(READ, new ArrayList<Sid>(0), false); acl.isGranted(READ, new ArrayList<>(0), false);
fail("It should have thrown IllegalArgumentException"); fail("It should have thrown IllegalArgumentException");
} }
catch (IllegalArgumentException expected) { catch (IllegalArgumentException expected) {
@ -500,7 +500,7 @@ public class AclImplTests {
.isTrue(); .isTrue();
assertThat(acl.isSidLoaded(BEN)).isTrue(); assertThat(acl.isSidLoaded(BEN)).isTrue();
assertThat(acl.isSidLoaded(null)).isTrue(); assertThat(acl.isSidLoaded(null)).isTrue();
assertThat(acl.isSidLoaded(new ArrayList<Sid>(0))).isTrue(); assertThat(acl.isSidLoaded(new ArrayList<>(0))).isTrue();
assertThat(acl.isSidLoaded(Arrays.asList((Sid) new GrantedAuthoritySid( assertThat(acl.isSidLoaded(Arrays.asList((Sid) new GrantedAuthoritySid(
"ROLE_IGNORED"), new GrantedAuthoritySid("ROLE_IGNORED")))) "ROLE_IGNORED"), new GrantedAuthoritySid("ROLE_IGNORED"))))
.isTrue(); .isTrue();

View File

@ -55,7 +55,7 @@ public class JdbcAclServiceTests {
// SEC-1898 // SEC-1898
@Test(expected = NotFoundException.class) @Test(expected = NotFoundException.class)
public void readAclByIdMissingAcl() { public void readAclByIdMissingAcl() {
Map<ObjectIdentity, Acl> result = new HashMap<ObjectIdentity, Acl>(); Map<ObjectIdentity, Acl> result = new HashMap<>();
when( when(
lookupStrategy.readAclsById(anyListOf(ObjectIdentity.class), lookupStrategy.readAclsById(anyListOf(ObjectIdentity.class),
anyListOf(Sid.class))).thenReturn(result); anyListOf(Sid.class))).thenReturn(result);

View File

@ -206,7 +206,7 @@ class PrePostSecured {
@PostFilter("filterObject.startsWith('a')") @PostFilter("filterObject.startsWith('a')")
public List<String> postFilterMethod() { public List<String> postFilterMethod() {
ArrayList<String> objects = new ArrayList<String>(); ArrayList<String> objects = new ArrayList<>();
objects.addAll(Arrays.asList(new String[] { "apple", "banana", "aubergine", objects.addAll(Arrays.asList(new String[] { "apple", "banana", "aubergine",
"orange" })); "orange" }));
return objects; return objects;

View File

@ -19,7 +19,6 @@ import java.util.ArrayList;
import org.jasig.cas.client.validation.Assertion; import org.jasig.cas.client.validation.Assertion;
import org.springframework.security.authentication.AbstractAuthenticationToken; import org.springframework.security.authentication.AbstractAuthenticationToken;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.SpringSecurityCoreVersion; import org.springframework.security.core.SpringSecurityCoreVersion;
/** /**
@ -37,7 +36,7 @@ public final class CasAssertionAuthenticationToken extends AbstractAuthenticatio
private final String ticket; private final String ticket;
public CasAssertionAuthenticationToken(final Assertion assertion, final String ticket) { public CasAssertionAuthenticationToken(final Assertion assertion, final String ticket) {
super(new ArrayList<GrantedAuthority>()); super(new ArrayList<>());
this.assertion = assertion; this.assertion = assertion;
this.ticket = ticket; this.ticket = ticket;

View File

@ -54,7 +54,7 @@ public final class GrantedAuthorityFromAssertionAttributesUserDetailsService ext
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
protected UserDetails loadUserDetails(final Assertion assertion) { protected UserDetails loadUserDetails(final Assertion assertion) {
final List<GrantedAuthority> grantedAuthorities = new ArrayList<GrantedAuthority>(); final List<GrantedAuthority> grantedAuthorities = new ArrayList<>();
for (final String attribute : this.attributes) { for (final String attribute : this.attributes) {
final Object value = assertion.getPrincipal().getAttributes().get(attribute); final Object value = assertion.getPrincipal().getAttributes().get(attribute);

View File

@ -33,7 +33,7 @@ import org.springframework.security.core.userdetails.User;
public abstract class AbstractStatelessTicketCacheTests { public abstract class AbstractStatelessTicketCacheTests {
protected CasAuthenticationToken getToken() { protected CasAuthenticationToken getToken() {
List<String> proxyList = new ArrayList<String>(); List<String> proxyList = new ArrayList<>();
proxyList.add("https://localhost/newPortal/login/cas"); proxyList.add("https://localhost/newPortal/login/cas");
User user = new User("rod", "password", true, true, true, true, User user = new User("rod", "password", true, true, true, true,

View File

@ -392,7 +392,7 @@ public class CasAuthenticationProviderTests {
} }
private class MockStatelessTicketCache implements StatelessTicketCache { private class MockStatelessTicketCache implements StatelessTicketCache {
private Map<String, CasAuthenticationToken> cache = new HashMap<String, CasAuthenticationToken>(); private Map<String, CasAuthenticationToken> cache = new HashMap<>();
public CasAuthenticationToken getByTicketId(String serviceTicket) { public CasAuthenticationToken getByTicketId(String serviceTicket) {
return cache.get(serviceTicket); return cache.get(serviceTicket);

View File

@ -44,7 +44,7 @@ public class GrantedAuthorityFromAssertionAttributesUserDetailsServiceTests {
uds.setConvertToUpperCase(false); uds.setConvertToUpperCase(false);
Assertion assertion = mock(Assertion.class); Assertion assertion = mock(Assertion.class);
AttributePrincipal principal = mock(AttributePrincipal.class); AttributePrincipal principal = mock(AttributePrincipal.class);
Map<String, Object> attributes = new HashMap<String, Object>(); Map<String, Object> attributes = new HashMap<>();
attributes.put("a", Arrays.asList("role_a1", "role_a2")); attributes.put("a", Arrays.asList("role_a1", "role_a2"));
attributes.put("b", "role_b"); attributes.put("b", "role_b");
attributes.put("c", "role_c"); attributes.put("c", "role_c");

View File

@ -60,7 +60,7 @@ public final class SecurityNamespaceHandler implements NamespaceHandler {
private static final String FILTER_CHAIN_PROXY_CLASSNAME = "org.springframework.security.web.FilterChainProxy"; private static final String FILTER_CHAIN_PROXY_CLASSNAME = "org.springframework.security.web.FilterChainProxy";
private static final String MESSAGE_CLASSNAME = "org.springframework.messaging.Message"; private static final String MESSAGE_CLASSNAME = "org.springframework.messaging.Message";
private final Log logger = LogFactory.getLog(getClass()); private final Log logger = LogFactory.getLog(getClass());
private final Map<String, BeanDefinitionParser> parsers = new HashMap<String, BeanDefinitionParser>(); private final Map<String, BeanDefinitionParser> parsers = new HashMap<>();
private final BeanDefinitionDecorator interceptMethodsBDD = new InterceptMethodsBeanDefinitionDecorator(); private final BeanDefinitionDecorator interceptMethodsBDD = new InterceptMethodsBeanDefinitionDecorator();
private BeanDefinitionDecorator filterChainMapBDD; private BeanDefinitionDecorator filterChainMapBDD;

View File

@ -220,9 +220,9 @@ public abstract class AbstractConfiguredSecurityBuilder<O, B extends SecurityBui
public <C extends SecurityConfigurer<O, B>> List<C> getConfigurers(Class<C> clazz) { public <C extends SecurityConfigurer<O, B>> List<C> getConfigurers(Class<C> clazz) {
List<C> configs = (List<C>) this.configurers.get(clazz); List<C> configs = (List<C>) this.configurers.get(clazz);
if (configs == null) { if (configs == null) {
return new ArrayList<C>(); return new ArrayList<>();
} }
return new ArrayList<C>(configs); return new ArrayList<>(configs);
} }
/** /**
@ -236,9 +236,9 @@ public abstract class AbstractConfiguredSecurityBuilder<O, B extends SecurityBui
public <C extends SecurityConfigurer<O, B>> List<C> removeConfigurers(Class<C> clazz) { public <C extends SecurityConfigurer<O, B>> List<C> removeConfigurers(Class<C> clazz) {
List<C> configs = (List<C>) this.configurers.remove(clazz); List<C> configs = (List<C>) this.configurers.remove(clazz);
if (configs == null) { if (configs == null) {
return new ArrayList<C>(); return new ArrayList<>();
} }
return new ArrayList<C>(configs); return new ArrayList<>(configs);
} }
/** /**

View File

@ -54,7 +54,7 @@ public class AuthenticationManagerBuilder
private final Log logger = LogFactory.getLog(getClass()); private final Log logger = LogFactory.getLog(getClass());
private AuthenticationManager parentAuthenticationManager; private AuthenticationManager parentAuthenticationManager;
private List<AuthenticationProvider> authenticationProviders = new ArrayList<AuthenticationProvider>(); private List<AuthenticationProvider> authenticationProviders = new ArrayList<>();
private UserDetailsService defaultUserDetailsService; private UserDetailsService defaultUserDetailsService;
private Boolean eraseCredentials; private Boolean eraseCredentials;
private AuthenticationEventPublisher eventPublisher; private AuthenticationEventPublisher eventPublisher;
@ -131,7 +131,7 @@ public class AuthenticationManagerBuilder
*/ */
public InMemoryUserDetailsManagerConfigurer<AuthenticationManagerBuilder> inMemoryAuthentication() public InMemoryUserDetailsManagerConfigurer<AuthenticationManagerBuilder> inMemoryAuthentication()
throws Exception { throws Exception {
return apply(new InMemoryUserDetailsManagerConfigurer<AuthenticationManagerBuilder>()); return apply(new InMemoryUserDetailsManagerConfigurer<>());
} }
/** /**
@ -161,7 +161,7 @@ public class AuthenticationManagerBuilder
*/ */
public JdbcUserDetailsManagerConfigurer<AuthenticationManagerBuilder> jdbcAuthentication() public JdbcUserDetailsManagerConfigurer<AuthenticationManagerBuilder> jdbcAuthentication()
throws Exception { throws Exception {
return apply(new JdbcUserDetailsManagerConfigurer<AuthenticationManagerBuilder>()); return apply(new JdbcUserDetailsManagerConfigurer<>());
} }
/** /**
@ -184,7 +184,7 @@ public class AuthenticationManagerBuilder
public <T extends UserDetailsService> DaoAuthenticationConfigurer<AuthenticationManagerBuilder, T> userDetailsService( public <T extends UserDetailsService> DaoAuthenticationConfigurer<AuthenticationManagerBuilder, T> userDetailsService(
T userDetailsService) throws Exception { T userDetailsService) throws Exception {
this.defaultUserDetailsService = userDetailsService; this.defaultUserDetailsService = userDetailsService;
return apply(new DaoAuthenticationConfigurer<AuthenticationManagerBuilder, T>( return apply(new DaoAuthenticationConfigurer<>(
userDetailsService)); userDetailsService));
} }
@ -203,7 +203,7 @@ public class AuthenticationManagerBuilder
*/ */
public LdapAuthenticationProviderConfigurer<AuthenticationManagerBuilder> ldapAuthentication() public LdapAuthenticationProviderConfigurer<AuthenticationManagerBuilder> ldapAuthentication()
throws Exception { throws Exception {
return apply(new LdapAuthenticationProviderConfigurer<AuthenticationManagerBuilder>()); return apply(new LdapAuthenticationProviderConfigurer<>());
} }
/** /**

View File

@ -18,7 +18,6 @@ package org.springframework.security.config.annotation.authentication.configurer
import java.util.ArrayList; import java.util.ArrayList;
import org.springframework.security.config.annotation.authentication.ProviderManagerBuilder; import org.springframework.security.config.annotation.authentication.ProviderManagerBuilder;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.provisioning.InMemoryUserDetailsManager; import org.springframework.security.provisioning.InMemoryUserDetailsManager;
/** /**
@ -39,6 +38,6 @@ public class InMemoryUserDetailsManagerConfigurer<B extends ProviderManagerBuild
* Creates a new instance * Creates a new instance
*/ */
public InMemoryUserDetailsManagerConfigurer() { public InMemoryUserDetailsManagerConfigurer() {
super(new InMemoryUserDetailsManager(new ArrayList<UserDetails>())); super(new InMemoryUserDetailsManager(new ArrayList<>()));
} }
} }

View File

@ -49,7 +49,7 @@ public class JdbcUserDetailsManagerConfigurer<B extends ProviderManagerBuilder<B
private DataSource dataSource; private DataSource dataSource;
private List<Resource> initScripts = new ArrayList<Resource>(); private List<Resource> initScripts = new ArrayList<>();
public JdbcUserDetailsManagerConfigurer(JdbcUserDetailsManager manager) { public JdbcUserDetailsManagerConfigurer(JdbcUserDetailsManager manager) {
super(manager); super(manager);

View File

@ -41,7 +41,7 @@ import org.springframework.security.provisioning.UserDetailsManager;
public class UserDetailsManagerConfigurer<B extends ProviderManagerBuilder<B>, C extends UserDetailsManagerConfigurer<B, C>> public class UserDetailsManagerConfigurer<B extends ProviderManagerBuilder<B>, C extends UserDetailsManagerConfigurer<B, C>>
extends UserDetailsServiceConfigurer<B, C, UserDetailsManager> { extends UserDetailsServiceConfigurer<B, C, UserDetailsManager> {
private final List<UserDetailsBuilder> userBuilders = new ArrayList<UserDetailsBuilder>(); private final List<UserDetailsBuilder> userBuilders = new ArrayList<>();
private final List<UserDetails> users = new ArrayList<>(); private final List<UserDetails> users = new ArrayList<>();

View File

@ -41,8 +41,8 @@ final class AutowireBeanFactoryObjectPostProcessor
implements ObjectPostProcessor<Object>, DisposableBean, SmartInitializingSingleton { implements ObjectPostProcessor<Object>, DisposableBean, SmartInitializingSingleton {
private final Log logger = LogFactory.getLog(getClass()); private final Log logger = LogFactory.getLog(getClass());
private final AutowireCapableBeanFactory autowireBeanFactory; private final AutowireCapableBeanFactory autowireBeanFactory;
private final List<DisposableBean> disposableBeans = new ArrayList<DisposableBean>(); private final List<DisposableBean> disposableBeans = new ArrayList<>();
private final List<SmartInitializingSingleton> smartSingletons = new ArrayList<SmartInitializingSingleton>(); private final List<SmartInitializingSingleton> smartSingletons = new ArrayList<>();
public AutowireBeanFactoryObjectPostProcessor( public AutowireBeanFactoryObjectPostProcessor(
AutowireCapableBeanFactory autowireBeanFactory) { AutowireCapableBeanFactory autowireBeanFactory) {

View File

@ -213,7 +213,7 @@ public class GlobalMethodSecurityConfiguration
getExpressionHandler()); getExpressionHandler());
PostInvocationAdviceProvider postInvocationAdviceProvider = new PostInvocationAdviceProvider( PostInvocationAdviceProvider postInvocationAdviceProvider = new PostInvocationAdviceProvider(
postAdvice); postAdvice);
List<AfterInvocationProvider> afterInvocationProviders = new ArrayList<AfterInvocationProvider>(); List<AfterInvocationProvider> afterInvocationProviders = new ArrayList<>();
afterInvocationProviders.add(postInvocationAdviceProvider); afterInvocationProviders.add(postInvocationAdviceProvider);
invocationProviderManager.setProviders(afterInvocationProviders); invocationProviderManager.setProviders(afterInvocationProviders);
return invocationProviderManager; return invocationProviderManager;
@ -350,7 +350,7 @@ public class GlobalMethodSecurityConfiguration
*/ */
@Bean @Bean
public MethodSecurityMetadataSource methodSecurityMetadataSource() { public MethodSecurityMetadataSource methodSecurityMetadataSource() {
List<MethodSecurityMetadataSource> sources = new ArrayList<MethodSecurityMetadataSource>(); List<MethodSecurityMetadataSource> sources = new ArrayList<>();
ExpressionBasedAnnotationAttributeFactory attributeFactory = new ExpressionBasedAnnotationAttributeFactory( ExpressionBasedAnnotationAttributeFactory attributeFactory = new ExpressionBasedAnnotationAttributeFactory(
getExpressionHandler()); getExpressionHandler());
MethodSecurityMetadataSource customMethodSecurityMetadataSource = customMethodSecurityMetadataSource(); MethodSecurityMetadataSource customMethodSecurityMetadataSource = customMethodSecurityMetadataSource();

View File

@ -61,7 +61,7 @@ final class GlobalMethodSecuritySelector implements ImportSelector {
boolean jsr250Enabled = attributes.getBoolean("jsr250Enabled"); boolean jsr250Enabled = attributes.getBoolean("jsr250Enabled");
List<String> classNames = new ArrayList<String>(4); List<String> classNames = new ArrayList<>(4);
if(isProxy) { if(isProxy) {
classNames.add(MethodSecurityMetadataSourceAdvisorRegistrar.class.getName()); classNames.add(MethodSecurityMetadataSourceAdvisorRegistrar.class.getName());
} }

View File

@ -169,7 +169,7 @@ public abstract class AbstractRequestMatcherRegistry<C> {
} }
HandlerMappingIntrospector introspector = this.context.getBean(HANDLER_MAPPING_INTROSPECTOR_BEAN_NAME, HandlerMappingIntrospector introspector = this.context.getBean(HANDLER_MAPPING_INTROSPECTOR_BEAN_NAME,
HandlerMappingIntrospector.class); HandlerMappingIntrospector.class);
List<MvcRequestMatcher> matchers = new ArrayList<MvcRequestMatcher>( List<MvcRequestMatcher> matchers = new ArrayList<>(
mvcPatterns.length); mvcPatterns.length);
for (String mvcPattern : mvcPatterns) { for (String mvcPattern : mvcPatterns) {
MvcRequestMatcher matcher = new MvcRequestMatcher(introspector, mvcPattern); MvcRequestMatcher matcher = new MvcRequestMatcher(introspector, mvcPattern);
@ -257,7 +257,7 @@ public abstract class AbstractRequestMatcherRegistry<C> {
public static List<RequestMatcher> antMatchers(HttpMethod httpMethod, public static List<RequestMatcher> antMatchers(HttpMethod httpMethod,
String... antPatterns) { String... antPatterns) {
String method = httpMethod == null ? null : httpMethod.toString(); String method = httpMethod == null ? null : httpMethod.toString();
List<RequestMatcher> matchers = new ArrayList<RequestMatcher>(); List<RequestMatcher> matchers = new ArrayList<>();
for (String pattern : antPatterns) { for (String pattern : antPatterns) {
matchers.add(new AntPathRequestMatcher(pattern, method)); matchers.add(new AntPathRequestMatcher(pattern, method));
} }
@ -290,7 +290,7 @@ public abstract class AbstractRequestMatcherRegistry<C> {
public static List<RequestMatcher> regexMatchers(HttpMethod httpMethod, public static List<RequestMatcher> regexMatchers(HttpMethod httpMethod,
String... regexPatterns) { String... regexPatterns) {
String method = httpMethod == null ? null : httpMethod.toString(); String method = httpMethod == null ? null : httpMethod.toString();
List<RequestMatcher> matchers = new ArrayList<RequestMatcher>(); List<RequestMatcher> matchers = new ArrayList<>();
for (String pattern : regexPatterns) { for (String pattern : regexPatterns) {
matchers.add(new RegexRequestMatcher(pattern, method)); matchers.add(new RegexRequestMatcher(pattern, method));
} }

View File

@ -57,7 +57,7 @@ import org.springframework.web.filter.CorsFilter;
@SuppressWarnings("serial") @SuppressWarnings("serial")
final class FilterComparator implements Comparator<Filter>, Serializable { final class FilterComparator implements Comparator<Filter>, Serializable {
private static final int STEP = 100; private static final int STEP = 100;
private Map<String, Integer> filterToOrder = new HashMap<String, Integer>(); private Map<String, Integer> filterToOrder = new HashMap<>();
FilterComparator() { FilterComparator() {
int order = 100; int order = 100;

View File

@ -119,7 +119,7 @@ public final class HttpSecurity extends
implements SecurityBuilder<DefaultSecurityFilterChain>, implements SecurityBuilder<DefaultSecurityFilterChain>,
HttpSecurityBuilder<HttpSecurity> { HttpSecurityBuilder<HttpSecurity> {
private final RequestMatcherConfigurer requestMatcherConfigurer; private final RequestMatcherConfigurer requestMatcherConfigurer;
private List<Filter> filters = new ArrayList<Filter>(); private List<Filter> filters = new ArrayList<>();
private RequestMatcher requestMatcher = AnyRequestMatcher.INSTANCE; private RequestMatcher requestMatcher = AnyRequestMatcher.INSTANCE;
private FilterComparator comparator = new FilterComparator(); private FilterComparator comparator = new FilterComparator();
@ -232,7 +232,7 @@ public final class HttpSecurity extends
* @see OpenIDLoginConfigurer * @see OpenIDLoginConfigurer
*/ */
public OpenIDLoginConfigurer<HttpSecurity> openidLogin() throws Exception { public OpenIDLoginConfigurer<HttpSecurity> openidLogin() throws Exception {
return getOrApply(new OpenIDLoginConfigurer<HttpSecurity>()); return getOrApply(new OpenIDLoginConfigurer<>());
} }
/** /**
@ -332,7 +332,7 @@ public final class HttpSecurity extends
* @see HeadersConfigurer * @see HeadersConfigurer
*/ */
public HeadersConfigurer<HttpSecurity> headers() throws Exception { public HeadersConfigurer<HttpSecurity> headers() throws Exception {
return getOrApply(new HeadersConfigurer<HttpSecurity>()); return getOrApply(new HeadersConfigurer<>());
} }
/** /**
@ -345,7 +345,7 @@ public final class HttpSecurity extends
* @throws Exception * @throws Exception
*/ */
public CorsConfigurer<HttpSecurity> cors() throws Exception { public CorsConfigurer<HttpSecurity> cors() throws Exception {
return getOrApply(new CorsConfigurer<HttpSecurity>()); return getOrApply(new CorsConfigurer<>());
} }
/** /**
@ -397,7 +397,7 @@ public final class HttpSecurity extends
* @throws Exception * @throws Exception
*/ */
public SessionManagementConfigurer<HttpSecurity> sessionManagement() throws Exception { public SessionManagementConfigurer<HttpSecurity> sessionManagement() throws Exception {
return getOrApply(new SessionManagementConfigurer<HttpSecurity>()); return getOrApply(new SessionManagementConfigurer<>());
} }
/** /**
@ -440,7 +440,7 @@ public final class HttpSecurity extends
* @see #requiresChannel() * @see #requiresChannel()
*/ */
public PortMapperConfigurer<HttpSecurity> portMapper() throws Exception { public PortMapperConfigurer<HttpSecurity> portMapper() throws Exception {
return getOrApply(new PortMapperConfigurer<HttpSecurity>()); return getOrApply(new PortMapperConfigurer<>());
} }
/** /**
@ -512,7 +512,7 @@ public final class HttpSecurity extends
* @throws Exception * @throws Exception
*/ */
public JeeConfigurer<HttpSecurity> jee() throws Exception { public JeeConfigurer<HttpSecurity> jee() throws Exception {
return getOrApply(new JeeConfigurer<HttpSecurity>()); return getOrApply(new JeeConfigurer<>());
} }
/** /**
@ -542,7 +542,7 @@ public final class HttpSecurity extends
* @throws Exception * @throws Exception
*/ */
public X509Configurer<HttpSecurity> x509() throws Exception { public X509Configurer<HttpSecurity> x509() throws Exception {
return getOrApply(new X509Configurer<HttpSecurity>()); return getOrApply(new X509Configurer<>());
} }
/** /**
@ -579,7 +579,7 @@ public final class HttpSecurity extends
* @throws Exception * @throws Exception
*/ */
public RememberMeConfigurer<HttpSecurity> rememberMe() throws Exception { public RememberMeConfigurer<HttpSecurity> rememberMe() throws Exception {
return getOrApply(new RememberMeConfigurer<HttpSecurity>()); return getOrApply(new RememberMeConfigurer<>());
} }
/** /**
@ -649,7 +649,7 @@ public final class HttpSecurity extends
public ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry authorizeRequests() public ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry authorizeRequests()
throws Exception { throws Exception {
ApplicationContext context = getContext(); ApplicationContext context = getContext();
return getOrApply(new ExpressionUrlAuthorizationConfigurer<HttpSecurity>(context)) return getOrApply(new ExpressionUrlAuthorizationConfigurer<>(context))
.getRegistry(); .getRegistry();
} }
@ -664,7 +664,7 @@ public final class HttpSecurity extends
* @throws Exception * @throws Exception
*/ */
public RequestCacheConfigurer<HttpSecurity> requestCache() throws Exception { public RequestCacheConfigurer<HttpSecurity> requestCache() throws Exception {
return getOrApply(new RequestCacheConfigurer<HttpSecurity>()); return getOrApply(new RequestCacheConfigurer<>());
} }
/** /**
@ -675,7 +675,7 @@ public final class HttpSecurity extends
* @throws Exception * @throws Exception
*/ */
public ExceptionHandlingConfigurer<HttpSecurity> exceptionHandling() throws Exception { public ExceptionHandlingConfigurer<HttpSecurity> exceptionHandling() throws Exception {
return getOrApply(new ExceptionHandlingConfigurer<HttpSecurity>()); return getOrApply(new ExceptionHandlingConfigurer<>());
} }
/** /**
@ -687,7 +687,7 @@ public final class HttpSecurity extends
* @throws Exception * @throws Exception
*/ */
public SecurityContextConfigurer<HttpSecurity> securityContext() throws Exception { public SecurityContextConfigurer<HttpSecurity> securityContext() throws Exception {
return getOrApply(new SecurityContextConfigurer<HttpSecurity>()); return getOrApply(new SecurityContextConfigurer<>());
} }
/** /**
@ -699,7 +699,7 @@ public final class HttpSecurity extends
* @throws Exception * @throws Exception
*/ */
public ServletApiConfigurer<HttpSecurity> servletApi() throws Exception { public ServletApiConfigurer<HttpSecurity> servletApi() throws Exception {
return getOrApply(new ServletApiConfigurer<HttpSecurity>()); return getOrApply(new ServletApiConfigurer<>());
} }
/** /**
@ -726,7 +726,7 @@ public final class HttpSecurity extends
*/ */
public CsrfConfigurer<HttpSecurity> csrf() throws Exception { public CsrfConfigurer<HttpSecurity> csrf() throws Exception {
ApplicationContext context = getContext(); ApplicationContext context = getContext();
return getOrApply(new CsrfConfigurer<HttpSecurity>(context)); return getOrApply(new CsrfConfigurer<>(context));
} }
/** /**
@ -767,7 +767,7 @@ public final class HttpSecurity extends
* @throws Exception * @throws Exception
*/ */
public LogoutConfigurer<HttpSecurity> logout() throws Exception { public LogoutConfigurer<HttpSecurity> logout() throws Exception {
return getOrApply(new LogoutConfigurer<HttpSecurity>()); return getOrApply(new LogoutConfigurer<>());
} }
/** /**
@ -830,7 +830,7 @@ public final class HttpSecurity extends
* @throws Exception * @throws Exception
*/ */
public AnonymousConfigurer<HttpSecurity> anonymous() throws Exception { public AnonymousConfigurer<HttpSecurity> anonymous() throws Exception {
return getOrApply(new AnonymousConfigurer<HttpSecurity>()); return getOrApply(new AnonymousConfigurer<>());
} }
/** /**
@ -894,7 +894,7 @@ public final class HttpSecurity extends
* @throws Exception * @throws Exception
*/ */
public FormLoginConfigurer<HttpSecurity> formLogin() throws Exception { public FormLoginConfigurer<HttpSecurity> formLogin() throws Exception {
return getOrApply(new FormLoginConfigurer<HttpSecurity>()); return getOrApply(new FormLoginConfigurer<>());
} }
/** /**
@ -988,7 +988,7 @@ public final class HttpSecurity extends
* @throws Exception * @throws Exception
*/ */
public OAuth2LoginConfigurer<HttpSecurity> oauth2Login() throws Exception { public OAuth2LoginConfigurer<HttpSecurity> oauth2Login() throws Exception {
return getOrApply(new OAuth2LoginConfigurer<HttpSecurity>()); return getOrApply(new OAuth2LoginConfigurer<>());
} }
/** /**
@ -1028,7 +1028,7 @@ public final class HttpSecurity extends
public ChannelSecurityConfigurer<HttpSecurity>.ChannelRequestMatcherRegistry requiresChannel() public ChannelSecurityConfigurer<HttpSecurity>.ChannelRequestMatcherRegistry requiresChannel()
throws Exception { throws Exception {
ApplicationContext context = getContext(); ApplicationContext context = getContext();
return getOrApply(new ChannelSecurityConfigurer<HttpSecurity>(context)) return getOrApply(new ChannelSecurityConfigurer<>(context))
.getRegistry(); .getRegistry();
} }
@ -1062,7 +1062,7 @@ public final class HttpSecurity extends
* @throws Exception * @throws Exception
*/ */
public HttpBasicConfigurer<HttpSecurity> httpBasic() throws Exception { public HttpBasicConfigurer<HttpSecurity> httpBasic() throws Exception {
return getOrApply(new HttpBasicConfigurer<HttpSecurity>()); return getOrApply(new HttpBasicConfigurer<>());
} }
public <C> void setSharedObject(Class<C> sharedType, C object) { public <C> void setSharedObject(Class<C> sharedType, C object) {
@ -1382,7 +1382,7 @@ public final class HttpSecurity extends
private MvcMatchersRequestMatcherConfigurer(ApplicationContext context, private MvcMatchersRequestMatcherConfigurer(ApplicationContext context,
List<MvcRequestMatcher> matchers) { List<MvcRequestMatcher> matchers) {
super(context); super(context);
this.matchers = new ArrayList<RequestMatcher>(matchers); this.matchers = new ArrayList<>(matchers);
} }
public RequestMatcherConfigurer servletPath(String servletPath) { public RequestMatcherConfigurer servletPath(String servletPath) {
@ -1403,7 +1403,7 @@ public final class HttpSecurity extends
public class RequestMatcherConfigurer public class RequestMatcherConfigurer
extends AbstractRequestMatcherRegistry<RequestMatcherConfigurer> { extends AbstractRequestMatcherRegistry<RequestMatcherConfigurer> {
protected List<RequestMatcher> matchers = new ArrayList<RequestMatcher>(); protected List<RequestMatcher> matchers = new ArrayList<>();
/** /**
* @param context * @param context

View File

@ -79,7 +79,7 @@ public final class WebSecurity extends
SecurityBuilder<Filter>, ApplicationContextAware { SecurityBuilder<Filter>, ApplicationContextAware {
private final Log logger = LogFactory.getLog(getClass()); private final Log logger = LogFactory.getLog(getClass());
private final List<RequestMatcher> ignoredRequests = new ArrayList<RequestMatcher>(); private final List<RequestMatcher> ignoredRequests = new ArrayList<>();
private final List<SecurityBuilder<? extends SecurityFilterChain>> securityFilterChainBuilders = new ArrayList<SecurityBuilder<? extends SecurityFilterChain>>(); private final List<SecurityBuilder<? extends SecurityFilterChain>> securityFilterChainBuilders = new ArrayList<SecurityBuilder<? extends SecurityFilterChain>>();
@ -281,7 +281,7 @@ public final class WebSecurity extends
+ WebSecurity.class.getSimpleName() + WebSecurity.class.getSimpleName()
+ ".addSecurityFilterChainBuilder directly"); + ".addSecurityFilterChainBuilder directly");
int chainSize = ignoredRequests.size() + securityFilterChainBuilders.size(); int chainSize = ignoredRequests.size() + securityFilterChainBuilders.size();
List<SecurityFilterChain> securityFilterChains = new ArrayList<SecurityFilterChain>( List<SecurityFilterChain> securityFilterChains = new ArrayList<>(
chainSize); chainSize);
for (RequestMatcher ignoredRequest : ignoredRequests) { for (RequestMatcher ignoredRequest : ignoredRequests) {
securityFilterChains.add(new DefaultSecurityFilterChain(ignoredRequest)); securityFilterChains.add(new DefaultSecurityFilterChain(ignoredRequest));

View File

@ -216,7 +216,7 @@ public abstract class WebSecurityConfigurerAdapter implements
.requestCache().and() .requestCache().and()
.anonymous().and() .anonymous().and()
.servletApi().and() .servletApi().and()
.apply(new DefaultLoginPageConfigurer<HttpSecurity>()).and() .apply(new DefaultLoginPageConfigurer<>()).and()
.logout(); .logout();
// @formatter:on // @formatter:on
ClassLoader classLoader = this.context.getClassLoader(); ClassLoader classLoader = this.context.getClassLoader();
@ -517,7 +517,7 @@ public abstract class WebSecurityConfigurerAdapter implements
String[] beanNamesForType = BeanFactoryUtils String[] beanNamesForType = BeanFactoryUtils
.beanNamesForTypeIncludingAncestors(applicationContext, .beanNamesForTypeIncludingAncestors(applicationContext,
AuthenticationManager.class); AuthenticationManager.class);
return new HashSet<String>(Arrays.asList(beanNamesForType)); return new HashSet<>(Arrays.asList(beanNamesForType));
} }
private static void validateBeanCycle(Object auth, Set<String> beanNames) { private static void validateBeanCycle(Object auth, Set<String> beanNames) {

View File

@ -39,7 +39,7 @@ import org.springframework.security.web.util.matcher.RequestMatcher;
*/ */
public abstract class AbstractConfigAttributeRequestMatcherRegistry<C> extends public abstract class AbstractConfigAttributeRequestMatcherRegistry<C> extends
AbstractRequestMatcherRegistry<C> { AbstractRequestMatcherRegistry<C> {
private List<UrlMapping> urlMappings = new ArrayList<UrlMapping>(); private List<UrlMapping> urlMappings = new ArrayList<>();
private List<RequestMatcher> unmappedMatchers; private List<RequestMatcher> unmappedMatchers;
/** /**

View File

@ -80,7 +80,7 @@ public final class CsrfConfigurer<H extends HttpSecurityBuilder<H>>
private CsrfTokenRepository csrfTokenRepository = new LazyCsrfTokenRepository( private CsrfTokenRepository csrfTokenRepository = new LazyCsrfTokenRepository(
new HttpSessionCsrfTokenRepository()); new HttpSessionCsrfTokenRepository());
private RequestMatcher requireCsrfProtectionMatcher = CsrfFilter.DEFAULT_CSRF_MATCHER; private RequestMatcher requireCsrfProtectionMatcher = CsrfFilter.DEFAULT_CSRF_MATCHER;
private List<RequestMatcher> ignoredCsrfProtectionMatchers = new ArrayList<RequestMatcher>(); private List<RequestMatcher> ignoredCsrfProtectionMatchers = new ArrayList<>();
private final ApplicationContext context; private final ApplicationContext context;
/** /**

View File

@ -68,7 +68,7 @@ public final class ExceptionHandlingConfigurer<H extends HttpSecurityBuilder<H>>
private AccessDeniedHandler accessDeniedHandler; private AccessDeniedHandler accessDeniedHandler;
private LinkedHashMap<RequestMatcher, AuthenticationEntryPoint> defaultEntryPointMappings = new LinkedHashMap<RequestMatcher, AuthenticationEntryPoint>(); private LinkedHashMap<RequestMatcher, AuthenticationEntryPoint> defaultEntryPointMappings = new LinkedHashMap<>();
/** /**
* Creates a new instance * Creates a new instance

View File

@ -62,7 +62,7 @@ import org.springframework.util.Assert;
*/ */
public class HeadersConfigurer<H extends HttpSecurityBuilder<H>> extends public class HeadersConfigurer<H extends HttpSecurityBuilder<H>> extends
AbstractHttpConfigurer<HeadersConfigurer<H>, H> { AbstractHttpConfigurer<HeadersConfigurer<H>, H> {
private List<HeaderWriter> headerWriters = new ArrayList<HeaderWriter>(); private List<HeaderWriter> headerWriters = new ArrayList<>();
// --- default header writers --- // --- default header writers ---
@ -766,7 +766,7 @@ public class HeadersConfigurer<H extends HttpSecurityBuilder<H>> extends
* @return * @return
*/ */
private List<HeaderWriter> getHeaderWriters() { private List<HeaderWriter> getHeaderWriters() {
List<HeaderWriter> writers = new ArrayList<HeaderWriter>(); List<HeaderWriter> writers = new ArrayList<>();
addIfNotNull(writers, contentTypeOptions.writer); addIfNotNull(writers, contentTypeOptions.writer);
addIfNotNull(writers, xssProtection.writer); addIfNotNull(writers, xssProtection.writer);
addIfNotNull(writers, cacheControl.writer); addIfNotNull(writers, cacheControl.writer);

View File

@ -97,7 +97,7 @@ public final class HttpBasicConfigurer<B extends HttpSecurityBuilder<B>> extends
public HttpBasicConfigurer() throws Exception { public HttpBasicConfigurer() throws Exception {
realmName(DEFAULT_REALM); realmName(DEFAULT_REALM);
LinkedHashMap<RequestMatcher, AuthenticationEntryPoint> entryPoints = new LinkedHashMap<RequestMatcher, AuthenticationEntryPoint>(); LinkedHashMap<RequestMatcher, AuthenticationEntryPoint> entryPoints = new LinkedHashMap<>();
entryPoints.put(X_REQUESTED_WITH, new HttpStatusEntryPoint(HttpStatus.UNAUTHORIZED)); entryPoints.put(X_REQUESTED_WITH, new HttpStatusEntryPoint(HttpStatus.UNAUTHORIZED));
DelegatingAuthenticationEntryPoint defaultEntryPoint = new DelegatingAuthenticationEntryPoint( DelegatingAuthenticationEntryPoint defaultEntryPoint = new DelegatingAuthenticationEntryPoint(

View File

@ -72,7 +72,7 @@ public final class JeeConfigurer<H extends HttpSecurityBuilder<H>> extends
AbstractHttpConfigurer<JeeConfigurer<H>, H> { AbstractHttpConfigurer<JeeConfigurer<H>, H> {
private J2eePreAuthenticatedProcessingFilter j2eePreAuthenticatedProcessingFilter; private J2eePreAuthenticatedProcessingFilter j2eePreAuthenticatedProcessingFilter;
private AuthenticationUserDetailsService<PreAuthenticatedAuthenticationToken> authenticationUserDetailsService; private AuthenticationUserDetailsService<PreAuthenticatedAuthenticationToken> authenticationUserDetailsService;
private Set<String> mappableRoles = new HashSet<String>(); private Set<String> mappableRoles = new HashSet<>();
/** /**
* Creates a new instance * Creates a new instance

View File

@ -65,7 +65,7 @@ import org.springframework.util.Assert;
*/ */
public final class LogoutConfigurer<H extends HttpSecurityBuilder<H>> extends public final class LogoutConfigurer<H extends HttpSecurityBuilder<H>> extends
AbstractHttpConfigurer<LogoutConfigurer<H>, H> { AbstractHttpConfigurer<LogoutConfigurer<H>, H> {
private List<LogoutHandler> logoutHandlers = new ArrayList<LogoutHandler>(); private List<LogoutHandler> logoutHandlers = new ArrayList<>();
private SecurityContextLogoutHandler contextLogoutHandler = new SecurityContextLogoutHandler(); private SecurityContextLogoutHandler contextLogoutHandler = new SecurityContextLogoutHandler();
private String logoutSuccessUrl = "/login?logout"; private String logoutSuccessUrl = "/login?logout";
private LogoutSuccessHandler logoutSuccessHandler; private LogoutSuccessHandler logoutSuccessHandler;
@ -75,7 +75,7 @@ public final class LogoutConfigurer<H extends HttpSecurityBuilder<H>> extends
private boolean customLogoutSuccess; private boolean customLogoutSuccess;
private LinkedHashMap<RequestMatcher, LogoutSuccessHandler> defaultLogoutSuccessHandlerMappings = private LinkedHashMap<RequestMatcher, LogoutSuccessHandler> defaultLogoutSuccessHandlerMappings =
new LinkedHashMap<RequestMatcher, LogoutSuccessHandler>(); new LinkedHashMap<>();
/** /**
* Creates a new instance * Creates a new instance

View File

@ -34,7 +34,7 @@ import org.springframework.security.web.PortMapperImpl;
public final class PortMapperConfigurer<H extends HttpSecurityBuilder<H>> extends public final class PortMapperConfigurer<H extends HttpSecurityBuilder<H>> extends
AbstractHttpConfigurer<PortMapperConfigurer<H>, H> { AbstractHttpConfigurer<PortMapperConfigurer<H>, H> {
private PortMapper portMapper; private PortMapper portMapper;
private Map<String, String> httpsPortMappings = new HashMap<String, String>(); private Map<String, String> httpsPortMappings = new HashMap<>();
/** /**
* Creates a new instance * Creates a new instance

View File

@ -139,7 +139,7 @@ public final class RequestCacheConfigurer<H extends HttpSecurityBuilder<H>> exte
boolean isCsrfEnabled = http.getConfigurer(CsrfConfigurer.class) != null; boolean isCsrfEnabled = http.getConfigurer(CsrfConfigurer.class) != null;
List<RequestMatcher> matchers = new ArrayList<RequestMatcher>(); List<RequestMatcher> matchers = new ArrayList<>();
if (isCsrfEnabled) { if (isCsrfEnabled) {
RequestMatcher getRequests = new AntPathRequestMatcher("/**", "GET"); RequestMatcher getRequests = new AntPathRequestMatcher("/**", "GET");
matchers.add(0, getRequests); matchers.add(0, getRequests);

View File

@ -100,7 +100,7 @@ public final class SessionManagementConfigurer<H extends HttpSecurityBuilder<H>>
private SessionAuthenticationStrategy providedSessionAuthenticationStrategy; private SessionAuthenticationStrategy providedSessionAuthenticationStrategy;
private InvalidSessionStrategy invalidSessionStrategy; private InvalidSessionStrategy invalidSessionStrategy;
private SessionInformationExpiredStrategy expiredSessionStrategy; private SessionInformationExpiredStrategy expiredSessionStrategy;
private List<SessionAuthenticationStrategy> sessionAuthenticationStrategies = new ArrayList<SessionAuthenticationStrategy>(); private List<SessionAuthenticationStrategy> sessionAuthenticationStrategies = new ArrayList<>();
private SessionRegistry sessionRegistry; private SessionRegistry sessionRegistry;
private Integer maximumSessions; private Integer maximumSessions;
private String expiredUrl; private String expiredUrl;

View File

@ -121,7 +121,7 @@ public final class X509Configurer<H extends HttpSecurityBuilder<H>> extends
* @return the {@link X509Configurer} for further customizations * @return the {@link X509Configurer} for further customizations
*/ */
public X509Configurer<H> userDetailsService(UserDetailsService userDetailsService) { public X509Configurer<H> userDetailsService(UserDetailsService userDetailsService) {
UserDetailsByNameServiceWrapper<PreAuthenticatedAuthenticationToken> authenticationUserDetailsService = new UserDetailsByNameServiceWrapper<PreAuthenticatedAuthenticationToken>(); UserDetailsByNameServiceWrapper<PreAuthenticatedAuthenticationToken> authenticationUserDetailsService = new UserDetailsByNameServiceWrapper<>();
authenticationUserDetailsService.setUserDetailsService(userDetailsService); authenticationUserDetailsService.setUserDetailsService(userDetailsService);
return authenticationUserDetailsService(authenticationUserDetailsService); return authenticationUserDetailsService(authenticationUserDetailsService);
} }

View File

@ -124,7 +124,7 @@ public final class OpenIDLoginConfigurer<H extends HttpSecurityBuilder<H>> exten
private OpenIDConsumer openIDConsumer; private OpenIDConsumer openIDConsumer;
private ConsumerManager consumerManager; private ConsumerManager consumerManager;
private AuthenticationUserDetailsService<OpenIDAuthenticationToken> authenticationUserDetailsService; private AuthenticationUserDetailsService<OpenIDAuthenticationToken> authenticationUserDetailsService;
private List<AttributeExchangeConfigurer> attributeExchangeConfigurers = new ArrayList<AttributeExchangeConfigurer>(); private List<AttributeExchangeConfigurer> attributeExchangeConfigurers = new ArrayList<>();
/** /**
* Creates a new instance * Creates a new instance
@ -341,7 +341,7 @@ public final class OpenIDLoginConfigurer<H extends HttpSecurityBuilder<H>> exten
if (this.authenticationUserDetailsService != null) { if (this.authenticationUserDetailsService != null) {
return this.authenticationUserDetailsService; return this.authenticationUserDetailsService;
} }
return new UserDetailsByNameServiceWrapper<OpenIDAuthenticationToken>( return new UserDetailsByNameServiceWrapper<>(
http.getSharedObject(UserDetailsService.class)); http.getSharedObject(UserDetailsService.class));
} }
@ -374,8 +374,8 @@ public final class OpenIDLoginConfigurer<H extends HttpSecurityBuilder<H>> exten
*/ */
public final class AttributeExchangeConfigurer { public final class AttributeExchangeConfigurer {
private final String identifier; private final String identifier;
private List<OpenIDAttribute> attributes = new ArrayList<OpenIDAttribute>(); private List<OpenIDAttribute> attributes = new ArrayList<>();
private List<AttributeConfigurer> attributeConfigurers = new ArrayList<AttributeConfigurer>(); private List<AttributeConfigurer> attributeConfigurers = new ArrayList<>();
/** /**
* Creates a new instance * Creates a new instance

View File

@ -51,9 +51,9 @@ public class MessageSecurityMetadataSourceRegistry {
private static final String fullyAuthenticated = "fullyAuthenticated"; private static final String fullyAuthenticated = "fullyAuthenticated";
private static final String rememberMe = "rememberMe"; private static final String rememberMe = "rememberMe";
private SecurityExpressionHandler<Message<Object>> expressionHandler = new DefaultMessageSecurityExpressionHandler<Object>(); private SecurityExpressionHandler<Message<Object>> expressionHandler = new DefaultMessageSecurityExpressionHandler<>();
private final LinkedHashMap<MatcherBuilder, String> matcherToExpression = new LinkedHashMap<MatcherBuilder, String>(); private final LinkedHashMap<MatcherBuilder, String> matcherToExpression = new LinkedHashMap<>();
private DelegatingPathMatcher pathMatcher = new DelegatingPathMatcher(); private DelegatingPathMatcher pathMatcher = new DelegatingPathMatcher();
@ -160,7 +160,7 @@ public class MessageSecurityMetadataSourceRegistry {
* @see {@link MessageSecurityMetadataSourceRegistry#simpDestPathMatcher(PathMatcher)} * @see {@link MessageSecurityMetadataSourceRegistry#simpDestPathMatcher(PathMatcher)}
*/ */
private Constraint simpDestMatchers(SimpMessageType type, String... patterns) { private Constraint simpDestMatchers(SimpMessageType type, String... patterns) {
List<MatcherBuilder> matchers = new ArrayList<MatcherBuilder>(patterns.length); List<MatcherBuilder> matchers = new ArrayList<>(patterns.length);
for (String pattern : patterns) { for (String pattern : patterns) {
matchers.add(new PathMatcherMessageMatcherBuilder(pattern, type)); matchers.add(new PathMatcherMessageMatcherBuilder(pattern, type));
} }
@ -201,7 +201,7 @@ public class MessageSecurityMetadataSourceRegistry {
* instances * instances
*/ */
public Constraint matchers(MessageMatcher<?>... matchers) { public Constraint matchers(MessageMatcher<?>... matchers) {
List<MatcherBuilder> builders = new ArrayList<MatcherBuilder>(matchers.length); List<MatcherBuilder> builders = new ArrayList<>(matchers.length);
for (MessageMatcher<?> matcher : matchers) { for (MessageMatcher<?> matcher : matchers) {
builders.add(new PreBuiltMatcherBuilder(matcher)); builders.add(new PreBuiltMatcherBuilder(matcher));
} }

View File

@ -87,7 +87,7 @@ public abstract class AbstractSecurityWebSocketMessageBrokerConfigurer extends
AbstractWebSocketMessageBrokerConfigurer implements SmartInitializingSingleton { AbstractWebSocketMessageBrokerConfigurer implements SmartInitializingSingleton {
private final WebSocketMessageSecurityMetadataSourceRegistry inboundRegistry = new WebSocketMessageSecurityMetadataSourceRegistry(); private final WebSocketMessageSecurityMetadataSourceRegistry inboundRegistry = new WebSocketMessageSecurityMetadataSourceRegistry();
private SecurityExpressionHandler<Message<Object>> defaultExpressionHandler = new DefaultMessageSecurityExpressionHandler<Object>(); private SecurityExpressionHandler<Message<Object>> defaultExpressionHandler = new DefaultMessageSecurityExpressionHandler<>();
private SecurityExpressionHandler<Message<Object>> expressionHandler; private SecurityExpressionHandler<Message<Object>> expressionHandler;
@ -156,7 +156,7 @@ public abstract class AbstractSecurityWebSocketMessageBrokerConfigurer extends
public ChannelSecurityInterceptor inboundChannelSecurity() { public ChannelSecurityInterceptor inboundChannelSecurity() {
ChannelSecurityInterceptor channelSecurityInterceptor = new ChannelSecurityInterceptor( ChannelSecurityInterceptor channelSecurityInterceptor = new ChannelSecurityInterceptor(
inboundMessageSecurityMetadataSource()); inboundMessageSecurityMetadataSource());
MessageExpressionVoter<Object> voter = new MessageExpressionVoter<Object>(); MessageExpressionVoter<Object> voter = new MessageExpressionVoter<>();
voter.setExpressionHandler(getMessageExpressionHandler()); voter.setExpressionHandler(getMessageExpressionHandler());
List<AccessDecisionVoter<? extends Object>> voters = new ArrayList<AccessDecisionVoter<? extends Object>>(); List<AccessDecisionVoter<? extends Object>> voters = new ArrayList<AccessDecisionVoter<? extends Object>>();
@ -255,7 +255,7 @@ public abstract class AbstractSecurityWebSocketMessageBrokerConfigurer extends
TransportHandlingSockJsService transportHandlingSockJsService = (TransportHandlingSockJsService) sockJsService; TransportHandlingSockJsService transportHandlingSockJsService = (TransportHandlingSockJsService) sockJsService;
List<HandshakeInterceptor> handshakeInterceptors = transportHandlingSockJsService List<HandshakeInterceptor> handshakeInterceptors = transportHandlingSockJsService
.getHandshakeInterceptors(); .getHandshakeInterceptors();
List<HandshakeInterceptor> interceptorsToSet = new ArrayList<HandshakeInterceptor>( List<HandshakeInterceptor> interceptorsToSet = new ArrayList<>(
handshakeInterceptors.size() + 1); handshakeInterceptors.size() + 1);
interceptorsToSet.add(new CsrfTokenHandshakeInterceptor()); interceptorsToSet.add(new CsrfTokenHandshakeInterceptor());
interceptorsToSet.addAll(handshakeInterceptors); interceptorsToSet.addAll(handshakeInterceptors);
@ -267,7 +267,7 @@ public abstract class AbstractSecurityWebSocketMessageBrokerConfigurer extends
WebSocketHttpRequestHandler handler = (WebSocketHttpRequestHandler) object; WebSocketHttpRequestHandler handler = (WebSocketHttpRequestHandler) object;
List<HandshakeInterceptor> handshakeInterceptors = handler List<HandshakeInterceptor> handshakeInterceptors = handler
.getHandshakeInterceptors(); .getHandshakeInterceptors();
List<HandshakeInterceptor> interceptorsToSet = new ArrayList<HandshakeInterceptor>( List<HandshakeInterceptor> interceptorsToSet = new ArrayList<>(
handshakeInterceptors.size() + 1); handshakeInterceptors.size() + 1);
interceptorsToSet.add(new CsrfTokenHandshakeInterceptor()); interceptorsToSet.add(new CsrfTokenHandshakeInterceptor());
interceptorsToSet.addAll(handshakeInterceptors); interceptorsToSet.addAll(handshakeInterceptors);

View File

@ -71,7 +71,7 @@ public class AuthenticationManagerBeanDefinitionParser implements BeanDefinition
String alias = element.getAttribute(ATT_ALIAS); String alias = element.getAttribute(ATT_ALIAS);
List<BeanMetadataElement> providers = new ManagedList<BeanMetadataElement>(); List<BeanMetadataElement> providers = new ManagedList<>();
NamespaceHandlerResolver resolver = pc.getReaderContext() NamespaceHandlerResolver resolver = pc.getReaderContext()
.getNamespaceHandlerResolver(); .getNamespaceHandlerResolver();

View File

@ -82,7 +82,7 @@ public class UserServiceBeanDefinitionParser extends
+ ATT_PROPERTIES + "' attribute)"); + ATT_PROPERTIES + "' attribute)");
} }
ManagedList<BeanDefinition> users = new ManagedList<BeanDefinition>(); ManagedList<BeanDefinition> users = new ManagedList<>();
for (Object elt : userElts) { for (Object elt : userElts) {
Element userElt = (Element) elt; Element userElt = (Element) elt;

View File

@ -302,7 +302,7 @@ final class AuthenticationConfigBuilder {
} }
private ManagedList<BeanDefinition> parseOpenIDAttributes(Element attrExElt) { private ManagedList<BeanDefinition> parseOpenIDAttributes(Element attrExElt) {
ManagedList<BeanDefinition> attributes = new ManagedList<BeanDefinition>(); ManagedList<BeanDefinition> attributes = new ManagedList<>();
for (Element attElt : DomUtils.getChildElementsByTagName(attrExElt, for (Element attElt : DomUtils.getChildElementsByTagName(attrExElt,
Elements.OPENID_ATTRIBUTE)) { Elements.OPENID_ATTRIBUTE)) {
String name = attElt.getAttribute("name"); String name = attElt.getAttribute("name");
@ -764,7 +764,7 @@ final class AuthenticationConfigBuilder {
} }
List<OrderDecorator> getFilters() { List<OrderDecorator> getFilters() {
List<OrderDecorator> filters = new ArrayList<OrderDecorator>(); List<OrderDecorator> filters = new ArrayList<>();
if (anonymousFilter != null) { if (anonymousFilter != null) {
filters.add(new OrderDecorator(anonymousFilter, ANONYMOUS_FILTER)); filters.add(new OrderDecorator(anonymousFilter, ANONYMOUS_FILTER));
@ -810,7 +810,7 @@ final class AuthenticationConfigBuilder {
} }
List<BeanReference> getProviders() { List<BeanReference> getProviders() {
List<BeanReference> providers = new ArrayList<BeanReference>(); List<BeanReference> providers = new ArrayList<>();
if (anonymousProviderRef != null) { if (anonymousProviderRef != null) {
providers.add(anonymousProviderRef); providers.add(anonymousProviderRef);

View File

@ -52,8 +52,8 @@ public class DefaultFilterChainValidator implements FilterChainProxy.FilterChain
checkFilterStack(filterChain.getFilters()); checkFilterStack(filterChain.getFilters());
} }
checkPathOrder(new ArrayList<SecurityFilterChain>(fcp.getFilterChains())); checkPathOrder(new ArrayList<>(fcp.getFilterChains()));
checkForDuplicateMatchers(new ArrayList<SecurityFilterChain>( checkForDuplicateMatchers(new ArrayList<>(
fcp.getFilterChains())); fcp.getFilterChains()));
} }

View File

@ -57,7 +57,7 @@ public class FilterChainBeanDefinitionParser implements BeanDefinitionParser {
} }
else { else {
String[] filterBeanNames = StringUtils.tokenizeToStringArray(filters, ","); String[] filterBeanNames = StringUtils.tokenizeToStringArray(filters, ",");
ManagedList<RuntimeBeanReference> filterChain = new ManagedList<RuntimeBeanReference>( ManagedList<RuntimeBeanReference> filterChain = new ManagedList<>(
filterBeanNames.length); filterBeanNames.length);
for (String name : filterBeanNames) { for (String name : filterBeanNames) {

View File

@ -44,7 +44,7 @@ public class FilterChainMapBeanDefinitionDecorator implements BeanDefinitionDeco
ParserContext parserContext) { ParserContext parserContext) {
BeanDefinition filterChainProxy = holder.getBeanDefinition(); BeanDefinition filterChainProxy = holder.getBeanDefinition();
ManagedList<BeanMetadataElement> securityFilterChains = new ManagedList<BeanMetadataElement>(); ManagedList<BeanMetadataElement> securityFilterChains = new ManagedList<>();
Element elt = (Element) node; Element elt = (Element) node;
MatcherType matcherType = MatcherType.fromElement(elt); MatcherType matcherType = MatcherType.fromElement(elt);

View File

@ -155,7 +155,7 @@ public class FilterInvocationSecurityMetadataSourceParser implements BeanDefinit
MatcherType matcherType, List<Element> urlElts, boolean useExpressions, MatcherType matcherType, List<Element> urlElts, boolean useExpressions,
boolean addAuthenticatedAll, ParserContext parserContext) { boolean addAuthenticatedAll, ParserContext parserContext) {
ManagedMap<BeanMetadataElement, BeanDefinition> filterInvocationDefinitionMap = new ManagedMap<BeanMetadataElement, BeanDefinition>(); ManagedMap<BeanMetadataElement, BeanDefinition> filterInvocationDefinitionMap = new ManagedMap<>();
for (Element urlElt : urlElts) { for (Element urlElt : urlElts) {
String access = urlElt.getAttribute(ATT_ACCESS); String access = urlElt.getAttribute(ATT_ACCESS);

View File

@ -91,7 +91,7 @@ public class HeadersBeanDefinitionParser implements BeanDefinitionParser {
private ManagedList<BeanMetadataElement> headerWriters; private ManagedList<BeanMetadataElement> headerWriters;
public BeanDefinition parse(Element element, ParserContext parserContext) { public BeanDefinition parse(Element element, ParserContext parserContext) {
headerWriters = new ManagedList<BeanMetadataElement>(); headerWriters = new ManagedList<>();
BeanDefinitionBuilder builder = BeanDefinitionBuilder BeanDefinitionBuilder builder = BeanDefinitionBuilder
.rootBeanDefinition(HeaderWriterFilter.class); .rootBeanDefinition(HeaderWriterFilter.class);
@ -220,7 +220,7 @@ public class HeadersBeanDefinitionParser implements BeanDefinitionParser {
if (pinsElement != null) { if (pinsElement != null) {
List<Element> pinElements = DomUtils.getChildElements(pinsElement); List<Element> pinElements = DomUtils.getChildElements(pinsElement);
Map<String, String> pins = new LinkedHashMap<String, String>(); Map<String, String> pins = new LinkedHashMap<>();
for (Element pinElement : pinElements) { for (Element pinElement : pinElements) {
String hash = pinElement.getAttribute(ATT_ALGORITHM); String hash = pinElement.getAttribute(ATT_ALGORITHM);

View File

@ -370,7 +370,7 @@ class HttpConfigurationBuilder {
boolean sessionFixationProtectionRequired = !sessionFixationAttribute boolean sessionFixationProtectionRequired = !sessionFixationAttribute
.equals(OPT_SESSION_FIXATION_NO_PROTECTION); .equals(OPT_SESSION_FIXATION_NO_PROTECTION);
ManagedList<BeanMetadataElement> delegateSessionStrategies = new ManagedList<BeanMetadataElement>(); ManagedList<BeanMetadataElement> delegateSessionStrategies = new ManagedList<>();
BeanDefinitionBuilder concurrentSessionStrategy; BeanDefinitionBuilder concurrentSessionStrategy;
BeanDefinitionBuilder sessionFixationStrategy = null; BeanDefinitionBuilder sessionFixationStrategy = null;
BeanDefinitionBuilder registerSessionStrategy; BeanDefinitionBuilder registerSessionStrategy;
@ -601,7 +601,7 @@ class HttpConfigurationBuilder {
metadataSourceBldr.getBeanDefinition()); metadataSourceBldr.getBeanDefinition());
RootBeanDefinition channelDecisionManager = new RootBeanDefinition( RootBeanDefinition channelDecisionManager = new RootBeanDefinition(
ChannelDecisionManagerImpl.class); ChannelDecisionManagerImpl.class);
ManagedList<RootBeanDefinition> channelProcessors = new ManagedList<RootBeanDefinition>( ManagedList<RootBeanDefinition> channelProcessors = new ManagedList<>(
3); 3);
RootBeanDefinition secureChannelProcessor = new RootBeanDefinition( RootBeanDefinition secureChannelProcessor = new RootBeanDefinition(
SecureChannelProcessor.class); SecureChannelProcessor.class);
@ -639,7 +639,7 @@ class HttpConfigurationBuilder {
*/ */
private ManagedMap<BeanMetadataElement, BeanDefinition> parseInterceptUrlsForChannelSecurity() { private ManagedMap<BeanMetadataElement, BeanDefinition> parseInterceptUrlsForChannelSecurity() {
ManagedMap<BeanMetadataElement, BeanDefinition> channelRequestMap = new ManagedMap<BeanMetadataElement, BeanDefinition>(); ManagedMap<BeanMetadataElement, BeanDefinition> channelRequestMap = new ManagedMap<>();
for (Element urlElt : interceptUrls) { for (Element urlElt : interceptUrls) {
String path = urlElt.getAttribute(ATT_PATH_PATTERN); String path = urlElt.getAttribute(ATT_PATH_PATTERN);
@ -719,7 +719,7 @@ class HttpConfigurationBuilder {
.createSecurityMetadataSource(interceptUrls, addAllAuth, httpElt, pc); .createSecurityMetadataSource(interceptUrls, addAllAuth, httpElt, pc);
RootBeanDefinition accessDecisionMgr; RootBeanDefinition accessDecisionMgr;
ManagedList<BeanDefinition> voters = new ManagedList<BeanDefinition>(2); ManagedList<BeanDefinition> voters = new ManagedList<>(2);
if (useExpressions) { if (useExpressions) {
BeanDefinitionBuilder expressionVoter = BeanDefinitionBuilder BeanDefinitionBuilder expressionVoter = BeanDefinitionBuilder
@ -820,7 +820,7 @@ class HttpConfigurationBuilder {
} }
List<OrderDecorator> getFilters() { List<OrderDecorator> getFilters() {
List<OrderDecorator> filters = new ArrayList<OrderDecorator>(); List<OrderDecorator> filters = new ArrayList<>();
if (cpf != null) { if (cpf != null) {
filters.add(new OrderDecorator(cpf, CHANNEL_FILTER)); filters.add(new OrderDecorator(cpf, CHANNEL_FILTER));

View File

@ -138,7 +138,7 @@ public class HttpSecurityBeanDefinitionParser implements BeanDefinitionParser {
final BeanReference portMapper = createPortMapper(element, pc); final BeanReference portMapper = createPortMapper(element, pc);
final BeanReference portResolver = createPortResolver(portMapper, pc); final BeanReference portResolver = createPortResolver(portMapper, pc);
ManagedList<BeanReference> authenticationProviders = new ManagedList<BeanReference>(); ManagedList<BeanReference> authenticationProviders = new ManagedList<>();
BeanReference authenticationManager = createAuthenticationManager(element, pc, BeanReference authenticationManager = createAuthenticationManager(element, pc,
authenticationProviders); authenticationProviders);
@ -158,7 +158,7 @@ public class HttpSecurityBeanDefinitionParser implements BeanDefinitionParser {
authenticationProviders.addAll(authBldr.getProviders()); authenticationProviders.addAll(authBldr.getProviders());
List<OrderDecorator> unorderedFilterChain = new ArrayList<OrderDecorator>(); List<OrderDecorator> unorderedFilterChain = new ArrayList<>();
unorderedFilterChain.addAll(httpBldr.getFilters()); unorderedFilterChain.addAll(httpBldr.getFilters());
unorderedFilterChain.addAll(authBldr.getFilters()); unorderedFilterChain.addAll(authBldr.getFilters());
@ -168,7 +168,7 @@ public class HttpSecurityBeanDefinitionParser implements BeanDefinitionParser {
checkFilterChainOrder(unorderedFilterChain, pc, pc.extractSource(element)); checkFilterChainOrder(unorderedFilterChain, pc, pc.extractSource(element));
// The list of filter beans // The list of filter beans
List<BeanMetadataElement> filterChain = new ManagedList<BeanMetadataElement>(); List<BeanMetadataElement> filterChain = new ManagedList<>();
for (OrderDecorator od : unorderedFilterChain) { for (OrderDecorator od : unorderedFilterChain) {
filterChain.add(od.bean); filterChain.add(od.bean);
@ -330,7 +330,7 @@ public class HttpSecurityBeanDefinitionParser implements BeanDefinitionParser {
List<OrderDecorator> buildCustomFilterList(Element element, ParserContext pc) { List<OrderDecorator> buildCustomFilterList(Element element, ParserContext pc) {
List<Element> customFilterElts = DomUtils.getChildElementsByTagName(element, List<Element> customFilterElts = DomUtils.getChildElementsByTagName(element,
Elements.CUSTOM_FILTER); Elements.CUSTOM_FILTER);
List<OrderDecorator> customFilters = new ArrayList<OrderDecorator>(); List<OrderDecorator> customFilters = new ArrayList<>();
final String ATT_AFTER = "after"; final String ATT_AFTER = "after";
final String ATT_BEFORE = "before"; final String ATT_BEFORE = "before";

View File

@ -45,7 +45,7 @@ class LogoutBeanDefinitionParser implements BeanDefinitionParser {
final String rememberMeServices; final String rememberMeServices;
private final String defaultLogoutUrl; private final String defaultLogoutUrl;
private ManagedList<BeanMetadataElement> logoutHandlers = new ManagedList<BeanMetadataElement>(); private ManagedList<BeanMetadataElement> logoutHandlers = new ManagedList<>();
private boolean csrfEnabled; private boolean csrfEnabled;
public LogoutBeanDefinitionParser(String loginPageUrl, String rememberMeServices, public LogoutBeanDefinitionParser(String loginPageUrl, String rememberMeServices,

View File

@ -113,7 +113,7 @@ public class GlobalMethodSecurityBeanDefinitionParser implements BeanDefinitionP
Object source = pc.extractSource(element); Object source = pc.extractSource(element);
// The list of method metadata delegates // The list of method metadata delegates
ManagedList<BeanMetadataElement> delegates = new ManagedList<BeanMetadataElement>(); ManagedList<BeanMetadataElement> delegates = new ManagedList<>();
boolean jsr250Enabled = "enabled".equals(element.getAttribute(ATT_USE_JSR250)); boolean jsr250Enabled = "enabled".equals(element.getAttribute(ATT_USE_JSR250));
boolean useSecured = "enabled".equals(element.getAttribute(ATT_USE_SECURED)); boolean useSecured = "enabled".equals(element.getAttribute(ATT_USE_SECURED));
@ -122,7 +122,7 @@ public class GlobalMethodSecurityBeanDefinitionParser implements BeanDefinitionP
boolean useAspectJ = "aspectj".equals(element.getAttribute(ATT_MODE)); boolean useAspectJ = "aspectj".equals(element.getAttribute(ATT_MODE));
BeanDefinition preInvocationVoter = null; BeanDefinition preInvocationVoter = null;
ManagedList<BeanMetadataElement> afterInvocationProviders = new ManagedList<BeanMetadataElement>(); ManagedList<BeanMetadataElement> afterInvocationProviders = new ManagedList<>();
// Check for an external SecurityMetadataSource, which takes priority over other // Check for an external SecurityMetadataSource, which takes priority over other
// sources // sources
@ -399,7 +399,7 @@ public class GlobalMethodSecurityBeanDefinitionParser implements BeanDefinitionP
String[] attributeTokens = StringUtils String[] attributeTokens = StringUtils
.commaDelimitedListToStringArray(accessConfig); .commaDelimitedListToStringArray(accessConfig);
List<ConfigAttribute> attributes = new ArrayList<ConfigAttribute>( List<ConfigAttribute> attributes = new ArrayList<>(
attributeTokens.length); attributeTokens.length);
for (String token : attributeTokens) { for (String token : attributeTokens) {

View File

@ -88,7 +88,7 @@ class InternalInterceptMethodsBeanDefinitionDecorator extends
// Parse the included methods // Parse the included methods
List<Element> methods = DomUtils.getChildElementsByTagName(interceptMethodsElt, List<Element> methods = DomUtils.getChildElementsByTagName(interceptMethodsElt,
Elements.PROTECT); Elements.PROTECT);
Map<String, BeanDefinition> mappings = new ManagedMap<String, BeanDefinition>(); Map<String, BeanDefinition> mappings = new ManagedMap<>();
for (Element protectmethodElt : methods) { for (Element protectmethodElt : methods) {
BeanDefinitionBuilder attributeBuilder = BeanDefinitionBuilder BeanDefinitionBuilder attributeBuilder = BeanDefinitionBuilder

View File

@ -64,9 +64,9 @@ final class ProtectPointcutPostProcessor implements BeanPostProcessor {
private final Map<String, List<ConfigAttribute>> pointcutMap = new LinkedHashMap<String, List<ConfigAttribute>>(); private final Map<String, List<ConfigAttribute>> pointcutMap = new LinkedHashMap<String, List<ConfigAttribute>>();
private final MapBasedMethodSecurityMetadataSource mapBasedMethodSecurityMetadataSource; private final MapBasedMethodSecurityMetadataSource mapBasedMethodSecurityMetadataSource;
private final Set<PointcutExpression> pointCutExpressions = new LinkedHashSet<PointcutExpression>(); private final Set<PointcutExpression> pointCutExpressions = new LinkedHashSet<>();
private final PointcutParser parser; private final PointcutParser parser;
private final Set<String> processedBeans = new HashSet<String>(); private final Set<String> processedBeans = new HashSet<>();
public ProtectPointcutPostProcessor( public ProtectPointcutPostProcessor(
MapBasedMethodSecurityMetadataSource mapBasedMethodSecurityMetadataSource) { MapBasedMethodSecurityMetadataSource mapBasedMethodSecurityMetadataSource) {
@ -75,7 +75,7 @@ final class ProtectPointcutPostProcessor implements BeanPostProcessor {
this.mapBasedMethodSecurityMetadataSource = mapBasedMethodSecurityMetadataSource; this.mapBasedMethodSecurityMetadataSource = mapBasedMethodSecurityMetadataSource;
// Set up AspectJ pointcut expression parser // Set up AspectJ pointcut expression parser
Set<PointcutPrimitive> supportedPrimitives = new HashSet<PointcutPrimitive>(3); Set<PointcutPrimitive> supportedPrimitives = new HashSet<>(3);
supportedPrimitives.add(PointcutPrimitive.EXECUTION); supportedPrimitives.add(PointcutPrimitive.EXECUTION);
supportedPrimitives.add(PointcutPrimitive.ARGS); supportedPrimitives.add(PointcutPrimitive.ARGS);
supportedPrimitives.add(PointcutPrimitive.REFERENCE); supportedPrimitives.add(PointcutPrimitive.REFERENCE);

View File

@ -116,7 +116,7 @@ public final class WebSocketMessageBrokerSecurityBeanDefinitionParser implements
BeanDefinitionRegistry registry = parserContext.getRegistry(); BeanDefinitionRegistry registry = parserContext.getRegistry();
XmlReaderContext context = parserContext.getReaderContext(); XmlReaderContext context = parserContext.getReaderContext();
ManagedMap<BeanDefinition, String> matcherToExpression = new ManagedMap<BeanDefinition, String>(); ManagedMap<BeanDefinition, String> matcherToExpression = new ManagedMap<>();
String id = element.getAttribute(ID_ATTR); String id = element.getAttribute(ID_ATTR);
Element expressionHandlerElt = DomUtils.getChildElementByTagName(element, Element expressionHandlerElt = DomUtils.getChildElementByTagName(element,
@ -149,7 +149,7 @@ public final class WebSocketMessageBrokerSecurityBeanDefinitionParser implements
String mdsId = context.registerWithGeneratedName(mds.getBeanDefinition()); String mdsId = context.registerWithGeneratedName(mds.getBeanDefinition());
ManagedList<BeanDefinition> voters = new ManagedList<BeanDefinition>(); ManagedList<BeanDefinition> voters = new ManagedList<>();
BeanDefinitionBuilder messageExpressionVoterBldr = BeanDefinitionBuilder.rootBeanDefinition(MessageExpressionVoter.class); BeanDefinitionBuilder messageExpressionVoterBldr = BeanDefinitionBuilder.rootBeanDefinition(MessageExpressionVoter.class);
if(expressionHandlerDefined) { if(expressionHandlerDefined) {
messageExpressionVoterBldr.addPropertyReference("expressionHandler", expressionHandlerRef); messageExpressionVoterBldr.addPropertyReference("expressionHandler", expressionHandlerRef);
@ -259,7 +259,7 @@ public final class WebSocketMessageBrokerSecurityBeanDefinitionParser implements
WEB_SOCKET_AMMH_CLASS_NAME.equals(beanClassName)) { WEB_SOCKET_AMMH_CLASS_NAME.equals(beanClassName)) {
PropertyValue current = bd.getPropertyValues().getPropertyValue( PropertyValue current = bd.getPropertyValues().getPropertyValue(
CUSTOM_ARG_RESOLVERS_PROP); CUSTOM_ARG_RESOLVERS_PROP);
ManagedList<Object> argResolvers = new ManagedList<Object>(); ManagedList<Object> argResolvers = new ManagedList<>();
if (current != null) { if (current != null) {
argResolvers.addAll((ManagedList<?>) current.getValue()); argResolvers.addAll((ManagedList<?>) current.getValue());
} }
@ -322,7 +322,7 @@ public final class WebSocketMessageBrokerSecurityBeanDefinitionParser implements
return; return;
} }
String interceptorPropertyName = "handshakeInterceptors"; String interceptorPropertyName = "handshakeInterceptors";
ManagedList<? super Object> interceptors = new ManagedList<Object>(); ManagedList<? super Object> interceptors = new ManagedList<>();
interceptors.add(new RootBeanDefinition(CsrfTokenHandshakeInterceptor.class)); interceptors.add(new RootBeanDefinition(CsrfTokenHandshakeInterceptor.class));
interceptors.addAll((ManagedList<Object>) bd.getPropertyValues().get( interceptors.addAll((ManagedList<Object>) bd.getPropertyValues().get(
interceptorPropertyName)); interceptorPropertyName));

View File

@ -31,7 +31,7 @@ public class ObjectPostProcessorTests {
@Test @Test
public void convertTypes() { public void convertTypes() {
assertThat((Object) PerformConversion.perform(new ArrayList<Object>())) assertThat((Object) PerformConversion.perform(new ArrayList<>()))
.isInstanceOf(LinkedList.class); .isInstanceOf(LinkedList.class);
} }
} }

View File

@ -25,7 +25,7 @@ public class DisableUseExpressionsConfig extends BaseWebConfig {
protected void configure(HttpSecurity http) throws Exception { protected void configure(HttpSecurity http) throws Exception {
// This config is also on UrlAuthorizationConfigurer javadoc // This config is also on UrlAuthorizationConfigurer javadoc
http http
.apply(new UrlAuthorizationConfigurer<HttpSecurity>(getApplicationContext())).getRegistry() .apply(new UrlAuthorizationConfigurer<>(getApplicationContext())).getRegistry()
.antMatchers("/users**", "/sessions/**").hasRole("USER") .antMatchers("/users**", "/sessions/**").hasRole("USER")
.antMatchers("/signup").hasRole("ANONYMOUS") .antMatchers("/signup").hasRole("ANONYMOUS")
.anyRequest().hasRole("USER"); .anyRequest().hasRole("USER");

View File

@ -24,8 +24,8 @@ import java.util.*;
* @author Luke Taylor * @author Luke Taylor
*/ */
public class BeanNameCollectingPostProcessor implements BeanPostProcessor { public class BeanNameCollectingPostProcessor implements BeanPostProcessor {
Set<String> beforeInitPostProcessedBeans = new HashSet<String>(); Set<String> beforeInitPostProcessedBeans = new HashSet<>();
Set<String> afterInitPostProcessedBeans = new HashSet<String>(); Set<String> afterInitPostProcessedBeans = new HashSet<>();
public Object postProcessBeforeInitialization(Object bean, String beanName) public Object postProcessBeforeInitialization(Object bean, String beanName)
throws BeansException { throws BeansException {

View File

@ -30,10 +30,10 @@ import org.springframework.security.authentication.event.AbstractAuthenticationF
* @since 3.1 * @since 3.1
*/ */
public class CollectingAppListener implements ApplicationListener { public class CollectingAppListener implements ApplicationListener {
Set<ApplicationEvent> events = new HashSet<ApplicationEvent>(); Set<ApplicationEvent> events = new HashSet<>();
Set<AbstractAuthenticationEvent> authenticationEvents = new HashSet<AbstractAuthenticationEvent>(); Set<AbstractAuthenticationEvent> authenticationEvents = new HashSet<>();
Set<AbstractAuthenticationFailureEvent> authenticationFailureEvents = new HashSet<AbstractAuthenticationFailureEvent>(); Set<AbstractAuthenticationFailureEvent> authenticationFailureEvents = new HashSet<>();
Set<AbstractAuthorizationEvent> authorizationEvents = new HashSet<AbstractAuthorizationEvent>(); Set<AbstractAuthorizationEvent> authorizationEvents = new HashSet<>();
public void onApplicationEvent(ApplicationEvent event) { public void onApplicationEvent(ApplicationEvent event) {
if (event instanceof AbstractAuthenticationEvent) { if (event instanceof AbstractAuthenticationEvent) {

View File

@ -24,7 +24,7 @@ import java.util.List;
*/ */
class ConcereteSecurityConfigurerAdapter extends class ConcereteSecurityConfigurerAdapter extends
SecurityConfigurerAdapter<Object, SecurityBuilder<Object>> { SecurityConfigurerAdapter<Object, SecurityBuilder<Object>> {
private List<Object> list = new ArrayList<Object>(); private List<Object> list = new ArrayList<>();
@Override @Override
public void configure(SecurityBuilder<Object> builder) throws Exception { public void configure(SecurityBuilder<Object> builder) throws Exception {

View File

@ -30,7 +30,7 @@ public class LdapAuthenticationProviderConfigurerTest {
@Before @Before
public void setUp() { public void setUp() {
configurer = new LdapAuthenticationProviderConfigurer<AuthenticationManagerBuilder>(); configurer = new LdapAuthenticationProviderConfigurer<>();
} }
// SEC-2557 // SEC-2557

View File

@ -107,14 +107,14 @@ public class AbstractSecurityWebSocketMessageBrokerConfigurerDocTests {
private Message<String> message(SimpMessageHeaderAccessor headers, String destination) { private Message<String> message(SimpMessageHeaderAccessor headers, String destination) {
headers.setSessionId("123"); headers.setSessionId("123");
headers.setSessionAttributes(new HashMap<String, Object>()); headers.setSessionAttributes(new HashMap<>());
if (destination != null) { if (destination != null) {
headers.setDestination(destination); headers.setDestination(destination);
} }
if (messageUser != null) { if (messageUser != null) {
headers.setUser(messageUser); headers.setUser(messageUser);
} }
return new GenericMessage<String>("hi", headers.getMessageHeaders()); return new GenericMessage<>("hi", headers.getMessageHeaders());
} }
@Controller @Controller

View File

@ -511,14 +511,14 @@ public class AbstractSecurityWebSocketMessageBrokerConfigurerTests {
private Message<String> message(SimpMessageHeaderAccessor headers, String destination) { private Message<String> message(SimpMessageHeaderAccessor headers, String destination) {
headers.setSessionId("123"); headers.setSessionId("123");
headers.setSessionAttributes(new HashMap<String, Object>()); headers.setSessionAttributes(new HashMap<>());
if (destination != null) { if (destination != null) {
headers.setDestination(destination); headers.setDestination(destination);
} }
if (messageUser != null) { if (messageUser != null) {
headers.setUser(messageUser); headers.setUser(messageUser);
} }
return new GenericMessage<String>("hi", headers.getMessageHeaders()); return new GenericMessage<>("hi", headers.getMessageHeaders());
} }
private MessageChannel clientInboundChannel() { private MessageChannel clientInboundChannel() {

View File

@ -114,7 +114,7 @@ public class AuthenticationManagerBeanDefinitionParserTests {
private static class AuthListener implements private static class AuthListener implements
ApplicationListener<AbstractAuthenticationEvent> { ApplicationListener<AbstractAuthenticationEvent> {
List<AbstractAuthenticationEvent> events = new ArrayList<AbstractAuthenticationEvent>(); List<AbstractAuthenticationEvent> events = new ArrayList<>();
public void onApplicationEvent(AbstractAuthenticationEvent event) { public void onApplicationEvent(AbstractAuthenticationEvent event) {
this.events.add(event); this.events.add(event);

View File

@ -287,7 +287,7 @@ public class GlobalMethodSecurityBeanDefinitionParserTests {
+ AUTH_PROVIDER_XML); + AUTH_PROVIDER_XML);
SecurityContextHolder.getContext().setAuthentication(bob); SecurityContextHolder.getContext().setAuthentication(bob);
target = (BusinessService) appContext.getBean("target"); target = (BusinessService) appContext.getBean("target");
List<String> arg = new ArrayList<String>(); List<String> arg = new ArrayList<>();
arg.add("joe"); arg.add("joe");
arg.add("bob"); arg.add("bob");
arg.add("sam"); arg.add("sam");

View File

@ -76,7 +76,7 @@ public class SecurityConfig implements ConfigAttribute {
public static List<ConfigAttribute> createList(String... attributeNames) { public static List<ConfigAttribute> createList(String... attributeNames) {
Assert.notNull(attributeNames, "You must supply an array of attribute names"); Assert.notNull(attributeNames, "You must supply an array of attribute names");
List<ConfigAttribute> attributes = new ArrayList<ConfigAttribute>( List<ConfigAttribute> attributes = new ArrayList<>(
attributeNames.length); attributeNames.length);
for (String attribute : attributeNames) { for (String attribute : attributeNames) {

View File

@ -75,7 +75,7 @@ public class Jsr250MethodSecurityMetadataSource extends
if (annotations == null || annotations.length == 0) { if (annotations == null || annotations.length == 0) {
return null; return null;
} }
List<ConfigAttribute> attributes = new ArrayList<ConfigAttribute>(); List<ConfigAttribute> attributes = new ArrayList<>();
for (Annotation a : annotations) { for (Annotation a : annotations) {
if (a instanceof DenyAll) { if (a instanceof DenyAll) {

View File

@ -84,7 +84,7 @@ class SecuredAnnotationMetadataExtractor implements AnnotationMetadataExtractor<
public Collection<ConfigAttribute> extractAttributes(Secured secured) { public Collection<ConfigAttribute> extractAttributes(Secured secured) {
String[] attributeTokens = secured.value(); String[] attributeTokens = secured.value();
List<ConfigAttribute> attributes = new ArrayList<ConfigAttribute>( List<ConfigAttribute> attributes = new ArrayList<>(
attributeTokens.length); attributeTokens.length);
for (String token : attributeTokens) { for (String token : attributeTokens) {

View File

@ -158,7 +158,7 @@ public abstract class SecurityExpressionRoot implements SecurityExpressionOperat
private Set<String> getAuthoritySet() { private Set<String> getAuthoritySet() {
if (roles == null) { if (roles == null) {
roles = new HashSet<String>(); roles = new HashSet<>();
Collection<? extends GrantedAuthority> userAuthorities = authentication Collection<? extends GrantedAuthority> userAuthorities = authentication
.getAuthorities(); .getAuthorities();

View File

@ -115,7 +115,7 @@ public class RoleHierarchyImpl implements RoleHierarchy {
return AuthorityUtils.NO_AUTHORITIES; return AuthorityUtils.NO_AUTHORITIES;
} }
Set<GrantedAuthority> reachableRoles = new HashSet<GrantedAuthority>(); Set<GrantedAuthority> reachableRoles = new HashSet<>();
for (GrantedAuthority authority : authorities) { for (GrantedAuthority authority : authorities) {
addReachableRoles(reachableRoles, authority); addReachableRoles(reachableRoles, authority);
@ -132,7 +132,7 @@ public class RoleHierarchyImpl implements RoleHierarchy {
+ " in zero or more steps."); + " in zero or more steps.");
} }
List<GrantedAuthority> reachableRoleList = new ArrayList<GrantedAuthority>( List<GrantedAuthority> reachableRoleList = new ArrayList<>(
reachableRoles.size()); reachableRoles.size());
reachableRoleList.addAll(reachableRoles); reachableRoleList.addAll(reachableRoles);
@ -190,7 +190,7 @@ public class RoleHierarchyImpl implements RoleHierarchy {
Set<GrantedAuthority> rolesReachableInOneStepSet; Set<GrantedAuthority> rolesReachableInOneStepSet;
if (!this.rolesReachableInOneStepMap.containsKey(higherRole)) { if (!this.rolesReachableInOneStepMap.containsKey(higherRole)) {
rolesReachableInOneStepSet = new HashSet<GrantedAuthority>(); rolesReachableInOneStepSet = new HashSet<>();
this.rolesReachableInOneStepMap.put(higherRole, this.rolesReachableInOneStepMap.put(higherRole,
rolesReachableInOneStepSet); rolesReachableInOneStepSet);
} }
@ -212,17 +212,17 @@ public class RoleHierarchyImpl implements RoleHierarchy {
* detected) * detected)
*/ */
private void buildRolesReachableInOneOrMoreStepsMap() { private void buildRolesReachableInOneOrMoreStepsMap() {
this.rolesReachableInOneOrMoreStepsMap = new HashMap<GrantedAuthority, Set<GrantedAuthority>>(); this.rolesReachableInOneOrMoreStepsMap = new HashMap<>();
// iterate over all higher roles from rolesReachableInOneStepMap // iterate over all higher roles from rolesReachableInOneStepMap
for (GrantedAuthority role : this.rolesReachableInOneStepMap.keySet()) { for (GrantedAuthority role : this.rolesReachableInOneStepMap.keySet()) {
Set<GrantedAuthority> rolesToVisitSet = new HashSet<GrantedAuthority>(); Set<GrantedAuthority> rolesToVisitSet = new HashSet<>();
if (this.rolesReachableInOneStepMap.containsKey(role)) { if (this.rolesReachableInOneStepMap.containsKey(role)) {
rolesToVisitSet.addAll(this.rolesReachableInOneStepMap.get(role)); rolesToVisitSet.addAll(this.rolesReachableInOneStepMap.get(role));
} }
Set<GrantedAuthority> visitedRolesSet = new HashSet<GrantedAuthority>(); Set<GrantedAuthority> visitedRolesSet = new HashSet<>();
while (!rolesToVisitSet.isEmpty()) { while (!rolesToVisitSet.isEmpty()) {
// take a role from the rolesToVisit set // take a role from the rolesToVisit set

View File

@ -161,7 +161,7 @@ public abstract class AbstractSecurityInterceptor implements InitializingBean,
return; return;
} }
Set<ConfigAttribute> unsupportedAttrs = new HashSet<ConfigAttribute>(); Set<ConfigAttribute> unsupportedAttrs = new HashSet<>();
for (ConfigAttribute attr : attributeDefs) { for (ConfigAttribute attr : attributeDefs) {
if (!this.runAsManager.supports(attr) if (!this.runAsManager.supports(attr)

View File

@ -91,7 +91,7 @@ public class AfterInvocationProviderManager implements AfterInvocationManager,
public void setProviders(List<?> newList) { public void setProviders(List<?> newList) {
checkIfValidList(newList); checkIfValidList(newList);
providers = new ArrayList<AfterInvocationProvider>(newList.size()); providers = new ArrayList<>(newList.size());
for (Object currentObject : newList) { for (Object currentObject : newList) {
Assert.isInstanceOf(AfterInvocationProvider.class, currentObject, Assert.isInstanceOf(AfterInvocationProvider.class, currentObject,

View File

@ -71,7 +71,7 @@ public class RunAsManagerImpl implements RunAsManager, InitializingBean {
public Authentication buildRunAs(Authentication authentication, Object object, public Authentication buildRunAs(Authentication authentication, Object object,
Collection<ConfigAttribute> attributes) { Collection<ConfigAttribute> attributes) {
List<GrantedAuthority> newAuthorities = new ArrayList<GrantedAuthority>(); List<GrantedAuthority> newAuthorities = new ArrayList<>();
for (ConfigAttribute attribute : attributes) { for (ConfigAttribute attribute : attributes) {
if (this.supports(attribute)) { if (this.supports(attribute)) {

View File

@ -95,7 +95,7 @@ public final class DelegatingMethodSecurityMetadataSource extends
@Override @Override
public Collection<ConfigAttribute> getAllConfigAttributes() { public Collection<ConfigAttribute> getAllConfigAttributes() {
Set<ConfigAttribute> set = new HashSet<ConfigAttribute>(); Set<ConfigAttribute> set = new HashSet<>();
for (MethodSecurityMetadataSource s : methodSecurityMetadataSources) { for (MethodSecurityMetadataSource s : methodSecurityMetadataSources) {
Collection<ConfigAttribute> attrs = s.getAllConfigAttributes(); Collection<ConfigAttribute> attrs = s.getAllConfigAttributes();
if (attrs != null) { if (attrs != null) {

View File

@ -50,10 +50,10 @@ public class MapBasedMethodSecurityMetadataSource extends
private ClassLoader beanClassLoader = ClassUtils.getDefaultClassLoader(); private ClassLoader beanClassLoader = ClassUtils.getDefaultClassLoader();
/** Map from RegisteredMethod to ConfigAttribute list */ /** Map from RegisteredMethod to ConfigAttribute list */
protected final Map<RegisteredMethod, List<ConfigAttribute>> methodMap = new HashMap<RegisteredMethod, List<ConfigAttribute>>(); protected final Map<RegisteredMethod, List<ConfigAttribute>> methodMap = new HashMap<>();
/** Map from RegisteredMethod to name pattern used for registration */ /** Map from RegisteredMethod to name pattern used for registration */
private final Map<RegisteredMethod, String> nameMap = new HashMap<RegisteredMethod, String>(); private final Map<RegisteredMethod, String> nameMap = new HashMap<>();
// ~ Methods // ~ Methods
// ======================================================================================================== // ========================================================================================================
@ -150,7 +150,7 @@ public class MapBasedMethodSecurityMetadataSource extends
} }
Method[] methods = javaType.getMethods(); Method[] methods = javaType.getMethods();
List<Method> matchingMethods = new ArrayList<Method>(); List<Method> matchingMethods = new ArrayList<>();
for (Method m : methods) { for (Method m : methods) {
if (m.getName().equals(mappedName) || isMatch(m.getName(), mappedName)) { if (m.getName().equals(mappedName) || isMatch(m.getName(), mappedName)) {
@ -236,7 +236,7 @@ public class MapBasedMethodSecurityMetadataSource extends
*/ */
@Override @Override
public Collection<ConfigAttribute> getAllConfigAttributes() { public Collection<ConfigAttribute> getAllConfigAttributes() {
Set<ConfigAttribute> allAttributes = new HashSet<ConfigAttribute>(); Set<ConfigAttribute> allAttributes = new HashSet<>();
for (List<ConfigAttribute> attributeList : methodMap.values()) { for (List<ConfigAttribute> attributeList : methodMap.values()) {
allAttributes.addAll(attributeList); allAttributes.addAll(attributeList);

View File

@ -84,7 +84,7 @@ public class PrePostAnnotationSecurityMetadataSource extends
String postAuthorizeAttribute = postAuthorize == null ? null : postAuthorize String postAuthorizeAttribute = postAuthorize == null ? null : postAuthorize
.value(); .value();
ArrayList<ConfigAttribute> attrs = new ArrayList<ConfigAttribute>(2); ArrayList<ConfigAttribute> attrs = new ArrayList<>(2);
PreInvocationAttribute pre = attributeFactory.createPreInvocationAttribute( PreInvocationAttribute pre = attributeFactory.createPreInvocationAttribute(
preFilterAttribute, filterObject, preAuthorizeAttribute); preFilterAttribute, filterObject, preAuthorizeAttribute);

View File

@ -66,7 +66,7 @@ public class UnanimousBased extends AbstractAccessDecisionManager {
int grant = 0; int grant = 0;
int abstain = 0; int abstain = 0;
List<ConfigAttribute> singleAttributeList = new ArrayList<ConfigAttribute>(1); List<ConfigAttribute> singleAttributeList = new ArrayList<>(1);
singleAttributeList.add(null); singleAttributeList.add(null);
for (ConfigAttribute attribute : attributes) { for (ConfigAttribute attribute : attributes) {

View File

@ -66,7 +66,7 @@ public abstract class AbstractAuthenticationToken implements Authentication,
"Authorities collection cannot contain any null elements"); "Authorities collection cannot contain any null elements");
} }
} }
ArrayList<GrantedAuthority> temp = new ArrayList<GrantedAuthority>( ArrayList<GrantedAuthority> temp = new ArrayList<>(
authorities.size()); authorities.size());
temp.addAll(authorities); temp.addAll(authorities);
this.authorities = Collections.unmodifiableList(temp); this.authorities = Collections.unmodifiableList(temp);

View File

@ -181,7 +181,7 @@ public abstract class AbstractJaasAuthenticationProvider
// Create a set to hold the authorities, and add any that have already been // Create a set to hold the authorities, and add any that have already been
// applied. // applied.
authorities = new HashSet<GrantedAuthority>(); authorities = new HashSet<>();
// Get the subject principals and pass them to each of the AuthorityGranters // Get the subject principals and pass them to each of the AuthorityGranters
Set<Principal> principals = loginContext.getSubject().getPrincipals(); Set<Principal> principals = loginContext.getSubject().getPrincipals();
@ -203,7 +203,7 @@ public abstract class AbstractJaasAuthenticationProvider
// Convert the authorities set back to an array and apply it to the token. // Convert the authorities set back to an array and apply it to the token.
JaasAuthenticationToken result = new JaasAuthenticationToken( JaasAuthenticationToken result = new JaasAuthenticationToken(
request.getPrincipal(), request.getCredentials(), request.getPrincipal(), request.getCredentials(),
new ArrayList<GrantedAuthority>(authorities), loginContext); new ArrayList<>(authorities), loginContext);
// Publish the success event // Publish the success event
publishSuccessEvent(result); publishSuccessEvent(result);

View File

@ -116,8 +116,8 @@ public final class DelegatingSecurityContextCallable<V> implements Callable<V> {
*/ */
public static <V> Callable<V> create(Callable<V> delegate, public static <V> Callable<V> create(Callable<V> delegate,
SecurityContext securityContext) { SecurityContext securityContext) {
return securityContext == null ? new DelegatingSecurityContextCallable<V>( return securityContext == null ? new DelegatingSecurityContextCallable<>(
delegate) : new DelegatingSecurityContextCallable<V>(delegate, delegate) : new DelegatingSecurityContextCallable<>(delegate,
securityContext); securityContext);
} }
} }

View File

@ -354,7 +354,7 @@ class ComparableVersion implements Comparable<ComparableVersion> {
ListItem list = items; ListItem list = items;
Stack<Item> stack = new Stack<Item>(); Stack<Item> stack = new Stack<>();
stack.push(list); stack.push(list);
boolean isDigit = false; boolean isDigit = false;

View File

@ -55,7 +55,7 @@ public abstract class AuthorityUtils {
*/ */
public static Set<String> authorityListToSet( public static Set<String> authorityListToSet(
Collection<? extends GrantedAuthority> userAuthorities) { Collection<? extends GrantedAuthority> userAuthorities) {
Set<String> set = new HashSet<String>(userAuthorities.size()); Set<String> set = new HashSet<>(userAuthorities.size());
for (GrantedAuthority authority : userAuthorities) { for (GrantedAuthority authority : userAuthorities) {
set.add(authority.getAuthority()); set.add(authority.getAuthority());
@ -65,7 +65,7 @@ public abstract class AuthorityUtils {
} }
public static List<GrantedAuthority> createAuthorityList(String... roles) { public static List<GrantedAuthority> createAuthorityList(String... roles) {
List<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>(roles.length); List<GrantedAuthority> authorities = new ArrayList<>(roles.length);
for (String role : roles) { for (String role : roles) {
authorities.add(new SimpleGrantedAuthority(role)); authorities.add(new SimpleGrantedAuthority(role));

View File

@ -47,7 +47,7 @@ public class MapBasedAttributes2GrantedAuthoritiesMapper implements
* Map the given array of attributes to Spring Security GrantedAuthorities. * Map the given array of attributes to Spring Security GrantedAuthorities.
*/ */
public List<GrantedAuthority> getGrantedAuthorities(Collection<String> attributes) { public List<GrantedAuthority> getGrantedAuthorities(Collection<String> attributes) {
ArrayList<GrantedAuthority> gaList = new ArrayList<GrantedAuthority>(); ArrayList<GrantedAuthority> gaList = new ArrayList<>();
for (String attribute : attributes) { for (String attribute : attributes) {
Collection<GrantedAuthority> c = attributes2grantedAuthoritiesMap Collection<GrantedAuthority> c = attributes2grantedAuthoritiesMap
.get(attribute); .get(attribute);
@ -107,7 +107,7 @@ public class MapBasedAttributes2GrantedAuthoritiesMapper implements
* @return Collection containing the GrantedAuthority Collection * @return Collection containing the GrantedAuthority Collection
*/ */
private Collection<GrantedAuthority> getGrantedAuthorityCollection(Object value) { private Collection<GrantedAuthority> getGrantedAuthorityCollection(Object value) {
Collection<GrantedAuthority> result = new ArrayList<GrantedAuthority>(); Collection<GrantedAuthority> result = new ArrayList<>();
addGrantedAuthorityCollection(result, value); addGrantedAuthorityCollection(result, value);
return result; return result;
} }

View File

@ -62,7 +62,7 @@ public class SimpleAttributes2GrantedAuthoritiesMapper implements
* GrantedAuthorities. * GrantedAuthorities.
*/ */
public List<GrantedAuthority> getGrantedAuthorities(Collection<String> attributes) { public List<GrantedAuthority> getGrantedAuthorities(Collection<String> attributes) {
List<GrantedAuthority> result = new ArrayList<GrantedAuthority>(attributes.size()); List<GrantedAuthority> result = new ArrayList<>(attributes.size());
for (String attribute : attributes) { for (String attribute : attributes) {
result.add(getGrantedAuthority(attribute)); result.add(getGrantedAuthority(attribute));
} }

View File

@ -54,7 +54,7 @@ public final class SimpleAuthorityMapper implements GrantedAuthoritiesMapper,
*/ */
public Set<GrantedAuthority> mapAuthorities( public Set<GrantedAuthority> mapAuthorities(
Collection<? extends GrantedAuthority> authorities) { Collection<? extends GrantedAuthority> authorities) {
HashSet<GrantedAuthority> mapped = new HashSet<GrantedAuthority>( HashSet<GrantedAuthority> mapped = new HashSet<>(
authorities.size()); authorities.size());
for (GrantedAuthority authority : authorities) { for (GrantedAuthority authority : authorities) {
mapped.add(mapAuthority(authority.getAuthority())); mapped.add(mapAuthority(authority.getAuthority()));

View File

@ -41,7 +41,7 @@ public class SimpleMappableAttributesRetriever implements MappableAttributesRetr
} }
public void setMappableAttributes(Set<String> aMappableRoles) { public void setMappableAttributes(Set<String> aMappableRoles) {
this.mappableAttributes = new HashSet<String>(); this.mappableAttributes = new HashSet<>();
this.mappableAttributes.addAll(aMappableRoles); this.mappableAttributes.addAll(aMappableRoles);
this.mappableAttributes = Collections.unmodifiableSet(this.mappableAttributes); this.mappableAttributes = Collections.unmodifiableSet(this.mappableAttributes);
} }

View File

@ -31,7 +31,7 @@ final class InheritableThreadLocalSecurityContextHolderStrategy implements
// ~ Static fields/initializers // ~ Static fields/initializers
// ===================================================================================== // =====================================================================================
private static final ThreadLocal<SecurityContext> contextHolder = new InheritableThreadLocal<SecurityContext>(); private static final ThreadLocal<SecurityContext> contextHolder = new InheritableThreadLocal<>();
// ~ Methods // ~ Methods
// ======================================================================================================== // ========================================================================================================

View File

@ -32,7 +32,7 @@ final class ThreadLocalSecurityContextHolderStrategy implements
// ~ Static fields/initializers // ~ Static fields/initializers
// ===================================================================================== // =====================================================================================
private static final ThreadLocal<SecurityContext> contextHolder = new ThreadLocal<SecurityContext>(); private static final ThreadLocal<SecurityContext> contextHolder = new ThreadLocal<>();
// ~ Methods // ~ Methods
// ======================================================================================================== // ========================================================================================================

View File

@ -91,7 +91,7 @@ public class AnnotationParameterNameDiscoverer implements ParameterNameDiscovere
private final Set<String> annotationClassesToUse; private final Set<String> annotationClassesToUse;
public AnnotationParameterNameDiscoverer(String... annotationClassToUse) { public AnnotationParameterNameDiscoverer(String... annotationClassToUse) {
this(new HashSet<String>(Arrays.asList(annotationClassToUse))); this(new HashSet<>(Arrays.asList(annotationClassToUse)));
} }
public AnnotationParameterNameDiscoverer(Set<String> annotationClassesToUse) { public AnnotationParameterNameDiscoverer(Set<String> annotationClassesToUse) {

View File

@ -81,7 +81,7 @@ public class DefaultSecurityParameterNameDiscoverer extends
addDiscoverer(discover); addDiscoverer(discover);
} }
Set<String> annotationClassesToUse = new HashSet<String>(2); Set<String> annotationClassesToUse = new HashSet<>(2);
annotationClassesToUse.add("org.springframework.security.access.method.P"); annotationClassesToUse.add("org.springframework.security.access.method.P");
annotationClassesToUse.add(P.class.getName()); annotationClassesToUse.add(P.class.getName());
if (DATA_PARAM_PRESENT) { if (DATA_PARAM_PRESENT) {

View File

@ -56,8 +56,8 @@ public class SessionRegistryImpl implements SessionRegistry,
// ======================================================================================================== // ========================================================================================================
public SessionRegistryImpl() { public SessionRegistryImpl() {
this.principals = new ConcurrentHashMap<Object, Set<String>>(); this.principals = new ConcurrentHashMap<>();
this.sessionIds = new ConcurrentHashMap<String, SessionInformation>(); this.sessionIds = new ConcurrentHashMap<>();
} }
public SessionRegistryImpl(ConcurrentMap<Object, Set<String>> principals, Map<String, SessionInformation> sessionIds) { public SessionRegistryImpl(ConcurrentMap<Object, Set<String>> principals, Map<String, SessionInformation> sessionIds) {
@ -66,7 +66,7 @@ public class SessionRegistryImpl implements SessionRegistry,
} }
public List<Object> getAllPrincipals() { public List<Object> getAllPrincipals() {
return new ArrayList<Object>(principals.keySet()); return new ArrayList<>(principals.keySet());
} }
public List<SessionInformation> getAllSessions(Object principal, public List<SessionInformation> getAllSessions(Object principal,
@ -77,7 +77,7 @@ public class SessionRegistryImpl implements SessionRegistry,
return Collections.emptyList(); return Collections.emptyList();
} }
List<SessionInformation> list = new ArrayList<SessionInformation>( List<SessionInformation> list = new ArrayList<>(
sessionsUsedByPrincipal.size()); sessionsUsedByPrincipal.size());
for (String sessionId : sessionsUsedByPrincipal) { for (String sessionId : sessionsUsedByPrincipal) {
@ -135,7 +135,7 @@ public class SessionRegistryImpl implements SessionRegistry,
Set<String> sessionsUsedByPrincipal = principals.get(principal); Set<String> sessionsUsedByPrincipal = principals.get(principal);
if (sessionsUsedByPrincipal == null) { if (sessionsUsedByPrincipal == null) {
sessionsUsedByPrincipal = new CopyOnWriteArraySet<String>(); sessionsUsedByPrincipal = new CopyOnWriteArraySet<>();
Set<String> prevSessionsUsedByPrincipal = principals.putIfAbsent(principal, Set<String> prevSessionsUsedByPrincipal = principals.putIfAbsent(principal,
sessionsUsedByPrincipal); sessionsUsedByPrincipal);
if (prevSessionsUsedByPrincipal != null) { if (prevSessionsUsedByPrincipal != null) {

View File

@ -159,7 +159,7 @@ public class User implements UserDetails, CredentialsContainer {
Assert.notNull(authorities, "Cannot pass a null GrantedAuthority collection"); Assert.notNull(authorities, "Cannot pass a null GrantedAuthority collection");
// Ensure array iteration order is predictable (as per // Ensure array iteration order is predictable (as per
// UserDetails.getAuthorities() contract and SEC-717) // UserDetails.getAuthorities() contract and SEC-717)
SortedSet<GrantedAuthority> sortedAuthorities = new TreeSet<GrantedAuthority>( SortedSet<GrantedAuthority> sortedAuthorities = new TreeSet<>(
new AuthorityComparator()); new AuthorityComparator());
for (GrantedAuthority grantedAuthority : authorities) { for (GrantedAuthority grantedAuthority : authorities) {
@ -367,7 +367,7 @@ public class User implements UserDetails, CredentialsContainer {
* additional attributes for this user) * additional attributes for this user)
*/ */
public UserBuilder roles(String... roles) { public UserBuilder roles(String... roles) {
List<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>( List<GrantedAuthority> authorities = new ArrayList<>(
roles.length); roles.length);
for (String role : roles) { for (String role : roles) {
Assert.isTrue(!role.startsWith("ROLE_"), role Assert.isTrue(!role.startsWith("ROLE_"), role
@ -400,7 +400,7 @@ public class User implements UserDetails, CredentialsContainer {
* @see #roles(String...) * @see #roles(String...)
*/ */
public UserBuilder authorities(Collection<? extends GrantedAuthority> authorities) { public UserBuilder authorities(Collection<? extends GrantedAuthority> authorities) {
this.authorities = new ArrayList<GrantedAuthority>(authorities); this.authorities = new ArrayList<>(authorities);
return this; return this;
} }

View File

@ -193,7 +193,7 @@ public class JdbcDaoImpl extends JdbcDaoSupport
UserDetails user = users.get(0); // contains no GrantedAuthority[] UserDetails user = users.get(0); // contains no GrantedAuthority[]
Set<GrantedAuthority> dbAuthsSet = new HashSet<GrantedAuthority>(); Set<GrantedAuthority> dbAuthsSet = new HashSet<>();
if (this.enableAuthorities) { if (this.enableAuthorities) {
dbAuthsSet.addAll(loadUserAuthorities(user.getUsername())); dbAuthsSet.addAll(loadUserAuthorities(user.getUsername()));
@ -203,7 +203,7 @@ public class JdbcDaoImpl extends JdbcDaoSupport
dbAuthsSet.addAll(loadGroupAuthorities(user.getUsername())); dbAuthsSet.addAll(loadGroupAuthorities(user.getUsername()));
} }
List<GrantedAuthority> dbAuths = new ArrayList<GrantedAuthority>(dbAuthsSet); List<GrantedAuthority> dbAuths = new ArrayList<>(dbAuthsSet);
addCustomAuthorities(user.getUsername(), dbAuths); addCustomAuthorities(user.getUsername(), dbAuths);

View File

@ -33,7 +33,7 @@ public class UserAttribute {
// ~ Instance fields // ~ Instance fields
// ================================================================================================ // ================================================================================================
private List<GrantedAuthority> authorities = new Vector<GrantedAuthority>(); private List<GrantedAuthority> authorities = new Vector<>();
private String password; private String password;
private boolean enabled = true; private boolean enabled = true;
@ -66,7 +66,7 @@ public class UserAttribute {
* @since 1.1 * @since 1.1
*/ */
public void setAuthoritiesAsString(List<String> authoritiesAsStrings) { public void setAuthoritiesAsString(List<String> authoritiesAsStrings) {
setAuthorities(new ArrayList<GrantedAuthority>(authoritiesAsStrings.size())); setAuthorities(new ArrayList<>(authoritiesAsStrings.size()));
for (String authority : authoritiesAsStrings) { for (String authority : authoritiesAsStrings) {
addAuthority(new SimpleGrantedAuthority(authority)); addAuthority(new SimpleGrantedAuthority(authority));
} }

View File

@ -37,7 +37,7 @@ public class UserAttributeEditor extends PropertyEditorSupport {
String[] tokens = StringUtils.commaDelimitedListToStringArray(s); String[] tokens = StringUtils.commaDelimitedListToStringArray(s);
UserAttribute userAttrib = new UserAttribute(); UserAttribute userAttrib = new UserAttribute();
List<String> authoritiesAsStrings = new ArrayList<String>(); List<String> authoritiesAsStrings = new ArrayList<>();
for (int i = 0; i < tokens.length; i++) { for (int i = 0; i < tokens.length; i++) {
String currentToken = tokens[i].trim(); String currentToken = tokens[i].trim();

View File

@ -95,7 +95,7 @@ public final class SecurityJackson2Modules {
* @return List of available security modules in classpath. * @return List of available security modules in classpath.
*/ */
public static List<Module> getModules(ClassLoader loader) { public static List<Module> getModules(ClassLoader loader) {
List<Module> modules = new ArrayList<Module>(); List<Module> modules = new ArrayList<>();
for (String className : securityJackson2ModuleClasses) { for (String className : securityJackson2ModuleClasses) {
Module module = loadAndGetInstance(className, loader); Module module = loadAndGetInstance(className, loader);
if (module != null) { if (module != null) {

View File

@ -43,7 +43,7 @@ class UnmodifiableSetDeserializer extends JsonDeserializer<Set> {
public Set deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { public Set deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
ObjectMapper mapper = (ObjectMapper) jp.getCodec(); ObjectMapper mapper = (ObjectMapper) jp.getCodec();
JsonNode node = mapper.readTree(jp); JsonNode node = mapper.readTree(jp);
Set<Object> resultSet = new HashSet<Object>(); Set<Object> resultSet = new HashSet<>();
if (node != null) { if (node != null) {
if (node instanceof ArrayNode) { if (node instanceof ArrayNode) {
ArrayNode arrayNode = (ArrayNode) node; ArrayNode arrayNode = (ArrayNode) node;

Some files were not shown because too many files have changed in this diff Show More