Change ClientAuthenticationMethod from enum to class
Fixes gh-4313
This commit is contained in:
+1
-1
@@ -78,7 +78,7 @@ public class NimbusAuthorizationCodeTokenExchanger implements AuthorizationGrant
|
||||
ClientID clientId = new ClientID(clientRegistration.getClientId());
|
||||
Secret clientSecret = new Secret(clientRegistration.getClientSecret());
|
||||
ClientAuthentication clientAuthentication;
|
||||
if (ClientAuthenticationMethod.FORM.equals(clientRegistration.getClientAuthenticationMethod())) {
|
||||
if (ClientAuthenticationMethod.POST.equals(clientRegistration.getClientAuthenticationMethod())) {
|
||||
clientAuthentication = new ClientSecretPost(clientId, clientSecret);
|
||||
} else {
|
||||
clientAuthentication = new ClientSecretBasic(clientId, clientSecret);
|
||||
|
||||
+2
-2
@@ -35,7 +35,7 @@ import java.util.Set;
|
||||
public class ClientRegistration {
|
||||
private String clientId;
|
||||
private String clientSecret;
|
||||
private ClientAuthenticationMethod clientAuthenticationMethod = ClientAuthenticationMethod.HEADER;
|
||||
private ClientAuthenticationMethod clientAuthenticationMethod = ClientAuthenticationMethod.BASIC;
|
||||
private AuthorizationGrantType authorizedGrantType;
|
||||
private String redirectUri;
|
||||
private Set<String> scopes = Collections.emptySet();
|
||||
@@ -154,7 +154,7 @@ public class ClientRegistration {
|
||||
public static class Builder {
|
||||
protected String clientId;
|
||||
protected String clientSecret;
|
||||
protected ClientAuthenticationMethod clientAuthenticationMethod = ClientAuthenticationMethod.HEADER;
|
||||
protected ClientAuthenticationMethod clientAuthenticationMethod = ClientAuthenticationMethod.BASIC;
|
||||
protected AuthorizationGrantType authorizedGrantType;
|
||||
protected String redirectUri;
|
||||
protected Set<String> scopes;
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@ import java.util.Set;
|
||||
public class ClientRegistrationProperties {
|
||||
private String clientId;
|
||||
private String clientSecret;
|
||||
private ClientAuthenticationMethod clientAuthenticationMethod = ClientAuthenticationMethod.HEADER;
|
||||
private ClientAuthenticationMethod clientAuthenticationMethod = ClientAuthenticationMethod.BASIC;
|
||||
private AuthorizationGrantType authorizedGrantType;
|
||||
private String redirectUri;
|
||||
private Set<String> scopes;
|
||||
|
||||
+25
-6
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package org.springframework.security.oauth2.core;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* The available authentication methods used when authenticating the client with the authorization server.
|
||||
*
|
||||
@@ -22,17 +24,34 @@ package org.springframework.security.oauth2.core;
|
||||
* @since 5.0
|
||||
* @see <a target="_blank" href="https://tools.ietf.org/html/rfc6749#section-2.3">Section 2.3 Client Authentication</a>
|
||||
*/
|
||||
public enum ClientAuthenticationMethod {
|
||||
HEADER("header"),
|
||||
FORM("form");
|
||||
|
||||
public final class ClientAuthenticationMethod {
|
||||
public static final ClientAuthenticationMethod BASIC = new ClientAuthenticationMethod("basic");
|
||||
public static final ClientAuthenticationMethod POST = new ClientAuthenticationMethod("post");
|
||||
private final String value;
|
||||
|
||||
ClientAuthenticationMethod(String value) {
|
||||
public ClientAuthenticationMethod(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;
|
||||
}
|
||||
ClientAuthenticationMethod that = (ClientAuthenticationMethod) obj;
|
||||
return this.getValue().equalsIgnoreCase(that.getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.getValue().hashCode();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user