mirror of
https://github.com/spring-projects/spring-security.git
synced 2026-02-08 14:34:34 +00:00
Remove compiler warnings in spring-security-ldap
- Add compile-warnings-error plugin to ldap module - Replace org.springframework.lang.NonNull with org.jspecify.annotations.NonNull - Add @SuppressWarnings for unchecked/rawtypes/deprecation warnings Closes gh-18405 Signed-off-by: LeeJiWon <dlwldnjs1009@gmail.com>
This commit is contained in:
parent
a23be5e625
commit
9fa0a34b4c
@ -1,5 +1,6 @@
|
||||
apply plugin: 'io.spring.convention.spring-module'
|
||||
apply plugin: 'javadoc-warnings-error'
|
||||
apply plugin: 'compile-warnings-error'
|
||||
|
||||
dependencies {
|
||||
management platform(project(":spring-security-dependencies"))
|
||||
|
||||
@ -68,6 +68,7 @@ public class DefaultSpringSecurityContextSourceTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public void poolingFlagIsSetWhenAuthenticationDnMatchesManagerUserDn() {
|
||||
EnvExposingDefaultSpringSecurityContextSource ctxSrc = new EnvExposingDefaultSpringSecurityContextSource(
|
||||
"ldap://blah:789/dc=springframework,dc=org");
|
||||
@ -79,6 +80,7 @@ public class DefaultSpringSecurityContextSourceTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public void poolingFlagIsNotSetWhenAuthenticationDnIsNotManagerUserDn() {
|
||||
EnvExposingDefaultSpringSecurityContextSource ctxSrc = new EnvExposingDefaultSpringSecurityContextSource(
|
||||
"ldap://blah:789/dc=springframework,dc=org");
|
||||
@ -170,13 +172,13 @@ public class DefaultSpringSecurityContextSourceTests {
|
||||
.isThrownBy(() -> new DefaultSpringSecurityContextSource(serverUrls, "dc=springframework,dc=org"));
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
static class EnvExposingDefaultSpringSecurityContextSource extends DefaultSpringSecurityContextSource {
|
||||
|
||||
EnvExposingDefaultSpringSecurityContextSource(String providerUrl) {
|
||||
super(providerUrl);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Hashtable getAuthenticatedEnvForTest(String userDn, String password) {
|
||||
return getAuthenticatedEnv(userDn, password);
|
||||
}
|
||||
|
||||
@ -89,6 +89,7 @@ public class SpringSecurityLdapTemplateITests {
|
||||
// }
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void namingExceptionIsTranslatedCorrectly() {
|
||||
assertThatExceptionOfType(UncategorizedLdapException.class)
|
||||
.isThrownBy(() -> this.template.executeReadOnly((ContextExecutor) (dirContext) -> {
|
||||
|
||||
@ -47,6 +47,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
|
||||
*/
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration(classes = UnboundIdContainerConfig.class)
|
||||
@SuppressWarnings("deprecation")
|
||||
public class PasswordComparisonAuthenticatorTests {
|
||||
|
||||
@Autowired
|
||||
|
||||
@ -57,6 +57,7 @@ public class DefaultLdapAuthoritiesPopulatorGetGrantedAuthoritiesTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
public void groupSearchDoesNotAllowNullRoles() {
|
||||
this.populator.setRolePrefix("ROLE_");
|
||||
this.populator.setGroupRoleAttribute("ou");
|
||||
|
||||
@ -116,6 +116,7 @@ public class NestedLdapAuthoritiesPopulatorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testClosureDudeJDevelopersWithMembershipAsAttributeValues() {
|
||||
this.populator.setAttributeNames(new HashSet(Arrays.asList("member")));
|
||||
|
||||
|
||||
@ -21,11 +21,11 @@ import java.util.LinkedHashSet;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
|
||||
import org.springframework.context.MessageSource;
|
||||
import org.springframework.context.MessageSourceAware;
|
||||
import org.springframework.context.support.MessageSourceAccessor;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.ldap.core.DirContextOperations;
|
||||
import org.springframework.security.authentication.AuthenticationProvider;
|
||||
import org.springframework.security.authentication.BadCredentialsException;
|
||||
|
||||
@ -21,11 +21,12 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.jspecify.annotations.NonNull;
|
||||
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.context.MessageSource;
|
||||
import org.springframework.context.MessageSourceAware;
|
||||
import org.springframework.context.support.MessageSourceAccessor;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.ldap.core.ContextSource;
|
||||
import org.springframework.security.core.SpringSecurityMessageSource;
|
||||
import org.springframework.security.ldap.search.LdapUserSearch;
|
||||
|
||||
@ -25,6 +25,7 @@ import com.unboundid.ldap.sdk.DN;
|
||||
import com.unboundid.ldap.sdk.Entry;
|
||||
import com.unboundid.ldap.sdk.LDAPException;
|
||||
import com.unboundid.ldif.LDIFReader;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
@ -34,7 +35,6 @@ import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.Lifecycle;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
|
||||
@ -369,6 +369,7 @@ public class LdapUserDetailsManager implements UserDetailsManager {
|
||||
this.groupSearchFilter = "(" + groupMemberAttributeName + "={0})";
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void setRoleMapper(AttributesMapper roleMapper) {
|
||||
this.roleMapper = roleMapper;
|
||||
}
|
||||
|
||||
@ -38,6 +38,7 @@ import static org.mockito.Mockito.mock;
|
||||
public class PasswordComparisonAuthenticatorMockTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void ldapCompareOperationIsUsedWhenPasswordIsNotRetrieved() throws Exception {
|
||||
final DirContext dirCtx = mock(DirContext.class);
|
||||
final BaseLdapPathContextSource source = mock(BaseLdapPathContextSource.class);
|
||||
|
||||
@ -38,6 +38,7 @@ import static org.mockito.Mockito.mock;
|
||||
public class UserDetailsServiceLdapAuthoritiesPopulatorTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void delegationToUserDetailsServiceReturnsCorrectRoles() {
|
||||
UserDetailsService uds = mock(UserDetailsService.class);
|
||||
UserDetails user = mock(UserDetails.class);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user