Change AccessToken.TokenType from enum to class
Fixes gh-4293
This commit is contained in:
parent
435e389609
commit
336e247e70
|
@ -113,7 +113,7 @@ public class NimbusAuthorizationCodeTokenExchanger implements AuthorizationGrant
|
||||||
|
|
||||||
String accessToken = accessTokenResponse.getTokens().getAccessToken().getValue();
|
String accessToken = accessTokenResponse.getTokens().getAccessToken().getValue();
|
||||||
AccessToken.TokenType accessTokenType = null;
|
AccessToken.TokenType accessTokenType = null;
|
||||||
if (AccessToken.TokenType.BEARER.value().equals(accessTokenResponse.getTokens().getAccessToken().getType().getValue())) {
|
if (AccessToken.TokenType.BEARER.getValue().equalsIgnoreCase(accessTokenResponse.getTokens().getAccessToken().getType().getValue())) {
|
||||||
accessTokenType = AccessToken.TokenType.BEARER;
|
accessTokenType = AccessToken.TokenType.BEARER;
|
||||||
}
|
}
|
||||||
long expiresIn = accessTokenResponse.getTokens().getAccessToken().getLifetime();
|
long expiresIn = accessTokenResponse.getTokens().getAccessToken().getLifetime();
|
||||||
|
|
|
@ -40,18 +40,35 @@ public class AccessToken extends AbstractToken {
|
||||||
private final Set<String> scopes;
|
private final Set<String> scopes;
|
||||||
private final Map<String,Object> additionalParameters;
|
private final Map<String,Object> additionalParameters;
|
||||||
|
|
||||||
public enum TokenType {
|
public static final class TokenType {
|
||||||
BEARER("Bearer");
|
public static final TokenType BEARER = new TokenType("Bearer");
|
||||||
|
|
||||||
private final String value;
|
private final String value;
|
||||||
|
|
||||||
TokenType(String value) {
|
public TokenType(String value) {
|
||||||
|
Assert.hasText(value, "value cannot be empty");
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String value() {
|
public String getValue() {
|
||||||
return this.value;
|
return this.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (obj == null || this.getClass() != obj.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
TokenType that = (TokenType) obj;
|
||||||
|
return this.getValue().equalsIgnoreCase(that.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return this.getValue().hashCode();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public AccessToken(TokenType tokenType, String tokenValue, Instant issuedAt, Instant expiresAt) {
|
public AccessToken(TokenType tokenType, String tokenValue, Instant issuedAt, Instant expiresAt) {
|
||||||
|
|
Loading…
Reference in New Issue