Revert unnecessary merges on 6.0.x
This commit removes unnecessary main-branch merges starting from8750608b5band adds the following needed commit(s) that were made afterward: -5dce82c48b
This commit is contained in:
@@ -104,9 +104,9 @@ public class SpringSecurityLdapTemplateITests {
|
||||
new String[] { param }, "ou");
|
||||
|
||||
assertThat(values).as("Expected 3 results from search").hasSize(3);
|
||||
assertThat(values).contains("developer");
|
||||
assertThat(values).contains("manager");
|
||||
assertThat(values).contains("submanager");
|
||||
assertThat(values.contains("developer")).isTrue();
|
||||
assertThat(values.contains("manager")).isTrue();
|
||||
assertThat(values.contains("submanager")).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -149,7 +149,7 @@ public class SpringSecurityLdapTemplateITests {
|
||||
}
|
||||
|
||||
protected void assertAttributeValue(Map<String, List<String>> record, String attributeName, String... values) {
|
||||
assertThat(record).containsKey(attributeName);
|
||||
assertThat(record.containsKey(attributeName)).isTrue();
|
||||
assertThat(record.get(attributeName)).hasSize(values.length);
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
assertThat(record.get(attributeName).get(i)).isEqualTo(values[i]);
|
||||
|
||||
@@ -72,8 +72,8 @@ public class DefaultLdapAuthoritiesPopulatorGetGrantedAuthoritiesTests {
|
||||
|
||||
assertThat(authorities).as("Should have 1 role").hasSize(2);
|
||||
|
||||
assertThat(authorities).contains("ROLE_DEVELOPER");
|
||||
assertThat(authorities).contains("ROLE_");
|
||||
assertThat(authorities.contains("ROLE_DEVELOPER")).isTrue();
|
||||
assertThat(authorities.contains("ROLE_")).isTrue();
|
||||
}
|
||||
|
||||
@Configuration
|
||||
|
||||
@@ -68,7 +68,7 @@ public class DefaultLdapAuthoritiesPopulatorTests {
|
||||
|
||||
Collection<GrantedAuthority> authorities = this.populator.getGrantedAuthorities(ctx, "notfound");
|
||||
assertThat(authorities).hasSize(1);
|
||||
assertThat(AuthorityUtils.authorityListToSet(authorities)).contains("ROLE_USER");
|
||||
assertThat(AuthorityUtils.authorityListToSet(authorities).contains("ROLE_USER")).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -79,7 +79,7 @@ public class DefaultLdapAuthoritiesPopulatorTests {
|
||||
Collection<GrantedAuthority> authorities = this.populator
|
||||
.getGrantedAuthorities(new DirContextAdapter(new DistinguishedName("cn=notused")), "notused");
|
||||
assertThat(authorities).hasSize(1);
|
||||
assertThat(AuthorityUtils.authorityListToSet(authorities)).contains("ROLE_USER");
|
||||
assertThat(AuthorityUtils.authorityListToSet(authorities).contains("ROLE_USER")).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -98,8 +98,8 @@ public class DefaultLdapAuthoritiesPopulatorTests {
|
||||
|
||||
assertThat(authorities).as("Should have 2 roles").hasSize(2);
|
||||
|
||||
assertThat(authorities).contains("ROLE_DEVELOPER");
|
||||
assertThat(authorities).contains("ROLE_MANAGER");
|
||||
assertThat(authorities.contains("ROLE_DEVELOPER")).isTrue();
|
||||
assertThat(authorities.contains("ROLE_MANAGER")).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -115,7 +115,7 @@ public class DefaultLdapAuthoritiesPopulatorTests {
|
||||
.authorityListToSet(this.populator.getGrantedAuthorities(ctx, "manager"));
|
||||
|
||||
assertThat(authorities).as("Should have 1 role").hasSize(1);
|
||||
assertThat(authorities).contains("ROLE_MANAGER");
|
||||
assertThat(authorities.contains("ROLE_MANAGER")).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -130,8 +130,8 @@ public class DefaultLdapAuthoritiesPopulatorTests {
|
||||
.authorityListToSet(this.populator.getGrantedAuthorities(ctx, "manager"));
|
||||
|
||||
assertThat(authorities).as("Should have 2 roles").hasSize(2);
|
||||
assertThat(authorities).contains("ROLE_MANAGER");
|
||||
assertThat(authorities).contains("ROLE_DEVELOPER");
|
||||
assertThat(authorities.contains("ROLE_MANAGER")).isTrue();
|
||||
assertThat(authorities.contains("ROLE_DEVELOPER")).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -147,9 +147,9 @@ public class DefaultLdapAuthoritiesPopulatorTests {
|
||||
.authorityListToSet(this.populator.getGrantedAuthorities(ctx, "manager"));
|
||||
|
||||
assertThat(authorities).as("Should have 3 roles").hasSize(3);
|
||||
assertThat(authorities).contains("ROLE_MANAGER");
|
||||
assertThat(authorities).contains("ROLE_SUBMANAGER");
|
||||
assertThat(authorities).contains("ROLE_DEVELOPER");
|
||||
assertThat(authorities.contains("ROLE_MANAGER")).isTrue();
|
||||
assertThat(authorities.contains("ROLE_SUBMANAGER")).isTrue();
|
||||
assertThat(authorities.contains("ROLE_DEVELOPER")).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -164,7 +164,7 @@ public class DefaultLdapAuthoritiesPopulatorTests {
|
||||
Collection<GrantedAuthority> authorities = this.populator
|
||||
.getGrantedAuthorities(new DirContextAdapter(new DistinguishedName("cn=notused")), "notused");
|
||||
assertThat(authorities).hasSize(1);
|
||||
assertThat(AuthorityUtils.authorityListToSet(authorities)).contains("ROLE_EXTRA");
|
||||
assertThat(AuthorityUtils.authorityListToSet(authorities).contains("ROLE_EXTRA")).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -180,7 +180,7 @@ public class DefaultLdapAuthoritiesPopulatorTests {
|
||||
.authorityListToSet(this.populator.getGrantedAuthorities(ctx, "notused"));
|
||||
|
||||
assertThat(authorities).as("Should have 1 role").hasSize(1);
|
||||
assertThat(authorities).contains("ROLE_MANAGER");
|
||||
assertThat(authorities.contains("ROLE_MANAGER")).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -128,14 +128,14 @@ public class NestedLdapAuthoritiesPopulatorTests {
|
||||
LdapAuthority[] ldapAuthorities = authorities.toArray(new LdapAuthority[0]);
|
||||
assertThat(ldapAuthorities).hasSize(5);
|
||||
// groovy-developers group
|
||||
assertThat(ldapAuthorities[0].getAttributes()).containsKey("member");
|
||||
assertThat(ldapAuthorities[0].getAttributes().containsKey("member")).isTrue();
|
||||
assertThat(ldapAuthorities[0].getAttributes().get("member")).isNotNull();
|
||||
assertThat(ldapAuthorities[0].getAttributes().get("member")).hasSize(3);
|
||||
assertThat(ldapAuthorities[0].getFirstAttributeValue("member"))
|
||||
.isEqualTo("cn=groovy-developers,ou=jdeveloper,dc=springframework,dc=org");
|
||||
|
||||
// java group
|
||||
assertThat(ldapAuthorities[1].getAttributes()).containsKey("member");
|
||||
assertThat(ldapAuthorities[1].getAttributes().containsKey("member")).isTrue();
|
||||
assertThat(ldapAuthorities[1].getAttributes().get("member")).isNotNull();
|
||||
assertThat(ldapAuthorities[1].getAttributes().get("member")).hasSize(3);
|
||||
assertThat(this.groovyDevelopers.getDn()).isEqualTo(ldapAuthorities[1].getFirstAttributeValue("member"));
|
||||
|
||||
@@ -260,30 +260,44 @@ public final class ActiveDirectoryLdapAuthenticationProvider extends AbstractLda
|
||||
String hexString = Integer.toHexString(code);
|
||||
Throwable cause = new ActiveDirectoryAuthenticationException(hexString, exception.getMessage(), exception);
|
||||
switch (code) {
|
||||
case PASSWORD_EXPIRED -> throw new CredentialsExpiredException(this.messages
|
||||
.getMessage("LdapAuthenticationProvider.credentialsExpired", "User credentials have expired"), cause);
|
||||
case ACCOUNT_DISABLED -> throw new DisabledException(
|
||||
this.messages.getMessage("LdapAuthenticationProvider.disabled", "User is disabled"), cause);
|
||||
case ACCOUNT_EXPIRED -> throw new AccountExpiredException(
|
||||
this.messages.getMessage("LdapAuthenticationProvider.expired", "User account has expired"), cause);
|
||||
case ACCOUNT_LOCKED -> throw new LockedException(
|
||||
this.messages.getMessage("LdapAuthenticationProvider.locked", "User account is locked"), cause);
|
||||
default -> throw badCredentials(cause);
|
||||
case PASSWORD_EXPIRED:
|
||||
throw new CredentialsExpiredException(this.messages.getMessage(
|
||||
"LdapAuthenticationProvider.credentialsExpired", "User credentials have expired"), cause);
|
||||
case ACCOUNT_DISABLED:
|
||||
throw new DisabledException(
|
||||
this.messages.getMessage("LdapAuthenticationProvider.disabled", "User is disabled"), cause);
|
||||
case ACCOUNT_EXPIRED:
|
||||
throw new AccountExpiredException(
|
||||
this.messages.getMessage("LdapAuthenticationProvider.expired", "User account has expired"),
|
||||
cause);
|
||||
case ACCOUNT_LOCKED:
|
||||
throw new LockedException(
|
||||
this.messages.getMessage("LdapAuthenticationProvider.locked", "User account is locked"), cause);
|
||||
default:
|
||||
throw badCredentials(cause);
|
||||
}
|
||||
}
|
||||
|
||||
private String subCodeToLogMessage(int code) {
|
||||
return switch (code) {
|
||||
case USERNAME_NOT_FOUND -> "User was not found in directory";
|
||||
case INVALID_PASSWORD -> "Supplied password was invalid";
|
||||
case NOT_PERMITTED -> "User not permitted to logon at this time";
|
||||
case PASSWORD_EXPIRED -> "Password has expired";
|
||||
case ACCOUNT_DISABLED -> "Account is disabled";
|
||||
case ACCOUNT_EXPIRED -> "Account expired";
|
||||
case PASSWORD_NEEDS_RESET -> "User must reset password";
|
||||
case ACCOUNT_LOCKED -> "Account locked";
|
||||
default -> "Unknown (error code " + Integer.toHexString(code) + ")";
|
||||
};
|
||||
switch (code) {
|
||||
case USERNAME_NOT_FOUND:
|
||||
return "User was not found in directory";
|
||||
case INVALID_PASSWORD:
|
||||
return "Supplied password was invalid";
|
||||
case NOT_PERMITTED:
|
||||
return "User not permitted to logon at this time";
|
||||
case PASSWORD_EXPIRED:
|
||||
return "Password has expired";
|
||||
case ACCOUNT_DISABLED:
|
||||
return "Account is disabled";
|
||||
case ACCOUNT_EXPIRED:
|
||||
return "Account expired";
|
||||
case PASSWORD_NEEDS_RESET:
|
||||
return "User must reset password";
|
||||
case ACCOUNT_LOCKED:
|
||||
return "Account locked";
|
||||
}
|
||||
return "Unknown (error code " + Integer.toHexString(code) + ")";
|
||||
}
|
||||
|
||||
private BadCredentialsException badCredentials() {
|
||||
|
||||
@@ -73,10 +73,10 @@ import org.springframework.util.Assert;
|
||||
* @author Rob Winch
|
||||
* @author Gunnar Hillert
|
||||
* @author Evgeniy Cheban
|
||||
* @deprecated For removal in 7.0. Use {@link UnboundIdContainer} instead because ApacheDS
|
||||
* 1.x is no longer supported with no GA version to replace it.
|
||||
* @deprecated Use {@link UnboundIdContainer} instead because ApacheDS 1.x is no longer
|
||||
* supported with no GA version to replace it.
|
||||
*/
|
||||
@Deprecated(since = "5.2", forRemoval = true)
|
||||
@Deprecated
|
||||
public class ApacheDSContainer
|
||||
implements EmbeddedLdapServerContainer, InitializingBean, DisposableBean, Lifecycle, ApplicationContextAware {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -113,13 +113,14 @@ public class LdapAuthority implements GrantedAuthority {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof LdapAuthority other)) {
|
||||
if (!(obj instanceof LdapAuthority)) {
|
||||
return false;
|
||||
}
|
||||
if (!this.dn.equals(other.getDn())) {
|
||||
LdapAuthority other = (LdapAuthority) obj;
|
||||
if (!this.dn.equals(other.dn)) {
|
||||
return false;
|
||||
}
|
||||
return this.role.equals(other.getAuthority());
|
||||
return this.role.equals(other.role);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -46,7 +46,7 @@ public class InetOrgPersonTests {
|
||||
InetOrgPerson p2 = (InetOrgPerson) essence.createUserDetails();
|
||||
Set<InetOrgPerson> set = new HashSet<>();
|
||||
set.add(p);
|
||||
assertThat(set).contains(p2);
|
||||
assertThat(set.contains(p2)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -60,7 +60,7 @@ public class LdapUserDetailsServiceTests {
|
||||
UserDetails user = service.loadUserByUsername("doesntmatterwegetjoeanyway");
|
||||
Set<String> authorities = AuthorityUtils.authorityListToSet(user.getAuthorities());
|
||||
assertThat(authorities).hasSize(1);
|
||||
assertThat(authorities).contains("ROLE_FROM_POPULATOR");
|
||||
assertThat(authorities.contains("ROLE_FROM_POPULATOR")).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -47,7 +47,7 @@ public class UserDetailsServiceLdapAuthoritiesPopulatorTests {
|
||||
UserDetailsServiceLdapAuthoritiesPopulator populator = new UserDetailsServiceLdapAuthoritiesPopulator(uds);
|
||||
Collection<? extends GrantedAuthority> auths = populator.getGrantedAuthorities(new DirContextAdapter(), "joe");
|
||||
assertThat(auths).hasSize(1);
|
||||
assertThat(AuthorityUtils.authorityListToSet(auths)).contains("ROLE_USER");
|
||||
assertThat(AuthorityUtils.authorityListToSet(auths).contains("ROLE_USER")).isTrue();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user