Use parenthesis with single-arg lambdas
Use regular expression search/replace to ensure all single-arg lambdas have parenthesis. This aligns with the style used in Spring Boot and ensure that single-arg and multi-arg lambdas are consistent. Issue gh-8945
This commit is contained in:
+1
-1
@@ -91,7 +91,7 @@ public class SpringSecurityLdapTemplateITests {
|
||||
@Test
|
||||
public void namingExceptionIsTranslatedCorrectly() {
|
||||
try {
|
||||
this.template.executeReadOnly((ContextExecutor) dirContext -> {
|
||||
this.template.executeReadOnly((ContextExecutor) (dirContext) -> {
|
||||
throw new NamingException();
|
||||
});
|
||||
fail("Expected UncategorizedLdapException on NamingException");
|
||||
|
||||
+1
-1
@@ -184,7 +184,7 @@ public class DefaultLdapAuthoritiesPopulatorTests {
|
||||
|
||||
@Test
|
||||
public void customAuthoritiesMappingFunction() {
|
||||
this.populator.setAuthorityMapper(record -> {
|
||||
this.populator.setAuthorityMapper((record) -> {
|
||||
String dn = record.get(SpringSecurityLdapTemplate.DN_KEY).get(0);
|
||||
String role = record.get(this.populator.getGroupRoleAttribute()).get(0);
|
||||
return new LdapAuthority(role, dn);
|
||||
|
||||
+4
-4
@@ -124,7 +124,7 @@ public class SpringSecurityLdapTemplate extends LdapTemplate {
|
||||
*/
|
||||
public DirContextOperations retrieveEntry(final String dn, final String[] attributesToRetrieve) {
|
||||
|
||||
return (DirContextOperations) executeReadOnly((ContextExecutor) ctx -> {
|
||||
return (DirContextOperations) executeReadOnly((ContextExecutor) (ctx) -> {
|
||||
Attributes attrs = ctx.getAttributes(dn, attributesToRetrieve);
|
||||
|
||||
// Object object = ctx.lookup(LdapUtils.getRelativeName(dn, ctx));
|
||||
@@ -188,7 +188,7 @@ public class SpringSecurityLdapTemplate extends LdapTemplate {
|
||||
|
||||
final HashSet<Map<String, List<String>>> set = new HashSet<>();
|
||||
|
||||
ContextMapper roleMapper = ctx -> {
|
||||
ContextMapper roleMapper = (ctx) -> {
|
||||
DirContextAdapter adapter = (DirContextAdapter) ctx;
|
||||
Map<String, List<String>> record = new HashMap<>();
|
||||
if (attributeNames == null || attributeNames.length == 0) {
|
||||
@@ -285,8 +285,8 @@ public class SpringSecurityLdapTemplate extends LdapTemplate {
|
||||
*/
|
||||
public DirContextOperations searchForSingleEntry(final String base, final String filter, final Object[] params) {
|
||||
|
||||
return (DirContextOperations) executeReadOnly(
|
||||
(ContextExecutor) ctx -> searchForSingleEntryInternal(ctx, this.searchControls, base, filter, params));
|
||||
return (DirContextOperations) executeReadOnly((ContextExecutor) (ctx) -> searchForSingleEntryInternal(ctx,
|
||||
this.searchControls, base, filter, params));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -169,7 +169,7 @@ public class DefaultLdapAuthoritiesPopulator implements LdapAuthoritiesPopulator
|
||||
logger.info("groupSearchBase is empty. Searches will be performed from the context source base");
|
||||
}
|
||||
|
||||
this.authorityMapper = record -> {
|
||||
this.authorityMapper = (record) -> {
|
||||
String role = record.get(this.groupRoleAttribute).get(0);
|
||||
|
||||
if (this.convertToUpperCase) {
|
||||
|
||||
+6
-6
@@ -114,7 +114,7 @@ public class LdapUserDetailsManager implements UserDetailsManager {
|
||||
private final LdapTemplate template;
|
||||
|
||||
/** Default context mapper used to create a set of roles from a list of attributes */
|
||||
private AttributesMapper roleMapper = attributes -> {
|
||||
private AttributesMapper roleMapper = (attributes) -> {
|
||||
Attribute roleAttr = attributes.get(this.groupRoleAttributeName);
|
||||
|
||||
NamingEnumeration<?> ne = roleAttr.getAll();
|
||||
@@ -146,7 +146,7 @@ public class LdapUserDetailsManager implements UserDetailsManager {
|
||||
}
|
||||
|
||||
private DirContextAdapter loadUserAsContext(final DistinguishedName dn, final String username) {
|
||||
return (DirContextAdapter) this.template.executeReadOnly((ContextExecutor) ctx -> {
|
||||
return (DirContextAdapter) this.template.executeReadOnly((ContextExecutor) (ctx) -> {
|
||||
try {
|
||||
Attributes attrs = ctx.getAttributes(dn, this.attributesToRetrieve);
|
||||
return new DirContextAdapter(attrs, LdapUtils.getFullDn(dn, ctx));
|
||||
@@ -210,7 +210,7 @@ public class LdapUserDetailsManager implements UserDetailsManager {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
List<GrantedAuthority> getUserAuthorities(final DistinguishedName dn, final String username) {
|
||||
SearchExecutor se = ctx -> {
|
||||
SearchExecutor se = (ctx) -> {
|
||||
DistinguishedName fullDn = LdapUtils.getFullDn(dn, ctx);
|
||||
SearchControls ctrls = new SearchControls();
|
||||
ctrls.setReturningAttributes(new String[] { this.groupRoleAttributeName });
|
||||
@@ -327,7 +327,7 @@ public class LdapUserDetailsManager implements UserDetailsManager {
|
||||
|
||||
private void modifyAuthorities(final DistinguishedName userDn,
|
||||
final Collection<? extends GrantedAuthority> authorities, final int modType) {
|
||||
this.template.executeReadWrite((ContextExecutor) ctx -> {
|
||||
this.template.executeReadWrite((ContextExecutor) (ctx) -> {
|
||||
for (GrantedAuthority authority : authorities) {
|
||||
String group = convertAuthorityToGroup(authority);
|
||||
DistinguishedName fullDn = LdapUtils.getFullDn(userDn, ctx);
|
||||
@@ -428,7 +428,7 @@ public class LdapUserDetailsManager implements UserDetailsManager {
|
||||
return;
|
||||
}
|
||||
|
||||
this.template.executeReadWrite(dirCtx -> {
|
||||
this.template.executeReadWrite((dirCtx) -> {
|
||||
LdapContext ctx = (LdapContext) dirCtx;
|
||||
ctx.removeFromEnvironment("com.sun.jndi.ldap.connect.pool");
|
||||
ctx.addToEnvironment(Context.SECURITY_PRINCIPAL, LdapUtils.getFullDn(userDn, ctx).toString());
|
||||
@@ -451,7 +451,7 @@ public class LdapUserDetailsManager implements UserDetailsManager {
|
||||
private void changePasswordUsingExtensionOperation(DistinguishedName userDn, String oldPassword,
|
||||
String newPassword) {
|
||||
|
||||
this.template.executeReadWrite(dirCtx -> {
|
||||
this.template.executeReadWrite((dirCtx) -> {
|
||||
LdapContext ctx = (LdapContext) dirCtx;
|
||||
|
||||
String userIdentity = LdapUtils.getFullDn(userDn, ctx).encode();
|
||||
|
||||
Reference in New Issue
Block a user