Move inner-types so that they are always last
Move all inner-types so that they are consistently the last item defined. This aligns with the style used by Spring Framework and the consistency generally makes it easier to scan the source. Issue gh-8945
This commit is contained in:
@@ -175,29 +175,6 @@ public class User implements UserDetails, CredentialsContainer {
|
||||
return sortedAuthorities;
|
||||
}
|
||||
|
||||
private static class AuthorityComparator implements Comparator<GrantedAuthority>, Serializable {
|
||||
|
||||
private static final long serialVersionUID = SpringSecurityCoreVersion.SERIAL_VERSION_UID;
|
||||
|
||||
@Override
|
||||
public int compare(GrantedAuthority g1, GrantedAuthority g2) {
|
||||
// Neither should ever be null as each entry is checked before adding it to
|
||||
// the set.
|
||||
// If the authority is null, it is a custom authority and should precede
|
||||
// others.
|
||||
if (g2.getAuthority() == null) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (g1.getAuthority() == null) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return g1.getAuthority().compareTo(g2.getAuthority());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@code true} if the supplied object is a {@code User} instance with the
|
||||
* same {@code username} value.
|
||||
@@ -339,6 +316,29 @@ public class User implements UserDetails, CredentialsContainer {
|
||||
.disabled(!userDetails.isEnabled());
|
||||
}
|
||||
|
||||
private static class AuthorityComparator implements Comparator<GrantedAuthority>, Serializable {
|
||||
|
||||
private static final long serialVersionUID = SpringSecurityCoreVersion.SERIAL_VERSION_UID;
|
||||
|
||||
@Override
|
||||
public int compare(GrantedAuthority g1, GrantedAuthority g2) {
|
||||
// Neither should ever be null as each entry is checked before adding it to
|
||||
// the set.
|
||||
// If the authority is null, it is a custom authority and should precede
|
||||
// others.
|
||||
if (g2.getAuthority() == null) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (g1.getAuthority() == null) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return g1.getAuthority().compareTo(g2.getAuthority());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the user to be added. At minimum the username, password, and authorities
|
||||
* should provided. The remaining attributes have reasonable defaults.
|
||||
|
||||
+6
-6
@@ -683,6 +683,12 @@ public class DaoAuthenticationProviderTests {
|
||||
verify(encoder, times(0)).matches(anyString(), anyString());
|
||||
}
|
||||
|
||||
private DaoAuthenticationProvider createProvider() {
|
||||
DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
|
||||
provider.setPasswordEncoder(NoOpPasswordEncoder.getInstance());
|
||||
return provider;
|
||||
}
|
||||
|
||||
private class MockUserDetailsServiceReturnsNull implements UserDetailsService {
|
||||
|
||||
@Override
|
||||
@@ -767,10 +773,4 @@ public class DaoAuthenticationProviderTests {
|
||||
|
||||
}
|
||||
|
||||
private DaoAuthenticationProvider createProvider() {
|
||||
DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
|
||||
provider.setPasswordEncoder(NoOpPasswordEncoder.getInstance());
|
||||
return provider;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user