Use diamond type
This commit is contained in:
+4
-4
@@ -104,7 +104,7 @@ public class DefaultSpringSecurityContextSourceTests extends AbstractLdapIntegra
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void instantiationFailsWithEmptyServerList() throws Exception {
|
||||
List<String> serverUrls = new ArrayList<String>();
|
||||
List<String> serverUrls = new ArrayList<>();
|
||||
DefaultSpringSecurityContextSource ctxSrc = new DefaultSpringSecurityContextSource(
|
||||
serverUrls, "dc=springframework,dc=org");
|
||||
ctxSrc.afterPropertiesSet();
|
||||
@@ -112,7 +112,7 @@ public class DefaultSpringSecurityContextSourceTests extends AbstractLdapIntegra
|
||||
|
||||
@Test
|
||||
public void instantiationSuceedsWithProperServerList() throws Exception {
|
||||
List<String> serverUrls = new ArrayList<String>();
|
||||
List<String> serverUrls = new ArrayList<>();
|
||||
serverUrls.add("ldap://foo:789");
|
||||
serverUrls.add("ldap://bar:389");
|
||||
serverUrls.add("ldaps://blah:636");
|
||||
@@ -127,7 +127,7 @@ public class DefaultSpringSecurityContextSourceTests extends AbstractLdapIntegra
|
||||
@Test
|
||||
public void instantiationSuceedsWithEmtpyBaseDn() throws Exception {
|
||||
String baseDn = "";
|
||||
List<String> serverUrls = new ArrayList<String>();
|
||||
List<String> serverUrls = new ArrayList<>();
|
||||
serverUrls.add("ldap://foo:789");
|
||||
serverUrls.add("ldap://bar:389");
|
||||
serverUrls.add("ldaps://blah:636");
|
||||
@@ -140,7 +140,7 @@ public class DefaultSpringSecurityContextSourceTests extends AbstractLdapIntegra
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void instantiationFailsWithIncorrectServerUrl() throws Exception {
|
||||
List<String> serverUrls = new ArrayList<String>();
|
||||
List<String> serverUrls = new ArrayList<>();
|
||||
// a simple trailing slash should be ok
|
||||
serverUrls.add("ldaps://blah:636/");
|
||||
// this url should be rejected because the root DN goes into a separate parameter
|
||||
|
||||
+1
-1
@@ -185,7 +185,7 @@ public class SpringSecurityLdapTemplateITests extends AbstractLdapIntegrationTes
|
||||
|
||||
@Test
|
||||
public void nonSpringLdapSearchCodeTestMethod() throws Exception {
|
||||
java.util.Hashtable<String, String> env = new java.util.Hashtable<String, String>();
|
||||
java.util.Hashtable<String, String> env = new java.util.Hashtable<>();
|
||||
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
|
||||
env.put(Context.PROVIDER_URL, "ldap://localhost:"
|
||||
+ ApacheDSServerIntegrationTests.getServerPort());
|
||||
|
||||
+1
-1
@@ -114,7 +114,7 @@ public class BindAuthenticatorTests extends AbstractLdapIntegrationTests {
|
||||
|
||||
/*
|
||||
* @Test public void messingWithEscapedChars() throws Exception {
|
||||
* Hashtable<String,String> env = new Hashtable<String,String>();
|
||||
* Hashtable<String,String> env = new Hashtable<>();
|
||||
* env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
|
||||
* env.put(Context.PROVIDER_URL, "ldap://127.0.0.1:22389/dc=springsource,dc=com");
|
||||
* env.put(Context.SECURITY_AUTHENTICATION, "simple");
|
||||
|
||||
+2
-2
@@ -196,8 +196,8 @@ public class ApacheDSContainerTests {
|
||||
}
|
||||
|
||||
private List<Integer> getDefaultPorts(int count) throws IOException {
|
||||
List<ServerSocket> connections = new ArrayList<ServerSocket>();
|
||||
List<Integer> availablePorts = new ArrayList<Integer>(count);
|
||||
List<ServerSocket> connections = new ArrayList<>();
|
||||
List<Integer> availablePorts = new ArrayList<>(count);
|
||||
try {
|
||||
for (int i = 0; i < count; i++) {
|
||||
ServerSocket socket = new ServerSocket(0);
|
||||
|
||||
+2
-2
@@ -46,8 +46,8 @@ public class UnboundIdContainerTests {
|
||||
}
|
||||
|
||||
private List<Integer> getDefaultPorts(int count) throws IOException {
|
||||
List<ServerSocket> connections = new ArrayList<ServerSocket>();
|
||||
List<Integer> availablePorts = new ArrayList<Integer>(count);
|
||||
List<ServerSocket> connections = new ArrayList<>();
|
||||
List<Integer> availablePorts = new ArrayList<>(count);
|
||||
try {
|
||||
for (int i = 0; i < count; i++) {
|
||||
ServerSocket socket = new ServerSocket(0);
|
||||
|
||||
+1
-1
@@ -147,7 +147,7 @@ public class DefaultLdapAuthoritiesPopulatorTests extends AbstractLdapIntegratio
|
||||
@Override
|
||||
protected Set<GrantedAuthority> getAdditionalRoles(DirContextOperations user,
|
||||
String username) {
|
||||
return new HashSet<GrantedAuthority>(
|
||||
return new HashSet<>(
|
||||
AuthorityUtils.createAuthorityList("ROLE_EXTRA"));
|
||||
}
|
||||
};
|
||||
|
||||
+1
-1
@@ -64,7 +64,7 @@ public class DefaultSpringSecurityContextSource extends LdapContextSource {
|
||||
|
||||
StringTokenizer st = new StringTokenizer(providerUrl);
|
||||
|
||||
ArrayList<String> urls = new ArrayList<String>();
|
||||
ArrayList<String> urls = new ArrayList<>();
|
||||
|
||||
// Work out rootDn from the first URL and check that the other URLs (if any) match
|
||||
while (st.hasMoreTokens()) {
|
||||
|
||||
+3
-3
@@ -165,7 +165,7 @@ public class SpringSecurityLdapTemplate extends LdapTemplate {
|
||||
String[] attributeNames = new String[] { attributeName };
|
||||
Set<Map<String, List<String>>> multipleAttributeValues = searchForMultipleAttributeValues(
|
||||
base, filter, params, attributeNames);
|
||||
Set<String> result = new HashSet<String>();
|
||||
Set<String> result = new HashSet<>();
|
||||
for (Map<String, List<String>> map : multipleAttributeValues) {
|
||||
List<String> values = map.get(attributeName);
|
||||
if (values != null) {
|
||||
@@ -274,7 +274,7 @@ public class SpringSecurityLdapTemplate extends LdapTemplate {
|
||||
}
|
||||
return;
|
||||
}
|
||||
List<String> svalues = new ArrayList<String>();
|
||||
List<String> svalues = new ArrayList<>();
|
||||
for (Object o : values) {
|
||||
if (o != null) {
|
||||
if (String.class.isAssignableFrom(o.getClass())) {
|
||||
@@ -338,7 +338,7 @@ public class SpringSecurityLdapTemplate extends LdapTemplate {
|
||||
+ searchBaseDn + "', filter = '" + filter + "'");
|
||||
}
|
||||
|
||||
Set<DirContextOperations> results = new HashSet<DirContextOperations>();
|
||||
Set<DirContextOperations> results = new HashSet<>();
|
||||
try {
|
||||
while (resultsEnum.hasMore()) {
|
||||
SearchResult searchResult = resultsEnum.next();
|
||||
|
||||
+1
-1
@@ -102,7 +102,7 @@ public abstract class AbstractLdapAuthenticator implements LdapAuthenticator,
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
List<String> userDns = new ArrayList<String>(userDnFormat.length);
|
||||
List<String> userDns = new ArrayList<>(userDnFormat.length);
|
||||
String[] args = new String[] { LdapEncoder.nameEncode(username) };
|
||||
|
||||
synchronized (userDnFormat) {
|
||||
|
||||
+2
-2
@@ -175,7 +175,7 @@ public final class ActiveDirectoryLdapAuthenticationProvider extends
|
||||
logger.debug("'memberOf' attribute values: " + Arrays.asList(groups));
|
||||
}
|
||||
|
||||
ArrayList<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>(
|
||||
ArrayList<GrantedAuthority> authorities = new ArrayList<>(
|
||||
groups.length);
|
||||
|
||||
for (String group : groups) {
|
||||
@@ -190,7 +190,7 @@ public final class ActiveDirectoryLdapAuthenticationProvider extends
|
||||
// TODO. add DNS lookup based on domain
|
||||
final String bindUrl = url;
|
||||
|
||||
Hashtable<String, String> env = new Hashtable<String, String>();
|
||||
Hashtable<String, String> env = new Hashtable<>();
|
||||
env.put(Context.SECURITY_AUTHENTICATION, "simple");
|
||||
String bindPrincipal = createBindPrincipal(username);
|
||||
env.put(Context.SECURITY_PRINCIPAL, bindPrincipal);
|
||||
|
||||
@@ -92,7 +92,7 @@ public class ApacheDSContainer implements InitializingBean, DisposableBean, Life
|
||||
public ApacheDSContainer(String root, String ldifs) throws Exception {
|
||||
this.ldifResources = ldifs;
|
||||
service = new DefaultDirectoryService();
|
||||
List<Interceptor> list = new ArrayList<Interceptor>();
|
||||
List<Interceptor> list = new ArrayList<>();
|
||||
|
||||
list.add(new NormalizationInterceptor());
|
||||
list.add(new AuthenticationInterceptor());
|
||||
|
||||
+3
-3
@@ -219,7 +219,7 @@ public class DefaultLdapAuthoritiesPopulator implements LdapAuthoritiesPopulator
|
||||
roles.add(this.defaultRole);
|
||||
}
|
||||
|
||||
List<GrantedAuthority> result = new ArrayList<GrantedAuthority>(roles.size());
|
||||
List<GrantedAuthority> result = new ArrayList<>(roles.size());
|
||||
result.addAll(roles);
|
||||
|
||||
return result;
|
||||
@@ -227,10 +227,10 @@ public class DefaultLdapAuthoritiesPopulator implements LdapAuthoritiesPopulator
|
||||
|
||||
public Set<GrantedAuthority> getGroupMembershipRoles(String userDn, String username) {
|
||||
if (getGroupSearchBase() == null) {
|
||||
return new HashSet<GrantedAuthority>();
|
||||
return new HashSet<>();
|
||||
}
|
||||
|
||||
Set<GrantedAuthority> authorities = new HashSet<GrantedAuthority>();
|
||||
Set<GrantedAuthority> authorities = new HashSet<>();
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Searching for roles for user '" + username + "', DN = " + "'"
|
||||
|
||||
+2
-2
@@ -186,7 +186,7 @@ public class LdapUserDetailsImpl implements LdapUserDetails, PasswordPolicyData
|
||||
*/
|
||||
public static class Essence {
|
||||
protected LdapUserDetailsImpl instance = createTarget();
|
||||
private List<GrantedAuthority> mutableAuthorities = new ArrayList<GrantedAuthority>();
|
||||
private List<GrantedAuthority> mutableAuthorities = new ArrayList<>();
|
||||
|
||||
public Essence() {
|
||||
}
|
||||
@@ -257,7 +257,7 @@ public class LdapUserDetailsImpl implements LdapUserDetails, PasswordPolicyData
|
||||
}
|
||||
|
||||
public void setAuthorities(Collection<? extends GrantedAuthority> authorities) {
|
||||
mutableAuthorities = new ArrayList<GrantedAuthority>();
|
||||
mutableAuthorities = new ArrayList<>();
|
||||
mutableAuthorities.addAll(authorities);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -274,7 +274,7 @@ public class LdapUserDetailsManager implements UserDetailsManager {
|
||||
copyToContext(user, ctx);
|
||||
|
||||
// Remove the objectclass attribute from the list of mods (if present).
|
||||
List<ModificationItem> mods = new LinkedList<ModificationItem>(Arrays.asList(ctx
|
||||
List<ModificationItem> mods = new LinkedList<>(Arrays.asList(ctx
|
||||
.getModificationItems()));
|
||||
ListIterator<ModificationItem> modIt = mods.listIterator();
|
||||
|
||||
|
||||
+4
-4
@@ -151,10 +151,10 @@ public class NestedLdapAuthoritiesPopulator extends DefaultLdapAuthoritiesPopula
|
||||
@Override
|
||||
public Set<GrantedAuthority> getGroupMembershipRoles(String userDn, String username) {
|
||||
if (getGroupSearchBase() == null) {
|
||||
return new HashSet<GrantedAuthority>();
|
||||
return new HashSet<>();
|
||||
}
|
||||
|
||||
Set<GrantedAuthority> authorities = new HashSet<GrantedAuthority>();
|
||||
Set<GrantedAuthority> authorities = new HashSet<>();
|
||||
|
||||
performNestedSearch(userDn, username, authorities, getMaxSearchDepth());
|
||||
|
||||
@@ -190,7 +190,7 @@ public class NestedLdapAuthoritiesPopulator extends DefaultLdapAuthoritiesPopula
|
||||
}
|
||||
|
||||
if (getAttributeNames() == null) {
|
||||
setAttributeNames(new HashSet<String>());
|
||||
setAttributeNames(new HashSet<>());
|
||||
}
|
||||
if (StringUtils.hasText(getGroupRoleAttribute())
|
||||
&& !getAttributeNames().contains(getGroupRoleAttribute())) {
|
||||
@@ -211,7 +211,7 @@ public class NestedLdapAuthoritiesPopulator extends DefaultLdapAuthoritiesPopula
|
||||
boolean circular = false;
|
||||
String dn = record.get(SpringSecurityLdapTemplate.DN_KEY).get(0);
|
||||
List<String> roleValues = record.get(getGroupRoleAttribute());
|
||||
Set<String> roles = new HashSet<String>();
|
||||
Set<String> roles = new HashSet<>();
|
||||
if (roleValues != null) {
|
||||
roles.addAll(roleValues);
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public class Person extends LdapUserDetailsImpl {
|
||||
private String sn;
|
||||
private String description;
|
||||
private String telephoneNumber;
|
||||
private List<String> cn = new ArrayList<String>();
|
||||
private List<String> cn = new ArrayList<>();
|
||||
|
||||
protected Person() {
|
||||
}
|
||||
@@ -106,7 +106,7 @@ public class Person extends LdapUserDetailsImpl {
|
||||
setSn(copyMe.sn);
|
||||
setDescription(copyMe.getDescription());
|
||||
setTelephoneNumber(copyMe.getTelephoneNumber());
|
||||
((Person) instance).cn = new ArrayList<String>(copyMe.cn);
|
||||
((Person) instance).cn = new ArrayList<>(copyMe.cn);
|
||||
}
|
||||
|
||||
protected LdapUserDetailsImpl createTarget() {
|
||||
|
||||
+1
-1
@@ -230,7 +230,7 @@ public class ActiveDirectoryLdapAuthenticationProviderTests {
|
||||
when(
|
||||
ctx.search(any(Name.class), any(String.class), any(Object[].class),
|
||||
any(SearchControls.class))).thenReturn(
|
||||
new EmptyEnumeration<SearchResult>());
|
||||
new EmptyEnumeration<>());
|
||||
|
||||
provider.contextFactory = createContextFactoryReturning(ctx);
|
||||
|
||||
|
||||
+1
-1
@@ -43,7 +43,7 @@ public class InetOrgPersonTests {
|
||||
InetOrgPerson p = (InetOrgPerson) essence.createUserDetails();
|
||||
essence = new InetOrgPerson.Essence(createUserContext());
|
||||
InetOrgPerson p2 = (InetOrgPerson) essence.createUserDetails();
|
||||
Set<InetOrgPerson> set = new HashSet<InetOrgPerson>();
|
||||
Set<InetOrgPerson> set = new HashSet<>();
|
||||
set.add(p);
|
||||
assertThat(set.contains(p2)).isTrue();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user