Remove authoritiesClaimName Field
This commit simplfies the logic in JwtGrantedAuthoritiesConverter to no longer need the authoritiesClaimName field. Signed-off-by: chanbinme <gksmfcksqls@gmail.com>
This commit is contained in:
parent
164cc4611c
commit
08fa272749
|
@ -53,7 +53,7 @@ public final class JwtGrantedAuthoritiesConverter implements Converter<Jwt, Coll
|
||||||
|
|
||||||
private String authoritiesClaimDelimiter = DEFAULT_AUTHORITIES_CLAIM_DELIMITER;
|
private String authoritiesClaimDelimiter = DEFAULT_AUTHORITIES_CLAIM_DELIMITER;
|
||||||
|
|
||||||
private String authoritiesClaimName;
|
private Collection<String> authoritiesClaimNames = WELL_KNOWN_AUTHORITIES_CLAIM_NAMES;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extract {@link GrantedAuthority}s from the given {@link Jwt}.
|
* Extract {@link GrantedAuthority}s from the given {@link Jwt}.
|
||||||
|
@ -102,14 +102,11 @@ public final class JwtGrantedAuthoritiesConverter implements Converter<Jwt, Coll
|
||||||
*/
|
*/
|
||||||
public void setAuthoritiesClaimName(String authoritiesClaimName) {
|
public void setAuthoritiesClaimName(String authoritiesClaimName) {
|
||||||
Assert.hasText(authoritiesClaimName, "authoritiesClaimName cannot be empty");
|
Assert.hasText(authoritiesClaimName, "authoritiesClaimName cannot be empty");
|
||||||
this.authoritiesClaimName = authoritiesClaimName;
|
this.authoritiesClaimNames = Collections.singletonList(authoritiesClaimName);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getAuthoritiesClaimName(Jwt jwt) {
|
private String getAuthoritiesClaimName(Jwt jwt) {
|
||||||
if (this.authoritiesClaimName != null) {
|
for (String claimName : this.authoritiesClaimNames) {
|
||||||
return this.authoritiesClaimName;
|
|
||||||
}
|
|
||||||
for (String claimName : WELL_KNOWN_AUTHORITIES_CLAIM_NAMES) {
|
|
||||||
if (jwt.hasClaim(claimName)) {
|
if (jwt.hasClaim(claimName)) {
|
||||||
return claimName;
|
return claimName;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue