|
@@ -68,14 +68,14 @@ public abstract class AbstractAuthenticationToken implements Authentication, Cre
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public String getName() {
|
|
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();
|
|
return (this.getPrincipal() == null) ? "" : this.getPrincipal().toString();
|
|
}
|
|
}
|
|
@@ -119,10 +119,9 @@ public abstract class AbstractAuthenticationToken implements Authentication, Cre
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public boolean equals(Object obj) {
|
|
public boolean equals(Object obj) {
|
|
- if (!(obj instanceof AbstractAuthenticationToken)) {
|
|
|
|
|
|
+ if (!(obj instanceof AbstractAuthenticationToken test)) {
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
- AbstractAuthenticationToken test = (AbstractAuthenticationToken) obj;
|
|
|
|
if (!this.authorities.equals(test.authorities)) {
|
|
if (!this.authorities.equals(test.authorities)) {
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|