Merge branch '6.1.x'
This commit is contained in:
+7
-8
@@ -68,14 +68,14 @@ public abstract class AbstractAuthenticationToken implements Authentication, Cre
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
if (this.getPrincipal() instanceof UserDetails) {
|
||||
return ((UserDetails) this.getPrincipal()).getUsername();
|
||||
if (this.getPrincipal() instanceof UserDetails userDetails) {
|
||||
return userDetails.getUsername();
|
||||
}
|
||||
if (this.getPrincipal() instanceof AuthenticatedPrincipal) {
|
||||
return ((AuthenticatedPrincipal) this.getPrincipal()).getName();
|
||||
if (this.getPrincipal() instanceof AuthenticatedPrincipal authenticatedPrincipal) {
|
||||
return authenticatedPrincipal.getName();
|
||||
}
|
||||
if (this.getPrincipal() instanceof Principal) {
|
||||
return ((Principal) this.getPrincipal()).getName();
|
||||
if (this.getPrincipal() instanceof Principal principal) {
|
||||
return principal.getName();
|
||||
}
|
||||
return (this.getPrincipal() == null) ? "" : this.getPrincipal().toString();
|
||||
}
|
||||
@@ -119,10 +119,9 @@ public abstract class AbstractAuthenticationToken implements Authentication, Cre
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof AbstractAuthenticationToken)) {
|
||||
if (!(obj instanceof AbstractAuthenticationToken test)) {
|
||||
return false;
|
||||
}
|
||||
AbstractAuthenticationToken test = (AbstractAuthenticationToken) obj;
|
||||
if (!this.authorities.equals(test.authorities)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
+1
-2
@@ -74,8 +74,7 @@ public class AnonymousAuthenticationToken extends AbstractAuthenticationToken im
|
||||
if (!super.equals(obj)) {
|
||||
return false;
|
||||
}
|
||||
if (obj instanceof AnonymousAuthenticationToken) {
|
||||
AnonymousAuthenticationToken test = (AnonymousAuthenticationToken) obj;
|
||||
if (obj instanceof AnonymousAuthenticationToken test) {
|
||||
return (this.getKeyHash() == test.getKeyHash());
|
||||
}
|
||||
return false;
|
||||
|
||||
+1
-1
@@ -59,7 +59,7 @@ public final class JaasGrantedAuthority implements GrantedAuthority {
|
||||
return true;
|
||||
}
|
||||
if (obj instanceof JaasGrantedAuthority jga) {
|
||||
return this.role.equals(jga.role) && this.principal.equals(jga.principal);
|
||||
return this.role.equals(jga.getAuthority()) && this.principal.equals(jga.getPrincipal());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
@@ -50,8 +50,8 @@ public final class SimpleGrantedAuthority implements GrantedAuthority {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj instanceof SimpleGrantedAuthority) {
|
||||
return this.role.equals(((SimpleGrantedAuthority) obj).role);
|
||||
if (obj instanceof SimpleGrantedAuthority sga) {
|
||||
return this.role.equals(sga.getAuthority());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -179,8 +179,8 @@ public class User implements UserDetails, CredentialsContainer {
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof User) {
|
||||
return this.username.equals(((User) obj).username);
|
||||
if (obj instanceof User user) {
|
||||
return this.username.equals(user.getUsername());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -208,7 +208,7 @@ public class User implements UserDetails, CredentialsContainer {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a UserBuilder with a specified user name
|
||||
* Creates a UserBuilder with a specified username
|
||||
* @param username the username to use
|
||||
* @return the UserBuilder
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user