Apply code cleanup rules to projects
Apply automated cleanup rules to add `@Override` and `@Deprecated` annotations and to fix class references used with static methods. Issue gh-8945
This commit is contained in:
+1
@@ -34,6 +34,7 @@ import org.springframework.security.core.context.SecurityContextHolder;
|
||||
*/
|
||||
final class WithAnonymousUserSecurityContextFactory implements WithSecurityContextFactory<WithAnonymousUser> {
|
||||
|
||||
@Override
|
||||
public SecurityContext createSecurityContext(WithAnonymousUser withUser) {
|
||||
List<GrantedAuthority> authorities = AuthorityUtils.createAuthorityList("ROLE_ANONYMOUS");
|
||||
Authentication authentication = new AnonymousAuthenticationToken("key", "anonymous", authorities);
|
||||
|
||||
+1
@@ -37,6 +37,7 @@ import org.springframework.util.StringUtils;
|
||||
*/
|
||||
final class WithMockUserSecurityContextFactory implements WithSecurityContextFactory<WithMockUser> {
|
||||
|
||||
@Override
|
||||
public SecurityContext createSecurityContext(WithMockUser withUser) {
|
||||
String username = StringUtils.hasLength(withUser.username()) ? withUser.username() : withUser.value();
|
||||
if (username == null) {
|
||||
|
||||
+1
@@ -51,6 +51,7 @@ final class WithUserDetailsSecurityContextFactory implements WithSecurityContext
|
||||
this.beans = beans;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SecurityContext createSecurityContext(WithUserDetails withUser) {
|
||||
String beanName = withUser.userDetailsServiceBeanName();
|
||||
UserDetailsService userDetailsService = findUserDetailsService(beanName);
|
||||
|
||||
+1
@@ -107,6 +107,7 @@ public class SecurityMockServerConfigurers {
|
||||
*/
|
||||
public static MockServerConfigurer springSecurity() {
|
||||
return new MockServerConfigurer() {
|
||||
@Override
|
||||
public void beforeServerCreated(WebHttpHandlerBuilder builder) {
|
||||
builder.filters(filters -> filters.add(0, new MutatorFilter()));
|
||||
}
|
||||
|
||||
+7
@@ -38,30 +38,37 @@ public class CustomUserDetails implements UserDetails {
|
||||
this.authorities = AuthorityUtils.createAuthorityList("ROLE_USER");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<? extends GrantedAuthority> getAuthorities() {
|
||||
return this.authorities;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPassword() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUsername() {
|
||||
return this.username;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAccountNonExpired() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAccountNonLocked() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCredentialsNonExpired() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
+1
@@ -26,6 +26,7 @@ import org.springframework.security.test.context.support.WithSecurityContextFact
|
||||
*/
|
||||
public class WithMockCustomUserSecurityContextFactory implements WithSecurityContextFactory<WithMockCustomUser> {
|
||||
|
||||
@Override
|
||||
public SecurityContext createSecurityContext(WithMockCustomUser customUser) {
|
||||
SecurityContext context = SecurityContextHolder.createEmptyContext();
|
||||
|
||||
|
||||
+1
@@ -101,6 +101,7 @@ public class WithUserDetailsTests {
|
||||
|
||||
static class CustomUserDetailsService implements UserDetailsService {
|
||||
|
||||
@Override
|
||||
public UserDetails loadUserByUsername(final String username) throws UsernameNotFoundException {
|
||||
return new CustomUserDetails("name", username);
|
||||
}
|
||||
|
||||
+1
@@ -26,6 +26,7 @@ import org.springframework.stereotype.Component;
|
||||
@Component
|
||||
public class HelloMessageService implements MessageService {
|
||||
|
||||
@Override
|
||||
@PreAuthorize("authenticated")
|
||||
public String getMessage() {
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
|
||||
+1
@@ -99,6 +99,7 @@ public class SecurityMockMvcResultMatchersTests {
|
||||
@EnableWebMvc
|
||||
static class Config extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
@Bean
|
||||
public UserDetailsService userDetailsService() {
|
||||
// @formatter:off
|
||||
|
||||
+1
@@ -79,6 +79,7 @@ public class SecurityMockWithAuthoritiesMvcResultMatchersTests {
|
||||
@EnableWebMvc
|
||||
static class Config extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
@Bean
|
||||
public UserDetailsService userDetailsService() {
|
||||
// @formatter:off
|
||||
|
||||
+1
@@ -88,6 +88,7 @@ public class AuthenticationTests {
|
||||
@EnableWebMvc
|
||||
static class Config extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
@Bean
|
||||
public UserDetailsService userDetailsService() {
|
||||
// @formatter:off
|
||||
|
||||
+1
@@ -107,6 +107,7 @@ public class CustomConfigAuthenticationTests {
|
||||
}
|
||||
|
||||
// @formatter:off
|
||||
@Override
|
||||
@Bean
|
||||
public UserDetailsService userDetailsService() {
|
||||
UserDetails user = User.withDefaultPasswordEncoder().username("user").password("password").roles("USER").build();
|
||||
|
||||
+1
@@ -94,6 +94,7 @@ public class CustomLoginRequestBuilderAuthenticationTests {
|
||||
}
|
||||
|
||||
// @formatter:off
|
||||
@Override
|
||||
@Bean
|
||||
public UserDetailsService userDetailsService() {
|
||||
UserDetails user = User.withDefaultPasswordEncoder().username("user").password("password").roles("USER").build();
|
||||
|
||||
Reference in New Issue
Block a user