Change AuthorizationGrantType from enum to class
Fixes gh-4291
This commit is contained in:
parent
4476df93e9
commit
545339c663
|
@ -264,7 +264,7 @@ public class ClientRegistration {
|
|||
|
||||
protected void validateClientWithAuthorizationCodeGrantType() {
|
||||
Assert.isTrue(AuthorizationGrantType.AUTHORIZATION_CODE.equals(this.authorizedGrantType),
|
||||
"authorizedGrantType must be " + AuthorizationGrantType.AUTHORIZATION_CODE.value());
|
||||
"authorizedGrantType must be " + AuthorizationGrantType.AUTHORIZATION_CODE.getValue());
|
||||
Assert.hasText(this.clientId, "clientId cannot be empty");
|
||||
Assert.hasText(this.clientSecret, "clientSecret cannot be empty");
|
||||
Assert.notNull(this.clientAuthenticationMethod, "clientAuthenticationMethod cannot be null");
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
*/
|
||||
package org.springframework.security.oauth2.core;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* An authorization grant is a credential representing the resource owner's authorization
|
||||
* (to access it's protected resources) to the client and used by the client to obtain an access token.
|
||||
|
@ -31,16 +33,33 @@ package org.springframework.security.oauth2.core;
|
|||
* @since 5.0
|
||||
* @see <a target="_blank" href="https://tools.ietf.org/html/rfc6749#section-1.3">Section 1.3 Authorization Grant</a>
|
||||
*/
|
||||
public enum AuthorizationGrantType {
|
||||
AUTHORIZATION_CODE("authorization_code");
|
||||
|
||||
public final class AuthorizationGrantType {
|
||||
public static final AuthorizationGrantType AUTHORIZATION_CODE = new AuthorizationGrantType("authorization_code");
|
||||
private final String value;
|
||||
|
||||
AuthorizationGrantType(String value) {
|
||||
public AuthorizationGrantType(String value) {
|
||||
Assert.hasText(value, "value cannot be empty");
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String value() {
|
||||
public String getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null || this.getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
AuthorizationGrantType that = (AuthorizationGrantType) obj;
|
||||
return this.getValue().equals(that.getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.getValue().hashCode();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue