|
|
|
@ -26,7 +26,7 @@ import java.util.LinkedHashSet; |
|
|
|
import java.util.Set; |
|
|
|
import java.util.Set; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* A representation of a client registration with an OAuth 2.0 / OpenID Connect 1.0 <i>Authorization Server</i>. |
|
|
|
* A representation of a client registration with an OAuth 2.0 or OpenID Connect 1.0 Provider. |
|
|
|
* |
|
|
|
* |
|
|
|
* @author Joe Grandja |
|
|
|
* @author Joe Grandja |
|
|
|
* @since 5.0 |
|
|
|
* @since 5.0 |
|
|
|
@ -46,38 +46,84 @@ public final class ClientRegistration { |
|
|
|
private ClientRegistration() { |
|
|
|
private ClientRegistration() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Returns the identifier for the registration. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return the identifier for the registration |
|
|
|
|
|
|
|
*/ |
|
|
|
public String getRegistrationId() { |
|
|
|
public String getRegistrationId() { |
|
|
|
return this.registrationId; |
|
|
|
return this.registrationId; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Returns the client identifier. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return the client identifier |
|
|
|
|
|
|
|
*/ |
|
|
|
public String getClientId() { |
|
|
|
public String getClientId() { |
|
|
|
return this.clientId; |
|
|
|
return this.clientId; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Returns the client secret. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return the client secret |
|
|
|
|
|
|
|
*/ |
|
|
|
public String getClientSecret() { |
|
|
|
public String getClientSecret() { |
|
|
|
return this.clientSecret; |
|
|
|
return this.clientSecret; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Returns the {@link ClientAuthenticationMethod authentication method} used |
|
|
|
|
|
|
|
* when authenticating the client with the authorization server. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return the {@link ClientAuthenticationMethod} |
|
|
|
|
|
|
|
*/ |
|
|
|
public ClientAuthenticationMethod getClientAuthenticationMethod() { |
|
|
|
public ClientAuthenticationMethod getClientAuthenticationMethod() { |
|
|
|
return this.clientAuthenticationMethod; |
|
|
|
return this.clientAuthenticationMethod; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Returns the {@link AuthorizationGrantType authorization grant type} used for the client. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return the {@link AuthorizationGrantType} |
|
|
|
|
|
|
|
*/ |
|
|
|
public AuthorizationGrantType getAuthorizationGrantType() { |
|
|
|
public AuthorizationGrantType getAuthorizationGrantType() { |
|
|
|
return this.authorizationGrantType; |
|
|
|
return this.authorizationGrantType; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Returns the uri (or uri template) for the redirection endpoint. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return the uri for the redirection endpoint |
|
|
|
|
|
|
|
*/ |
|
|
|
public String getRedirectUriTemplate() { |
|
|
|
public String getRedirectUriTemplate() { |
|
|
|
return this.redirectUriTemplate; |
|
|
|
return this.redirectUriTemplate; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Returns the scope(s) used for the client. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return the {@code Set} of scope(s) |
|
|
|
|
|
|
|
*/ |
|
|
|
public Set<String> getScopes() { |
|
|
|
public Set<String> getScopes() { |
|
|
|
return this.scopes; |
|
|
|
return this.scopes; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Returns the details of the provider. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return the {@link ProviderDetails} |
|
|
|
|
|
|
|
*/ |
|
|
|
public ProviderDetails getProviderDetails() { |
|
|
|
public ProviderDetails getProviderDetails() { |
|
|
|
return this.providerDetails; |
|
|
|
return this.providerDetails; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Returns the logical name of the client or registration. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return the client or registration name |
|
|
|
|
|
|
|
*/ |
|
|
|
public String getClientName() { |
|
|
|
public String getClientName() { |
|
|
|
return this.clientName; |
|
|
|
return this.clientName; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -97,6 +143,9 @@ public final class ClientRegistration { |
|
|
|
+ '\'' + '}'; |
|
|
|
+ '\'' + '}'; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Details of the Provider. |
|
|
|
|
|
|
|
*/ |
|
|
|
public class ProviderDetails { |
|
|
|
public class ProviderDetails { |
|
|
|
private String authorizationUri; |
|
|
|
private String authorizationUri; |
|
|
|
private String tokenUri; |
|
|
|
private String tokenUri; |
|
|
|
@ -106,22 +155,45 @@ public final class ClientRegistration { |
|
|
|
private ProviderDetails() { |
|
|
|
private ProviderDetails() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Returns the uri for the authorization endpoint. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return the uri for the authorization endpoint |
|
|
|
|
|
|
|
*/ |
|
|
|
public String getAuthorizationUri() { |
|
|
|
public String getAuthorizationUri() { |
|
|
|
return this.authorizationUri; |
|
|
|
return this.authorizationUri; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Returns the uri for the token endpoint. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return the uri for the token endpoint |
|
|
|
|
|
|
|
*/ |
|
|
|
public String getTokenUri() { |
|
|
|
public String getTokenUri() { |
|
|
|
return this.tokenUri; |
|
|
|
return this.tokenUri; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Returns the details of the {@link UserInfoEndpoint UserInfo Endpoint}. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return the {@link UserInfoEndpoint} |
|
|
|
|
|
|
|
*/ |
|
|
|
public UserInfoEndpoint getUserInfoEndpoint() { |
|
|
|
public UserInfoEndpoint getUserInfoEndpoint() { |
|
|
|
return this.userInfoEndpoint; |
|
|
|
return this.userInfoEndpoint; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Returns the uri for the JSON Web Key (JWK) Set endpoint. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return the uri for the JSON Web Key (JWK) Set endpoint |
|
|
|
|
|
|
|
*/ |
|
|
|
public String getJwkSetUri() { |
|
|
|
public String getJwkSetUri() { |
|
|
|
return this.jwkSetUri; |
|
|
|
return this.jwkSetUri; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Details of the UserInfo Endpoint. |
|
|
|
|
|
|
|
*/ |
|
|
|
public class UserInfoEndpoint { |
|
|
|
public class UserInfoEndpoint { |
|
|
|
private String uri; |
|
|
|
private String uri; |
|
|
|
private String userNameAttributeName; |
|
|
|
private String userNameAttributeName; |
|
|
|
@ -129,21 +201,40 @@ public final class ClientRegistration { |
|
|
|
private UserInfoEndpoint() { |
|
|
|
private UserInfoEndpoint() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Returns the uri for the user info endpoint. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return the uri for the user info endpoint |
|
|
|
|
|
|
|
*/ |
|
|
|
public String getUri() { |
|
|
|
public String getUri() { |
|
|
|
return this.uri; |
|
|
|
return this.uri; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Returns the attribute name used to access the user's name from the user info response. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return the attribute name used to access the user's name from the user info response |
|
|
|
|
|
|
|
*/ |
|
|
|
public String getUserNameAttributeName() { |
|
|
|
public String getUserNameAttributeName() { |
|
|
|
return this.userNameAttributeName; |
|
|
|
return this.userNameAttributeName; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Returns a new {@link Builder}, initialized with the provided registration identifier. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param registrationId the identifier for the registration |
|
|
|
|
|
|
|
* @return the {@link Builder} |
|
|
|
|
|
|
|
*/ |
|
|
|
public static Builder withRegistrationId(String registrationId) { |
|
|
|
public static Builder withRegistrationId(String registrationId) { |
|
|
|
Assert.hasText(registrationId, "registrationId cannot be empty"); |
|
|
|
Assert.hasText(registrationId, "registrationId cannot be empty"); |
|
|
|
return new Builder(registrationId); |
|
|
|
return new Builder(registrationId); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* A builder for {@link ClientRegistration}. |
|
|
|
|
|
|
|
*/ |
|
|
|
public static class Builder { |
|
|
|
public static class Builder { |
|
|
|
private String registrationId; |
|
|
|
private String registrationId; |
|
|
|
private String clientId; |
|
|
|
private String clientId; |
|
|
|
@ -163,31 +254,68 @@ public final class ClientRegistration { |
|
|
|
this.registrationId = registrationId; |
|
|
|
this.registrationId = registrationId; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Sets the client identifier. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param clientId the client identifier |
|
|
|
|
|
|
|
* @return the {@link Builder} |
|
|
|
|
|
|
|
*/ |
|
|
|
public Builder clientId(String clientId) { |
|
|
|
public Builder clientId(String clientId) { |
|
|
|
this.clientId = clientId; |
|
|
|
this.clientId = clientId; |
|
|
|
return this; |
|
|
|
return this; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Sets the client secret. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param clientSecret the client secret |
|
|
|
|
|
|
|
* @return the {@link Builder} |
|
|
|
|
|
|
|
*/ |
|
|
|
public Builder clientSecret(String clientSecret) { |
|
|
|
public Builder clientSecret(String clientSecret) { |
|
|
|
this.clientSecret = clientSecret; |
|
|
|
this.clientSecret = clientSecret; |
|
|
|
return this; |
|
|
|
return this; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Sets the {@link ClientAuthenticationMethod authentication method} used |
|
|
|
|
|
|
|
* when authenticating the client with the authorization server. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param clientAuthenticationMethod the authentication method used for the client |
|
|
|
|
|
|
|
* @return the {@link Builder} |
|
|
|
|
|
|
|
*/ |
|
|
|
public Builder clientAuthenticationMethod(ClientAuthenticationMethod clientAuthenticationMethod) { |
|
|
|
public Builder clientAuthenticationMethod(ClientAuthenticationMethod clientAuthenticationMethod) { |
|
|
|
this.clientAuthenticationMethod = clientAuthenticationMethod; |
|
|
|
this.clientAuthenticationMethod = clientAuthenticationMethod; |
|
|
|
return this; |
|
|
|
return this; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Sets the {@link AuthorizationGrantType authorization grant type} used for the client. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param authorizationGrantType the authorization grant type used for the client |
|
|
|
|
|
|
|
* @return the {@link Builder} |
|
|
|
|
|
|
|
*/ |
|
|
|
public Builder authorizationGrantType(AuthorizationGrantType authorizationGrantType) { |
|
|
|
public Builder authorizationGrantType(AuthorizationGrantType authorizationGrantType) { |
|
|
|
this.authorizationGrantType = authorizationGrantType; |
|
|
|
this.authorizationGrantType = authorizationGrantType; |
|
|
|
return this; |
|
|
|
return this; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Sets the uri (or uri template) for the redirection endpoint. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param redirectUriTemplate the uri for the redirection endpoint |
|
|
|
|
|
|
|
* @return the {@link Builder} |
|
|
|
|
|
|
|
*/ |
|
|
|
public Builder redirectUriTemplate(String redirectUriTemplate) { |
|
|
|
public Builder redirectUriTemplate(String redirectUriTemplate) { |
|
|
|
this.redirectUriTemplate = redirectUriTemplate; |
|
|
|
this.redirectUriTemplate = redirectUriTemplate; |
|
|
|
return this; |
|
|
|
return this; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Sets the scope(s) used for the client. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param scope the scope(s) used for the client |
|
|
|
|
|
|
|
* @return the {@link Builder} |
|
|
|
|
|
|
|
*/ |
|
|
|
public Builder scope(String... scope) { |
|
|
|
public Builder scope(String... scope) { |
|
|
|
if (scope != null && scope.length > 0) { |
|
|
|
if (scope != null && scope.length > 0) { |
|
|
|
this.scopes = Collections.unmodifiableSet( |
|
|
|
this.scopes = Collections.unmodifiableSet( |
|
|
|
@ -196,36 +324,77 @@ public final class ClientRegistration { |
|
|
|
return this; |
|
|
|
return this; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Sets the uri for the authorization endpoint. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param authorizationUri the uri for the authorization endpoint |
|
|
|
|
|
|
|
* @return the {@link Builder} |
|
|
|
|
|
|
|
*/ |
|
|
|
public Builder authorizationUri(String authorizationUri) { |
|
|
|
public Builder authorizationUri(String authorizationUri) { |
|
|
|
this.authorizationUri = authorizationUri; |
|
|
|
this.authorizationUri = authorizationUri; |
|
|
|
return this; |
|
|
|
return this; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Sets the uri for the token endpoint. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param tokenUri the uri for the token endpoint |
|
|
|
|
|
|
|
* @return the {@link Builder} |
|
|
|
|
|
|
|
*/ |
|
|
|
public Builder tokenUri(String tokenUri) { |
|
|
|
public Builder tokenUri(String tokenUri) { |
|
|
|
this.tokenUri = tokenUri; |
|
|
|
this.tokenUri = tokenUri; |
|
|
|
return this; |
|
|
|
return this; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Sets the uri for the user info endpoint. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param userInfoUri the uri for the user info endpoint |
|
|
|
|
|
|
|
* @return the {@link Builder} |
|
|
|
|
|
|
|
*/ |
|
|
|
public Builder userInfoUri(String userInfoUri) { |
|
|
|
public Builder userInfoUri(String userInfoUri) { |
|
|
|
this.userInfoUri = userInfoUri; |
|
|
|
this.userInfoUri = userInfoUri; |
|
|
|
return this; |
|
|
|
return this; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Sets the attribute name used to access the user's name from the user info response. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param userNameAttributeName the attribute name used to access the user's name from the user info response |
|
|
|
|
|
|
|
* @return the {@link Builder} |
|
|
|
|
|
|
|
*/ |
|
|
|
public Builder userNameAttributeName(String userNameAttributeName) { |
|
|
|
public Builder userNameAttributeName(String userNameAttributeName) { |
|
|
|
this.userNameAttributeName = userNameAttributeName; |
|
|
|
this.userNameAttributeName = userNameAttributeName; |
|
|
|
return this; |
|
|
|
return this; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Sets the uri for the JSON Web Key (JWK) Set endpoint. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param jwkSetUri the uri for the JSON Web Key (JWK) Set endpoint |
|
|
|
|
|
|
|
* @return the {@link Builder} |
|
|
|
|
|
|
|
*/ |
|
|
|
public Builder jwkSetUri(String jwkSetUri) { |
|
|
|
public Builder jwkSetUri(String jwkSetUri) { |
|
|
|
this.jwkSetUri = jwkSetUri; |
|
|
|
this.jwkSetUri = jwkSetUri; |
|
|
|
return this; |
|
|
|
return this; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Sets the logical name of the client or registration. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param clientName the client or registration name |
|
|
|
|
|
|
|
* @return the {@link Builder} |
|
|
|
|
|
|
|
*/ |
|
|
|
public Builder clientName(String clientName) { |
|
|
|
public Builder clientName(String clientName) { |
|
|
|
this.clientName = clientName; |
|
|
|
this.clientName = clientName; |
|
|
|
return this; |
|
|
|
return this; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Builds a new {@link ClientRegistration}. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return a {@link ClientRegistration} |
|
|
|
|
|
|
|
*/ |
|
|
|
public ClientRegistration build() { |
|
|
|
public ClientRegistration build() { |
|
|
|
Assert.notNull(this.authorizationGrantType, "authorizationGrantType cannot be null"); |
|
|
|
Assert.notNull(this.authorizationGrantType, "authorizationGrantType cannot be null"); |
|
|
|
if (AuthorizationGrantType.IMPLICIT.equals(this.authorizationGrantType)) { |
|
|
|
if (AuthorizationGrantType.IMPLICIT.equals(this.authorizationGrantType)) { |
|
|
|
|