From 9219125b14012880d1d624d7934797e5136308a9 Mon Sep 17 00:00:00 2001
From: Joe Grandja <10884212+jgrandja@users.noreply.github.com>
Date: Wed, 15 May 2024 15:25:35 -0400
Subject: [PATCH] Apply Spring formatting
Issue gh-1616
---
...ractOAuth2AuthorizationServerMetadata.java | 323 +++++----
...moryOAuth2AuthorizationConsentService.java | 16 +-
.../InMemoryOAuth2AuthorizationService.java | 59 +-
...JdbcOAuth2AuthorizationConsentService.java | 71 +-
.../JdbcOAuth2AuthorizationService.java | 190 +++---
.../authorization/OAuth2Authorization.java | 140 ++--
.../OAuth2AuthorizationCode.java | 7 +-
.../OAuth2AuthorizationConsent.java | 81 +--
.../OAuth2AuthorizationConsentService.java | 7 +-
.../OAuth2AuthorizationServerMetadata.java | 24 +-
...horizationServerMetadataClaimAccessor.java | 78 ++-
...AuthorizationServerMetadataClaimNames.java | 43 +-
.../OAuth2AuthorizationService.java | 16 +-
.../OAuth2TokenIntrospection.java | 98 +--
.../server/authorization/OAuth2TokenType.java | 10 +-
.../ClientSecretAuthenticationProvider.java | 49 +-
.../CodeVerifierAuthenticator.java | 45 +-
...ClientAssertionAuthenticationProvider.java | 46 +-
.../JwtClientAssertionDecoderFactory.java | 60 +-
.../OAuth2AccessTokenAuthenticationToken.java | 34 +-
.../OAuth2AuthenticationContext.java | 9 +-
.../OAuth2AuthenticationProviderUtils.java | 4 +-
...thorizationCodeAuthenticationProvider.java | 102 +--
...2AuthorizationCodeAuthenticationToken.java | 12 +-
.../OAuth2AuthorizationCodeGenerator.java | 11 +-
...ationCodeRequestAuthenticationContext.java | 17 +-
...ionCodeRequestAuthenticationException.java | 24 +-
...tionCodeRequestAuthenticationProvider.java | 179 ++---
...izationCodeRequestAuthenticationToken.java | 55 +-
...ionCodeRequestAuthenticationValidator.java | 101 +--
...orizationConsentAuthenticationContext.java | 28 +-
...rizationConsentAuthenticationProvider.java | 161 +++--
...thorizationConsentAuthenticationToken.java | 37 +-
...AuthorizationGrantAuthenticationToken.java | 18 +-
.../OAuth2ClientAuthenticationToken.java | 34 +-
...ientCredentialsAuthenticationProvider.java | 34 +-
...2ClientCredentialsAuthenticationToken.java | 17 +-
...rizationConsentAuthenticationProvider.java | 90 +--
...thorizationConsentAuthenticationToken.java | 23 +-
...rizationRequestAuthenticationProvider.java | 51 +-
...thorizationRequestAuthenticationToken.java | 42 +-
...Auth2DeviceCodeAuthenticationProvider.java | 95 +--
.../OAuth2DeviceCodeAuthenticationToken.java | 9 +-
...iceVerificationAuthenticationProvider.java | 68 +-
...DeviceVerificationAuthenticationToken.java | 20 +-
...th2RefreshTokenAuthenticationProvider.java | 54 +-
...OAuth2RefreshTokenAuthenticationToken.java | 12 +-
...enIntrospectionAuthenticationProvider.java | 44 +-
...TokenIntrospectionAuthenticationToken.java | 21 +-
...TokenRevocationAuthenticationProvider.java | 21 +-
...th2TokenRevocationAuthenticationToken.java | 24 +-
.../PublicClientAuthenticationProvider.java | 27 +-
.../InMemoryRegisteredClientRepository.java | 32 +-
.../JdbcRegisteredClientRepository.java | 153 +++--
.../client/RegisteredClient.java | 235 +++----
.../client/RegisteredClientRepository.java | 14 +-
...Auth2AuthorizationServerConfiguration.java | 9 +-
.../RegisterMissingBeanPostProcessor.java | 6 +-
.../configurers/AbstractOAuth2Configurer.java | 1 +
.../AuthorizationServerContextFilter.java | 26 +-
...OAuth2AuthorizationEndpointConfigurer.java | 175 ++---
.../OAuth2AuthorizationServerConfigurer.java | 189 +++---
...ationServerMetadataEndpointConfigurer.java | 45 +-
.../OAuth2ClientAuthenticationConfigurer.java | 120 ++--
.../configurers/OAuth2ConfigurerUtils.java | 42 +-
...DeviceAuthorizationEndpointConfigurer.java | 142 ++--
...2DeviceVerificationEndpointConfigurer.java | 183 +++---
.../OAuth2TokenEndpointConfigurer.java | 120 ++--
...2TokenIntrospectionEndpointConfigurer.java | 130 ++--
...uth2TokenRevocationEndpointConfigurer.java | 127 ++--
...cClientRegistrationEndpointConfigurer.java | 142 ++--
.../web/configurers/OidcConfigurer.java | 62 +-
.../OidcLogoutEndpointConfigurer.java | 106 +--
...oviderConfigurationEndpointConfigurer.java | 38 +-
.../OidcUserInfoEndpointConfigurer.java | 131 ++--
.../context/AuthorizationServerContext.java | 2 -
.../AuthorizationServerContextHolder.java | 9 +-
.../server/authorization/context/Context.java | 15 +-
...ionServerMetadataHttpMessageConverter.java | 110 ++--
...okenIntrospectionHttpMessageConverter.java | 54 +-
.../jackson2/JwsAlgorithmMixin.java | 1 +
...Auth2AuthorizationRequestDeserializer.java | 4 +-
.../oidc/OidcClientMetadataClaimAccessor.java | 98 +--
.../oidc/OidcClientMetadataClaimNames.java | 47 +-
.../oidc/OidcClientRegistration.java | 212 +++---
.../oidc/OidcProviderConfiguration.java | 92 +--
.../OidcProviderMetadataClaimAccessor.java | 26 +-
.../oidc/OidcProviderMetadataClaimNames.java | 13 +-
.../OidcAuthenticationProviderUtils.java | 4 +-
...ntConfigurationAuthenticationProvider.java | 45 +-
...entRegistrationAuthenticationProvider.java | 148 +++--
...ClientRegistrationAuthenticationToken.java | 20 +-
.../OidcLogoutAuthenticationProvider.java | 63 +-
.../OidcLogoutAuthenticationToken.java | 68 +-
.../OidcUserInfoAuthenticationContext.java | 15 +-
.../OidcUserInfoAuthenticationProvider.java | 64 +-
.../OidcUserInfoAuthenticationToken.java | 12 +-
...ClientOidcClientRegistrationConverter.java | 3 +-
...lientRegistrationHttpMessageConverter.java | 54 +-
...iderConfigurationHttpMessageConverter.java | 84 ++-
.../OidcUserInfoHttpMessageConverter.java | 57 +-
.../OidcClientRegistrationEndpointFilter.java | 100 +--
.../oidc/web/OidcLogoutEndpointFilter.java | 86 +--
...dcProviderConfigurationEndpointFilter.java | 75 ++-
.../oidc/web/OidcUserInfoEndpointFilter.java | 66 +-
...ntRegistrationAuthenticationConverter.java | 22 +-
.../OidcLogoutAuthenticationConverter.java | 38 +-
.../settings/AbstractSettings.java | 18 +-
.../settings/AuthorizationServerSettings.java | 88 ++-
.../settings/ClientSettings.java | 75 ++-
.../settings/ConfigurationSettingNames.java | 79 ++-
.../settings/OAuth2TokenFormat.java | 12 +-
.../authorization/settings/TokenSettings.java | 93 ++-
.../token/DefaultOAuth2TokenContext.java | 3 +-
.../token/DelegatingOAuth2TokenGenerator.java | 10 +-
.../token/JwtEncodingContext.java | 13 +-
.../authorization/token/JwtGenerator.java | 14 +-
.../token/OAuth2AccessTokenGenerator.java | 26 +-
.../token/OAuth2RefreshTokenGenerator.java | 5 +-
.../token/OAuth2TokenClaimAccessor.java | 42 +-
.../token/OAuth2TokenClaimNames.java | 20 +-
.../token/OAuth2TokenClaimsContext.java | 12 +-
.../token/OAuth2TokenClaimsSet.java | 45 +-
.../token/OAuth2TokenContext.java | 62 +-
.../token/OAuth2TokenCustomizer.java | 5 +-
.../token/OAuth2TokenGenerator.java | 14 +-
.../SpringAuthorizationServerVersion.java | 4 +
.../authorization/web/DefaultConsentPage.java | 12 +-
.../web/NimbusJwkSetEndpointFilter.java | 13 +-
.../OAuth2AuthorizationEndpointFilter.java | 188 +++---
...orizationServerMetadataEndpointFilter.java | 73 +-
.../web/OAuth2ClientAuthenticationFilter.java | 73 +-
...uth2DeviceAuthorizationEndpointFilter.java | 107 +--
...Auth2DeviceVerificationEndpointFilter.java | 132 ++--
.../web/OAuth2TokenEndpointFilter.java | 101 +--
...Auth2TokenIntrospectionEndpointFilter.java | 70 +-
.../OAuth2TokenRevocationEndpointFilter.java | 69 +-
...entSecretBasicAuthenticationConverter.java | 22 +-
...ientSecretPostAuthenticationConverter.java | 18 +-
.../DelegatingAuthenticationConverter.java | 14 +-
...lientAssertionAuthenticationConverter.java | 26 +-
...horizationCodeAuthenticationConverter.java | 32 +-
...ionCodeRequestAuthenticationConverter.java | 68 +-
...izationConsentAuthenticationConverter.java | 31 +-
...entCredentialsAuthenticationConverter.java | 23 +-
...izationConsentAuthenticationConverter.java | 47 +-
...izationRequestAuthenticationConverter.java | 19 +-
...uth2DeviceCodeAuthenticationConverter.java | 20 +-
...ceVerificationAuthenticationConverter.java | 28 +-
.../authentication/OAuth2EndpointUtils.java | 25 +-
...h2RefreshTokenAuthenticationConverter.java | 33 +-
...nIntrospectionAuthenticationConverter.java | 18 +-
...okenRevocationAuthenticationConverter.java | 11 +-
.../PublicClientAuthenticationConverter.java | 21 +-
.../security/oauth2/jose/TestJwks.java | 3 +-
.../security/oauth2/jwt/TestJwsHeaders.java | 1 +
.../oauth2/jwt/TestJwtClaimsSets.java | 1 +
...Auth2AuthorizationConsentServiceTests.java | 76 +--
...MemoryOAuth2AuthorizationServiceTests.java | 244 +++----
...Auth2AuthorizationConsentServiceTests.java | 102 +--
.../JdbcOAuth2AuthorizationServiceTests.java | 124 ++--
.../OAuth2AuthorizationConsentTests.java | 89 +--
...Auth2AuthorizationServerMetadataTests.java | 466 +++++++------
.../OAuth2AuthorizationTests.java | 84 +--
.../TestOAuth2Authorizations.java | 58 +-
...ientSecretAuthenticationProviderTests.java | 208 +++---
...tAssertionAuthenticationProviderTests.java | 168 ++---
...JwtClientAssertionDecoderFactoryTests.java | 48 +-
...h2AccessTokenAuthenticationTokenTests.java | 47 +-
...zationCodeAuthenticationProviderTests.java | 551 +++++++++-------
...orizationCodeAuthenticationTokenTests.java | 30 +-
...odeRequestAuthenticationProviderTests.java | 461 +++++++------
...onCodeRequestAuthenticationTokenTests.java | 47 +-
...tionConsentAuthenticationContextTests.java | 89 ++-
...ionConsentAuthenticationProviderTests.java | 492 +++++++-------
.../OAuth2ClientAuthenticationTokenTests.java | 29 +-
...redentialsAuthenticationProviderTests.java | 179 ++---
...ntCredentialsAuthenticationTokenTests.java | 15 +-
...ionConsentAuthenticationProviderTests.java | 53 +-
...ionRequestAuthenticationProviderTests.java | 66 +-
...DeviceCodeAuthenticationProviderTests.java | 32 +-
...rificationAuthenticationProviderTests.java | 32 +-
...freshTokenAuthenticationProviderTests.java | 395 +++++------
...2RefreshTokenAuthenticationTokenTests.java | 30 +-
...rospectionAuthenticationProviderTests.java | 118 ++--
...IntrospectionAuthenticationTokenTests.java | 37 +-
...RevocationAuthenticationProviderTests.java | 114 ++--
...kenRevocationAuthenticationTokenTests.java | 32 +-
...blicClientAuthenticationProviderTests.java | 182 ++---
...MemoryRegisteredClientRepositoryTests.java | 119 ++--
.../JdbcRegisteredClientRepositoryTests.java | 123 ++--
.../client/RegisteredClientTests.java | 433 ++++++------
.../client/TestRegisteredClients.java | 61 +-
...AuthorizationServerConfigurationTests.java | 8 +-
...RegisterMissingBeanPostProcessorTests.java | 2 +
.../web/configurers/JwkSetTests.java | 36 +-
.../OAuth2AuthorizationCodeGrantTests.java | 622 ++++++++++--------
...Auth2AuthorizationServerMetadataTests.java | 47 +-
.../OAuth2ClientCredentialsGrantTests.java | 187 +++---
.../OAuth2DeviceCodeGrantTests.java | 26 +-
.../OAuth2RefreshTokenGrantTests.java | 90 +--
.../OAuth2TokenIntrospectionTests.java | 133 ++--
.../OAuth2TokenRevocationTests.java | 89 ++-
.../OidcClientRegistrationTests.java | 248 +++----
.../OidcProviderConfigurationTests.java | 78 +--
.../annotation/web/configurers/OidcTests.java | 293 +++++----
.../web/configurers/OidcUserInfoTests.java | 84 ++-
.../TestAuthorizationServerContext.java | 9 +-
...rverMetadataHttpMessageConverterTests.java | 154 +++--
...ntrospectionHttpMessageConverterTests.java | 30 +-
...uthorizationServerJackson2ModuleTests.java | 2 +
.../oidc/OidcClientRegistrationTests.java | 187 +++---
.../oidc/OidcProviderConfigurationTests.java | 416 ++++++------
...figurationAuthenticationProviderTests.java | 287 ++++----
...gistrationAuthenticationProviderTests.java | 483 +++++++-------
...tRegistrationAuthenticationTokenTests.java | 22 +-
...OidcLogoutAuthenticationProviderTests.java | 560 ++++++++--------
.../OidcLogoutAuthenticationTokenTests.java | 55 +-
...dcUserInfoAuthenticationProviderTests.java | 91 ++-
.../OidcUserInfoAuthenticationTokenTests.java | 6 +-
...RegistrationHttpMessageConverterTests.java | 62 +-
...onfigurationHttpMessageConverterTests.java | 122 ++--
...OidcUserInfoHttpMessageConverterTests.java | 76 ++-
...ClientRegistrationEndpointFilterTests.java | 159 ++---
.../web/OidcLogoutEndpointFilterTests.java | 112 ++--
...viderConfigurationEndpointFilterTests.java | 66 +-
.../web/OidcUserInfoEndpointFilterTests.java | 94 +--
.../AuthorizationServerSettingsTests.java | 69 +-
.../settings/ClientSettingsTests.java | 22 +-
.../settings/TokenSettingsTests.java | 90 ++-
.../authorization/test/SpringTestContext.java | 25 +-
.../DelegatingOAuth2TokenGeneratorTests.java | 20 +-
.../token/JwtEncodingContextTests.java | 67 +-
.../token/JwtGeneratorTests.java | 147 +++--
.../OAuth2AccessTokenGeneratorTests.java | 42 +-
.../OAuth2RefreshTokenGeneratorTests.java | 4 +-
.../token/OAuth2TokenClaimsContextTests.java | 28 +-
.../token/OAuth2TokenClaimsSetTests.java | 13 +-
.../web/NimbusJwkSetEndpointFilterTests.java | 14 +-
...Auth2AuthorizationEndpointFilterTests.java | 363 +++++-----
...tionServerMetadataEndpointFilterTests.java | 60 +-
...OAuth2ClientAuthenticationFilterTests.java | 65 +-
...eviceAuthorizationEndpointFilterTests.java | 60 +-
...DeviceVerificationEndpointFilterTests.java | 76 ++-
.../web/OAuth2TokenEndpointFilterTests.java | 269 ++++----
...TokenIntrospectionEndpointFilterTests.java | 148 ++---
...th2TokenRevocationEndpointFilterTests.java | 88 ++-
...cretBasicAuthenticationConverterTests.java | 57 +-
...ecretPostAuthenticationConverterTests.java | 42 +-
...AssertionAuthenticationConverterTests.java | 24 +-
...onConsentAuthenticationConverterTests.java | 26 +-
...onRequestAuthenticationConverterTests.java | 16 +-
...eviceCodeAuthenticationConverterTests.java | 13 +-
...ificationAuthenticationConverterTests.java | 19 +-
...licClientAuthenticationConverterTests.java | 44 +-
255 files changed, 11231 insertions(+), 9765 deletions(-)
diff --git a/oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/AbstractOAuth2AuthorizationServerMetadata.java b/oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/AbstractOAuth2AuthorizationServerMetadata.java
index d7215df0..09168646 100644
--- a/oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/AbstractOAuth2AuthorizationServerMetadata.java
+++ b/oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/AbstractOAuth2AuthorizationServerMetadata.java
@@ -29,19 +29,27 @@ import org.springframework.security.oauth2.server.authorization.util.SpringAutho
import org.springframework.util.Assert;
/**
- * A base representation of OAuth 2.0 Authorization Server metadata,
- * returned by an endpoint defined in OAuth 2.0 Authorization Server Metadata and OpenID Connect Discovery 1.0.
- * The metadata endpoint returns a set of claims an Authorization Server describes about its configuration.
+ * A base representation of OAuth 2.0 Authorization Server metadata, returned by an
+ * endpoint defined in OAuth 2.0 Authorization Server Metadata and OpenID Connect
+ * Discovery 1.0. The metadata endpoint returns a set of claims an Authorization Server
+ * describes about its configuration.
*
* @author Daniel Garnier-Moiroux
* @see OAuth2AuthorizationServerMetadataClaimAccessor
* @since 0.1.1
- * @see 3.2. Authorization Server Metadata Response
- * @see 4.2. OpenID Provider Configuration Response
- * @see 4. Device Authorization Grant Metadata
+ * @see 3.2.
+ * Authorization Server Metadata Response
+ * @see 4.2.
+ * OpenID Provider Configuration Response
+ * @see 4.
+ * Device Authorization Grant Metadata
*/
-public abstract class AbstractOAuth2AuthorizationServerMetadata implements OAuth2AuthorizationServerMetadataClaimAccessor, Serializable {
+public abstract class AbstractOAuth2AuthorizationServerMetadata
+ implements OAuth2AuthorizationServerMetadataClaimAccessor, Serializable {
+
private static final long serialVersionUID = SpringAuthorizationServerVersion.SERIAL_VERSION_UID;
+
private final Map claims;
protected AbstractOAuth2AuthorizationServerMetadata(Map claims) {
@@ -51,7 +59,6 @@ public abstract class AbstractOAuth2AuthorizationServerMetadata implements OAuth
/**
* Returns the metadata as claims.
- *
* @return a {@code Map} of the metadata as claims
*/
@Override
@@ -63,6 +70,7 @@ public abstract class AbstractOAuth2AuthorizationServerMetadata implements OAuth
* A builder for subclasses of {@link AbstractOAuth2AuthorizationServerMetadata}.
*/
protected static abstract class AbstractBuilder> {
+
private final Map claims = new LinkedHashMap<>();
protected AbstractBuilder() {
@@ -74,13 +82,14 @@ public abstract class AbstractOAuth2AuthorizationServerMetadata implements OAuth
@SuppressWarnings("unchecked")
protected final B getThis() {
- // avoid unchecked casts in subclasses by using "getThis()" instead of "(B) this"
+ // avoid unchecked casts in subclasses by using "getThis()" instead of "(B)
+ // this"
return (B) this;
}
/**
- * Use this {@code issuer} in the resulting {@link AbstractOAuth2AuthorizationServerMetadata}, REQUIRED.
- *
+ * Use this {@code issuer} in the resulting
+ * {@link AbstractOAuth2AuthorizationServerMetadata}, REQUIRED.
* @param issuer the {@code URL} of the Authorization Server's Issuer Identifier
* @return the {@link AbstractBuilder} for further configuration
*/
@@ -89,9 +98,10 @@ public abstract class AbstractOAuth2AuthorizationServerMetadata implements OAuth
}
/**
- * Use this {@code authorization_endpoint} in the resulting {@link AbstractOAuth2AuthorizationServerMetadata}, REQUIRED.
- *
- * @param authorizationEndpoint the {@code URL} of the OAuth 2.0 Authorization Endpoint
+ * Use this {@code authorization_endpoint} in the resulting
+ * {@link AbstractOAuth2AuthorizationServerMetadata}, REQUIRED.
+ * @param authorizationEndpoint the {@code URL} of the OAuth 2.0 Authorization
+ * Endpoint
* @return the {@link AbstractBuilder} for further configuration
*/
public B authorizationEndpoint(String authorizationEndpoint) {
@@ -99,19 +109,21 @@ public abstract class AbstractOAuth2AuthorizationServerMetadata implements OAuth
}
/**
- * Use this {@code device_authorization_endpoint} in the resulting {@link AbstractOAuth2AuthorizationServerMetadata}, OPTIONAL.
- *
- * @param deviceAuthorizationEndpoint the {@code URL} of the OAuth 2.0 Device Authorization Endpoint
+ * Use this {@code device_authorization_endpoint} in the resulting
+ * {@link AbstractOAuth2AuthorizationServerMetadata}, OPTIONAL.
+ * @param deviceAuthorizationEndpoint the {@code URL} of the OAuth 2.0 Device
+ * Authorization Endpoint
* @return the {@link AbstractBuilder} for further configuration
* @since 1.1
*/
public B deviceAuthorizationEndpoint(String deviceAuthorizationEndpoint) {
- return claim(OAuth2AuthorizationServerMetadataClaimNames.DEVICE_AUTHORIZATION_ENDPOINT, deviceAuthorizationEndpoint);
+ return claim(OAuth2AuthorizationServerMetadataClaimNames.DEVICE_AUTHORIZATION_ENDPOINT,
+ deviceAuthorizationEndpoint);
}
/**
- * Use this {@code token_endpoint} in the resulting {@link AbstractOAuth2AuthorizationServerMetadata}, REQUIRED.
- *
+ * Use this {@code token_endpoint} in the resulting
+ * {@link AbstractOAuth2AuthorizationServerMetadata}, REQUIRED.
* @param tokenEndpoint the {@code URL} of the OAuth 2.0 Token Endpoint
* @return the {@link AbstractBuilder} for further configuration
*/
@@ -120,31 +132,35 @@ public abstract class AbstractOAuth2AuthorizationServerMetadata implements OAuth
}
/**
- * Add this client authentication method to the collection of {@code token_endpoint_auth_methods_supported}
- * in the resulting {@link AbstractOAuth2AuthorizationServerMetadata}, OPTIONAL.
- *
- * @param authenticationMethod the client authentication method supported by the OAuth 2.0 Token Endpoint
+ * Add this client authentication method to the collection of
+ * {@code token_endpoint_auth_methods_supported} in the resulting
+ * {@link AbstractOAuth2AuthorizationServerMetadata}, OPTIONAL.
+ * @param authenticationMethod the client authentication method supported by the
+ * OAuth 2.0 Token Endpoint
* @return the {@link AbstractBuilder} for further configuration
*/
public B tokenEndpointAuthenticationMethod(String authenticationMethod) {
- addClaimToClaimList(OAuth2AuthorizationServerMetadataClaimNames.TOKEN_ENDPOINT_AUTH_METHODS_SUPPORTED, authenticationMethod);
+ addClaimToClaimList(OAuth2AuthorizationServerMetadataClaimNames.TOKEN_ENDPOINT_AUTH_METHODS_SUPPORTED,
+ authenticationMethod);
return getThis();
}
/**
- * A {@code Consumer} of the client authentication method(s) allowing the ability to add, replace, or remove.
- *
- * @param authenticationMethodsConsumer a {@code Consumer} of the client authentication method(s) supported by the OAuth 2.0 Token Endpoint
+ * A {@code Consumer} of the client authentication method(s) allowing the ability
+ * to add, replace, or remove.
+ * @param authenticationMethodsConsumer a {@code Consumer} of the client
+ * authentication method(s) supported by the OAuth 2.0 Token Endpoint
* @return the {@link AbstractBuilder} for further configuration
*/
public B tokenEndpointAuthenticationMethods(Consumer> authenticationMethodsConsumer) {
- acceptClaimValues(OAuth2AuthorizationServerMetadataClaimNames.TOKEN_ENDPOINT_AUTH_METHODS_SUPPORTED, authenticationMethodsConsumer);
+ acceptClaimValues(OAuth2AuthorizationServerMetadataClaimNames.TOKEN_ENDPOINT_AUTH_METHODS_SUPPORTED,
+ authenticationMethodsConsumer);
return getThis();
}
/**
- * Use this {@code jwks_uri} in the resulting {@link AbstractOAuth2AuthorizationServerMetadata}, OPTIONAL.
- *
+ * Use this {@code jwks_uri} in the resulting
+ * {@link AbstractOAuth2AuthorizationServerMetadata}, OPTIONAL.
* @param jwkSetUrl the {@code URL} of the JSON Web Key Set
* @return the {@link AbstractBuilder} for further configuration
*/
@@ -154,8 +170,8 @@ public abstract class AbstractOAuth2AuthorizationServerMetadata implements OAuth
/**
* Add this OAuth 2.0 {@code scope} to the collection of {@code scopes_supported}
- * in the resulting {@link AbstractOAuth2AuthorizationServerMetadata}, RECOMMENDED.
- *
+ * in the resulting {@link AbstractOAuth2AuthorizationServerMetadata},
+ * RECOMMENDED.
* @param scope the OAuth 2.0 {@code scope} value supported
* @return the {@link AbstractBuilder} for further configuration
*/
@@ -165,9 +181,10 @@ public abstract class AbstractOAuth2AuthorizationServerMetadata implements OAuth
}
/**
- * A {@code Consumer} of the OAuth 2.0 {@code scope} values supported allowing the ability to add, replace, or remove.
- *
- * @param scopesConsumer a {@code Consumer} of the OAuth 2.0 {@code scope} values supported
+ * A {@code Consumer} of the OAuth 2.0 {@code scope} values supported allowing the
+ * ability to add, replace, or remove.
+ * @param scopesConsumer a {@code Consumer} of the OAuth 2.0 {@code scope} values
+ * supported
* @return the {@link AbstractBuilder} for further configuration
*/
public B scopes(Consumer> scopesConsumer) {
@@ -176,9 +193,9 @@ public abstract class AbstractOAuth2AuthorizationServerMetadata implements OAuth
}
/**
- * Add this OAuth 2.0 {@code response_type} to the collection of {@code response_types_supported}
- * in the resulting {@link AbstractOAuth2AuthorizationServerMetadata}, REQUIRED.
- *
+ * Add this OAuth 2.0 {@code response_type} to the collection of
+ * {@code response_types_supported} in the resulting
+ * {@link AbstractOAuth2AuthorizationServerMetadata}, REQUIRED.
* @param responseType the OAuth 2.0 {@code response_type} value supported
* @return the {@link AbstractBuilder} for further configuration
*/
@@ -188,20 +205,22 @@ public abstract class AbstractOAuth2AuthorizationServerMetadata implements OAuth
}
/**
- * A {@code Consumer} of the OAuth 2.0 {@code response_type} values supported allowing the ability to add, replace, or remove.
- *
- * @param responseTypesConsumer a {@code Consumer} of the OAuth 2.0 {@code response_type} values supported
+ * A {@code Consumer} of the OAuth 2.0 {@code response_type} values supported
+ * allowing the ability to add, replace, or remove.
+ * @param responseTypesConsumer a {@code Consumer} of the OAuth 2.0
+ * {@code response_type} values supported
* @return the {@link AbstractBuilder} for further configuration
*/
public B responseTypes(Consumer> responseTypesConsumer) {
- acceptClaimValues(OAuth2AuthorizationServerMetadataClaimNames.RESPONSE_TYPES_SUPPORTED, responseTypesConsumer);
+ acceptClaimValues(OAuth2AuthorizationServerMetadataClaimNames.RESPONSE_TYPES_SUPPORTED,
+ responseTypesConsumer);
return getThis();
}
/**
- * Add this OAuth 2.0 {@code grant_type} to the collection of {@code grant_types_supported}
- * in the resulting {@link AbstractOAuth2AuthorizationServerMetadata}, OPTIONAL.
- *
+ * Add this OAuth 2.0 {@code grant_type} to the collection of
+ * {@code grant_types_supported} in the resulting
+ * {@link AbstractOAuth2AuthorizationServerMetadata}, OPTIONAL.
* @param grantType the OAuth 2.0 {@code grant_type} value supported
* @return the {@link AbstractBuilder} for further configuration
*/
@@ -211,9 +230,10 @@ public abstract class AbstractOAuth2AuthorizationServerMetadata implements OAuth
}
/**
- * A {@code Consumer} of the OAuth 2.0 {@code grant_type} values supported allowing the ability to add, replace, or remove.
- *
- * @param grantTypesConsumer a {@code Consumer} of the OAuth 2.0 {@code grant_type} values supported
+ * A {@code Consumer} of the OAuth 2.0 {@code grant_type} values supported
+ * allowing the ability to add, replace, or remove.
+ * @param grantTypesConsumer a {@code Consumer} of the OAuth 2.0
+ * {@code grant_type} values supported
* @return the {@link AbstractBuilder} for further configuration
*/
public B grantTypes(Consumer> grantTypesConsumer) {
@@ -222,9 +242,10 @@ public abstract class AbstractOAuth2AuthorizationServerMetadata implements OAuth
}
/**
- * Use this {@code revocation_endpoint} in the resulting {@link AbstractOAuth2AuthorizationServerMetadata}, OPTIONAL.
- *
- * @param tokenRevocationEndpoint the {@code URL} of the OAuth 2.0 Token Revocation Endpoint
+ * Use this {@code revocation_endpoint} in the resulting
+ * {@link AbstractOAuth2AuthorizationServerMetadata}, OPTIONAL.
+ * @param tokenRevocationEndpoint the {@code URL} of the OAuth 2.0 Token
+ * Revocation Endpoint
* @return the {@link AbstractBuilder} for further configuration
*/
public B tokenRevocationEndpoint(String tokenRevocationEndpoint) {
@@ -232,65 +253,78 @@ public abstract class AbstractOAuth2AuthorizationServerMetadata implements OAuth
}
/**
- * Add this client authentication method to the collection of {@code revocation_endpoint_auth_methods_supported}
- * in the resulting {@link AbstractOAuth2AuthorizationServerMetadata}, OPTIONAL.
- *
- * @param authenticationMethod the client authentication method supported by the OAuth 2.0 Token Revocation Endpoint
+ * Add this client authentication method to the collection of
+ * {@code revocation_endpoint_auth_methods_supported} in the resulting
+ * {@link AbstractOAuth2AuthorizationServerMetadata}, OPTIONAL.
+ * @param authenticationMethod the client authentication method supported by the
+ * OAuth 2.0 Token Revocation Endpoint
* @return the {@link AbstractBuilder} for further configuration
*/
public B tokenRevocationEndpointAuthenticationMethod(String authenticationMethod) {
- addClaimToClaimList(OAuth2AuthorizationServerMetadataClaimNames.REVOCATION_ENDPOINT_AUTH_METHODS_SUPPORTED, authenticationMethod);
+ addClaimToClaimList(OAuth2AuthorizationServerMetadataClaimNames.REVOCATION_ENDPOINT_AUTH_METHODS_SUPPORTED,
+ authenticationMethod);
return getThis();
}
/**
- * A {@code Consumer} of the client authentication method(s) allowing the ability to add, replace, or remove.
- *
- * @param authenticationMethodsConsumer a {@code Consumer} of the client authentication method(s) supported by the OAuth 2.0 Token Revocation Endpoint
+ * A {@code Consumer} of the client authentication method(s) allowing the ability
+ * to add, replace, or remove.
+ * @param authenticationMethodsConsumer a {@code Consumer} of the client
+ * authentication method(s) supported by the OAuth 2.0 Token Revocation Endpoint
* @return the {@link AbstractBuilder} for further configuration
*/
public B tokenRevocationEndpointAuthenticationMethods(Consumer> authenticationMethodsConsumer) {
- acceptClaimValues(OAuth2AuthorizationServerMetadataClaimNames.REVOCATION_ENDPOINT_AUTH_METHODS_SUPPORTED, authenticationMethodsConsumer);
+ acceptClaimValues(OAuth2AuthorizationServerMetadataClaimNames.REVOCATION_ENDPOINT_AUTH_METHODS_SUPPORTED,
+ authenticationMethodsConsumer);
return getThis();
}
/**
- * Use this {@code introspection_endpoint} in the resulting {@link AbstractOAuth2AuthorizationServerMetadata}, OPTIONAL.
- *
- * @param tokenIntrospectionEndpoint the {@code URL} of the OAuth 2.0 Token Introspection Endpoint
+ * Use this {@code introspection_endpoint} in the resulting
+ * {@link AbstractOAuth2AuthorizationServerMetadata}, OPTIONAL.
+ * @param tokenIntrospectionEndpoint the {@code URL} of the OAuth 2.0 Token
+ * Introspection Endpoint
* @return the {@link AbstractBuilder} for further configuration
*/
public B tokenIntrospectionEndpoint(String tokenIntrospectionEndpoint) {
- return claim(OAuth2AuthorizationServerMetadataClaimNames.INTROSPECTION_ENDPOINT, tokenIntrospectionEndpoint);
+ return claim(OAuth2AuthorizationServerMetadataClaimNames.INTROSPECTION_ENDPOINT,
+ tokenIntrospectionEndpoint);
}
/**
- * Add this client authentication method to the collection of {@code introspection_endpoint_auth_methods_supported}
- * in the resulting {@link AbstractOAuth2AuthorizationServerMetadata}, OPTIONAL.
- *
- * @param authenticationMethod the client authentication method supported by the OAuth 2.0 Token Introspection Endpoint
+ * Add this client authentication method to the collection of
+ * {@code introspection_endpoint_auth_methods_supported} in the resulting
+ * {@link AbstractOAuth2AuthorizationServerMetadata}, OPTIONAL.
+ * @param authenticationMethod the client authentication method supported by the
+ * OAuth 2.0 Token Introspection Endpoint
* @return the {@link AbstractBuilder} for further configuration
*/
public B tokenIntrospectionEndpointAuthenticationMethod(String authenticationMethod) {
- addClaimToClaimList(OAuth2AuthorizationServerMetadataClaimNames.INTROSPECTION_ENDPOINT_AUTH_METHODS_SUPPORTED, authenticationMethod);
+ addClaimToClaimList(
+ OAuth2AuthorizationServerMetadataClaimNames.INTROSPECTION_ENDPOINT_AUTH_METHODS_SUPPORTED,
+ authenticationMethod);
return getThis();
}
/**
- * A {@code Consumer} of the client authentication method(s) allowing the ability to add, replace, or remove.
- *
- * @param authenticationMethodsConsumer a {@code Consumer} of the client authentication method(s) supported by the OAuth 2.0 Token Introspection Endpoint
+ * A {@code Consumer} of the client authentication method(s) allowing the ability
+ * to add, replace, or remove.
+ * @param authenticationMethodsConsumer a {@code Consumer} of the client
+ * authentication method(s) supported by the OAuth 2.0 Token Introspection
+ * Endpoint
* @return the {@link AbstractBuilder} for further configuration
*/
public B tokenIntrospectionEndpointAuthenticationMethods(Consumer> authenticationMethodsConsumer) {
- acceptClaimValues(OAuth2AuthorizationServerMetadataClaimNames.INTROSPECTION_ENDPOINT_AUTH_METHODS_SUPPORTED, authenticationMethodsConsumer);
+ acceptClaimValues(OAuth2AuthorizationServerMetadataClaimNames.INTROSPECTION_ENDPOINT_AUTH_METHODS_SUPPORTED,
+ authenticationMethodsConsumer);
return getThis();
}
/**
- * Use this {@code registration_endpoint} in the resulting {@link AbstractOAuth2AuthorizationServerMetadata}, OPTIONAL.
- *
- * @param clientRegistrationEndpoint the {@code URL} of the OAuth 2.0 Dynamic Client Registration Endpoint
+ * Use this {@code registration_endpoint} in the resulting
+ * {@link AbstractOAuth2AuthorizationServerMetadata}, OPTIONAL.
+ * @param clientRegistrationEndpoint the {@code URL} of the OAuth 2.0 Dynamic
+ * Client Registration Endpoint
* @return the {@link AbstractBuilder} for further configuration
* @since 0.4.0
*/
@@ -299,31 +333,35 @@ public abstract class AbstractOAuth2AuthorizationServerMetadata implements OAuth
}
/**
- * Add this Proof Key for Code Exchange (PKCE) {@code code_challenge_method} to the collection of {@code code_challenge_methods_supported}
- * in the resulting {@link AbstractOAuth2AuthorizationServerMetadata}, OPTIONAL.
- *
+ * Add this Proof Key for Code Exchange (PKCE) {@code code_challenge_method} to
+ * the collection of {@code code_challenge_methods_supported} in the resulting
+ * {@link AbstractOAuth2AuthorizationServerMetadata}, OPTIONAL.
* @param codeChallengeMethod the {@code code_challenge_method} value supported
* @return the {@link AbstractBuilder} for further configuration
*/
public B codeChallengeMethod(String codeChallengeMethod) {
- addClaimToClaimList(OAuth2AuthorizationServerMetadataClaimNames.CODE_CHALLENGE_METHODS_SUPPORTED, codeChallengeMethod);
+ addClaimToClaimList(OAuth2AuthorizationServerMetadataClaimNames.CODE_CHALLENGE_METHODS_SUPPORTED,
+ codeChallengeMethod);
return getThis();
}
/**
- * A {@code Consumer} of the Proof Key for Code Exchange (PKCE) {@code code_challenge_method} values supported allowing the ability to add, replace, or remove.
- *
- * @param codeChallengeMethodsConsumer a {@code Consumer} of the {@code code_challenge_method} values supported
+ * A {@code Consumer} of the Proof Key for Code Exchange (PKCE)
+ * {@code code_challenge_method} values supported allowing the ability to add,
+ * replace, or remove.
+ * @param codeChallengeMethodsConsumer a {@code Consumer} of the
+ * {@code code_challenge_method} values supported
* @return the {@link AbstractBuilder} for further configuration
*/
public B codeChallengeMethods(Consumer> codeChallengeMethodsConsumer) {
- acceptClaimValues(OAuth2AuthorizationServerMetadataClaimNames.CODE_CHALLENGE_METHODS_SUPPORTED, codeChallengeMethodsConsumer);
+ acceptClaimValues(OAuth2AuthorizationServerMetadataClaimNames.CODE_CHALLENGE_METHODS_SUPPORTED,
+ codeChallengeMethodsConsumer);
return getThis();
}
/**
- * Use this claim in the resulting {@link AbstractOAuth2AuthorizationServerMetadata}.
- *
+ * Use this claim in the resulting
+ * {@link AbstractOAuth2AuthorizationServerMetadata}.
* @param name the claim name
* @param value the claim value
* @return the {@link AbstractBuilder} for further configuration
@@ -338,7 +376,6 @@ public abstract class AbstractOAuth2AuthorizationServerMetadata implements OAuth
/**
* Provides access to every {@link #claim(String, Object)} declared so far with
* the possibility to add, replace, or remove.
- *
* @param claimsConsumer a {@code Consumer} of the claims
* @return the {@link AbstractBuilder} for further configurations
*/
@@ -349,59 +386,105 @@ public abstract class AbstractOAuth2AuthorizationServerMetadata implements OAuth
/**
* Creates the {@link AbstractOAuth2AuthorizationServerMetadata}.
- *
* @return the {@link AbstractOAuth2AuthorizationServerMetadata}
*/
public abstract T build();
protected void validate() {
- Assert.notNull(getClaims().get(OAuth2AuthorizationServerMetadataClaimNames.ISSUER), "issuer cannot be null");
- validateURL(getClaims().get(OAuth2AuthorizationServerMetadataClaimNames.ISSUER), "issuer must be a valid URL");
- Assert.notNull(getClaims().get(OAuth2AuthorizationServerMetadataClaimNames.AUTHORIZATION_ENDPOINT), "authorizationEndpoint cannot be null");
- validateURL(getClaims().get(OAuth2AuthorizationServerMetadataClaimNames.AUTHORIZATION_ENDPOINT), "authorizationEndpoint must be a valid URL");
+ Assert.notNull(getClaims().get(OAuth2AuthorizationServerMetadataClaimNames.ISSUER),
+ "issuer cannot be null");
+ validateURL(getClaims().get(OAuth2AuthorizationServerMetadataClaimNames.ISSUER),
+ "issuer must be a valid URL");
+ Assert.notNull(getClaims().get(OAuth2AuthorizationServerMetadataClaimNames.AUTHORIZATION_ENDPOINT),
+ "authorizationEndpoint cannot be null");
+ validateURL(getClaims().get(OAuth2AuthorizationServerMetadataClaimNames.AUTHORIZATION_ENDPOINT),
+ "authorizationEndpoint must be a valid URL");
if (getClaims().get(OAuth2AuthorizationServerMetadataClaimNames.DEVICE_AUTHORIZATION_ENDPOINT) != null) {
- validateURL(getClaims().get(OAuth2AuthorizationServerMetadataClaimNames.DEVICE_AUTHORIZATION_ENDPOINT), "deviceAuthorizationEndpoint must be a valid URL");
+ validateURL(getClaims().get(OAuth2AuthorizationServerMetadataClaimNames.DEVICE_AUTHORIZATION_ENDPOINT),
+ "deviceAuthorizationEndpoint must be a valid URL");
}
- Assert.notNull(getClaims().get(OAuth2AuthorizationServerMetadataClaimNames.TOKEN_ENDPOINT), "tokenEndpoint cannot be null");
- validateURL(getClaims().get(OAuth2AuthorizationServerMetadataClaimNames.TOKEN_ENDPOINT), "tokenEndpoint must be a valid URL");
- if (getClaims().get(OAuth2AuthorizationServerMetadataClaimNames.TOKEN_ENDPOINT_AUTH_METHODS_SUPPORTED) != null) {
- Assert.isInstanceOf(List.class, getClaims().get(OAuth2AuthorizationServerMetadataClaimNames.TOKEN_ENDPOINT_AUTH_METHODS_SUPPORTED), "tokenEndpointAuthenticationMethods must be of type List");
- Assert.notEmpty((List>) getClaims().get(OAuth2AuthorizationServerMetadataClaimNames.TOKEN_ENDPOINT_AUTH_METHODS_SUPPORTED), "tokenEndpointAuthenticationMethods cannot be empty");
+ Assert.notNull(getClaims().get(OAuth2AuthorizationServerMetadataClaimNames.TOKEN_ENDPOINT),
+ "tokenEndpoint cannot be null");
+ validateURL(getClaims().get(OAuth2AuthorizationServerMetadataClaimNames.TOKEN_ENDPOINT),
+ "tokenEndpoint must be a valid URL");
+ if (getClaims()
+ .get(OAuth2AuthorizationServerMetadataClaimNames.TOKEN_ENDPOINT_AUTH_METHODS_SUPPORTED) != null) {
+ Assert.isInstanceOf(List.class,
+ getClaims()
+ .get(OAuth2AuthorizationServerMetadataClaimNames.TOKEN_ENDPOINT_AUTH_METHODS_SUPPORTED),
+ "tokenEndpointAuthenticationMethods must be of type List");
+ Assert.notEmpty(
+ (List>) getClaims()
+ .get(OAuth2AuthorizationServerMetadataClaimNames.TOKEN_ENDPOINT_AUTH_METHODS_SUPPORTED),
+ "tokenEndpointAuthenticationMethods cannot be empty");
}
if (getClaims().get(OAuth2AuthorizationServerMetadataClaimNames.JWKS_URI) != null) {
- validateURL(getClaims().get(OAuth2AuthorizationServerMetadataClaimNames.JWKS_URI), "jwksUri must be a valid URL");
+ validateURL(getClaims().get(OAuth2AuthorizationServerMetadataClaimNames.JWKS_URI),
+ "jwksUri must be a valid URL");
}
if (getClaims().get(OAuth2AuthorizationServerMetadataClaimNames.SCOPES_SUPPORTED) != null) {
- Assert.isInstanceOf(List.class, getClaims().get(OAuth2AuthorizationServerMetadataClaimNames.SCOPES_SUPPORTED), "scopes must be of type List");
- Assert.notEmpty((List>) getClaims().get(OAuth2AuthorizationServerMetadataClaimNames.SCOPES_SUPPORTED), "scopes cannot be empty");
+ Assert.isInstanceOf(List.class,
+ getClaims().get(OAuth2AuthorizationServerMetadataClaimNames.SCOPES_SUPPORTED),
+ "scopes must be of type List");
+ Assert.notEmpty((List>) getClaims().get(OAuth2AuthorizationServerMetadataClaimNames.SCOPES_SUPPORTED),
+ "scopes cannot be empty");
}
- Assert.notNull(getClaims().get(OAuth2AuthorizationServerMetadataClaimNames.RESPONSE_TYPES_SUPPORTED), "responseTypes cannot be null");
- Assert.isInstanceOf(List.class, getClaims().get(OAuth2AuthorizationServerMetadataClaimNames.RESPONSE_TYPES_SUPPORTED), "responseTypes must be of type List");
- Assert.notEmpty((List>) getClaims().get(OAuth2AuthorizationServerMetadataClaimNames.RESPONSE_TYPES_SUPPORTED), "responseTypes cannot be empty");
+ Assert.notNull(getClaims().get(OAuth2AuthorizationServerMetadataClaimNames.RESPONSE_TYPES_SUPPORTED),
+ "responseTypes cannot be null");
+ Assert.isInstanceOf(List.class,
+ getClaims().get(OAuth2AuthorizationServerMetadataClaimNames.RESPONSE_TYPES_SUPPORTED),
+ "responseTypes must be of type List");
+ Assert.notEmpty(
+ (List>) getClaims().get(OAuth2AuthorizationServerMetadataClaimNames.RESPONSE_TYPES_SUPPORTED),
+ "responseTypes cannot be empty");
if (getClaims().get(OAuth2AuthorizationServerMetadataClaimNames.GRANT_TYPES_SUPPORTED) != null) {
- Assert.isInstanceOf(List.class, getClaims().get(OAuth2AuthorizationServerMetadataClaimNames.GRANT_TYPES_SUPPORTED), "grantTypes must be of type List");
- Assert.notEmpty((List>) getClaims().get(OAuth2AuthorizationServerMetadataClaimNames.GRANT_TYPES_SUPPORTED), "grantTypes cannot be empty");
+ Assert.isInstanceOf(List.class,
+ getClaims().get(OAuth2AuthorizationServerMetadataClaimNames.GRANT_TYPES_SUPPORTED),
+ "grantTypes must be of type List");
+ Assert.notEmpty(
+ (List>) getClaims().get(OAuth2AuthorizationServerMetadataClaimNames.GRANT_TYPES_SUPPORTED),
+ "grantTypes cannot be empty");
}
if (getClaims().get(OAuth2AuthorizationServerMetadataClaimNames.REVOCATION_ENDPOINT) != null) {
- validateURL(getClaims().get(OAuth2AuthorizationServerMetadataClaimNames.REVOCATION_ENDPOINT), "tokenRevocationEndpoint must be a valid URL");
+ validateURL(getClaims().get(OAuth2AuthorizationServerMetadataClaimNames.REVOCATION_ENDPOINT),
+ "tokenRevocationEndpoint must be a valid URL");
}
- if (getClaims().get(OAuth2AuthorizationServerMetadataClaimNames.REVOCATION_ENDPOINT_AUTH_METHODS_SUPPORTED) != null) {
- Assert.isInstanceOf(List.class, getClaims().get(OAuth2AuthorizationServerMetadataClaimNames.REVOCATION_ENDPOINT_AUTH_METHODS_SUPPORTED), "tokenRevocationEndpointAuthenticationMethods must be of type List");
- Assert.notEmpty((List>) getClaims().get(OAuth2AuthorizationServerMetadataClaimNames.REVOCATION_ENDPOINT_AUTH_METHODS_SUPPORTED), "tokenRevocationEndpointAuthenticationMethods cannot be empty");
+ if (getClaims()
+ .get(OAuth2AuthorizationServerMetadataClaimNames.REVOCATION_ENDPOINT_AUTH_METHODS_SUPPORTED) != null) {
+ Assert.isInstanceOf(List.class,
+ getClaims().get(
+ OAuth2AuthorizationServerMetadataClaimNames.REVOCATION_ENDPOINT_AUTH_METHODS_SUPPORTED),
+ "tokenRevocationEndpointAuthenticationMethods must be of type List");
+ Assert.notEmpty(
+ (List>) getClaims().get(
+ OAuth2AuthorizationServerMetadataClaimNames.REVOCATION_ENDPOINT_AUTH_METHODS_SUPPORTED),
+ "tokenRevocationEndpointAuthenticationMethods cannot be empty");
}
if (getClaims().get(OAuth2AuthorizationServerMetadataClaimNames.INTROSPECTION_ENDPOINT) != null) {
- validateURL(getClaims().get(OAuth2AuthorizationServerMetadataClaimNames.INTROSPECTION_ENDPOINT), "tokenIntrospectionEndpoint must be a valid URL");
+ validateURL(getClaims().get(OAuth2AuthorizationServerMetadataClaimNames.INTROSPECTION_ENDPOINT),
+ "tokenIntrospectionEndpoint must be a valid URL");
}
- if (getClaims().get(OAuth2AuthorizationServerMetadataClaimNames.INTROSPECTION_ENDPOINT_AUTH_METHODS_SUPPORTED) != null) {
- Assert.isInstanceOf(List.class, getClaims().get(OAuth2AuthorizationServerMetadataClaimNames.INTROSPECTION_ENDPOINT_AUTH_METHODS_SUPPORTED), "tokenIntrospectionEndpointAuthenticationMethods must be of type List");
- Assert.notEmpty((List>) getClaims().get(OAuth2AuthorizationServerMetadataClaimNames.INTROSPECTION_ENDPOINT_AUTH_METHODS_SUPPORTED), "tokenIntrospectionEndpointAuthenticationMethods cannot be empty");
+ if (getClaims().get(
+ OAuth2AuthorizationServerMetadataClaimNames.INTROSPECTION_ENDPOINT_AUTH_METHODS_SUPPORTED) != null) {
+ Assert.isInstanceOf(List.class, getClaims()
+ .get(OAuth2AuthorizationServerMetadataClaimNames.INTROSPECTION_ENDPOINT_AUTH_METHODS_SUPPORTED),
+ "tokenIntrospectionEndpointAuthenticationMethods must be of type List");
+ Assert.notEmpty((List>) getClaims()
+ .get(OAuth2AuthorizationServerMetadataClaimNames.INTROSPECTION_ENDPOINT_AUTH_METHODS_SUPPORTED),
+ "tokenIntrospectionEndpointAuthenticationMethods cannot be empty");
}
if (getClaims().get(OAuth2AuthorizationServerMetadataClaimNames.REGISTRATION_ENDPOINT) != null) {
- validateURL(getClaims().get(OAuth2AuthorizationServerMetadataClaimNames.REGISTRATION_ENDPOINT), "clientRegistrationEndpoint must be a valid URL");
+ validateURL(getClaims().get(OAuth2AuthorizationServerMetadataClaimNames.REGISTRATION_ENDPOINT),
+ "clientRegistrationEndpoint must be a valid URL");
}
if (getClaims().get(OAuth2AuthorizationServerMetadataClaimNames.CODE_CHALLENGE_METHODS_SUPPORTED) != null) {
- Assert.isInstanceOf(List.class, getClaims().get(OAuth2AuthorizationServerMetadataClaimNames.CODE_CHALLENGE_METHODS_SUPPORTED), "codeChallengeMethods must be of type List");
- Assert.notEmpty((List>) getClaims().get(OAuth2AuthorizationServerMetadataClaimNames.CODE_CHALLENGE_METHODS_SUPPORTED), "codeChallengeMethods cannot be empty");
+ Assert.isInstanceOf(List.class,
+ getClaims().get(OAuth2AuthorizationServerMetadataClaimNames.CODE_CHALLENGE_METHODS_SUPPORTED),
+ "codeChallengeMethods must be of type List");
+ Assert.notEmpty(
+ (List>) getClaims()
+ .get(OAuth2AuthorizationServerMetadataClaimNames.CODE_CHALLENGE_METHODS_SUPPORTED),
+ "codeChallengeMethods cannot be empty");
}
}
@@ -429,10 +512,12 @@ public abstract class AbstractOAuth2AuthorizationServerMetadata implements OAuth
try {
new URI(url.toString()).toURL();
- } catch (Exception ex) {
+ }
+ catch (Exception ex) {
throw new IllegalArgumentException(errorMessage, ex);
}
}
}
+
}
diff --git a/oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/InMemoryOAuth2AuthorizationConsentService.java b/oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/InMemoryOAuth2AuthorizationConsentService.java
index 42bfc034..a2b351b7 100644
--- a/oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/InMemoryOAuth2AuthorizationConsentService.java
+++ b/oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/InMemoryOAuth2AuthorizationConsentService.java
@@ -26,7 +26,8 @@ import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
/**
- * An {@link OAuth2AuthorizationConsentService} that stores {@link OAuth2AuthorizationConsent}'s in-memory.
+ * An {@link OAuth2AuthorizationConsentService} that stores
+ * {@link OAuth2AuthorizationConsent}'s in-memory.
*
*
* NOTE: This implementation should ONLY be used during development/testing.
@@ -36,6 +37,7 @@ import org.springframework.util.Assert;
* @see OAuth2AuthorizationConsentService
*/
public final class InMemoryOAuth2AuthorizationConsentService implements OAuth2AuthorizationConsentService {
+
private final Map authorizationConsents = new ConcurrentHashMap<>();
/**
@@ -46,8 +48,8 @@ public final class InMemoryOAuth2AuthorizationConsentService implements OAuth2Au
}
/**
- * Constructs an {@code InMemoryOAuth2AuthorizationConsentService} using the provided parameters.
- *
+ * Constructs an {@code InMemoryOAuth2AuthorizationConsentService} using the provided
+ * parameters.
* @param authorizationConsents the authorization consent(s)
*/
public InMemoryOAuth2AuthorizationConsentService(OAuth2AuthorizationConsent... authorizationConsents) {
@@ -55,8 +57,8 @@ public final class InMemoryOAuth2AuthorizationConsentService implements OAuth2Au
}
/**
- * Constructs an {@code InMemoryOAuth2AuthorizationConsentService} using the provided parameters.
- *
+ * Constructs an {@code InMemoryOAuth2AuthorizationConsentService} using the provided
+ * parameters.
* @param authorizationConsents the authorization consent(s)
*/
public InMemoryOAuth2AuthorizationConsentService(List authorizationConsents) {
@@ -66,8 +68,8 @@ public final class InMemoryOAuth2AuthorizationConsentService implements OAuth2Au
int id = getId(authorizationConsent);
Assert.isTrue(!this.authorizationConsents.containsKey(id),
"The authorizationConsent must be unique. Found duplicate, with registered client id: ["
- + authorizationConsent.getRegisteredClientId()
- + "] and principal name: [" + authorizationConsent.getPrincipalName() + "]");
+ + authorizationConsent.getRegisteredClientId() + "] and principal name: ["
+ + authorizationConsent.getPrincipalName() + "]");
this.authorizationConsents.put(id, authorizationConsent);
});
}
diff --git a/oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/InMemoryOAuth2AuthorizationService.java b/oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/InMemoryOAuth2AuthorizationService.java
index 20dbb0bf..e69dad95 100644
--- a/oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/InMemoryOAuth2AuthorizationService.java
+++ b/oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/InMemoryOAuth2AuthorizationService.java
@@ -33,7 +33,8 @@ import org.springframework.security.oauth2.core.oidc.endpoint.OidcParameterNames
import org.springframework.util.Assert;
/**
- * An {@link OAuth2AuthorizationService} that stores {@link OAuth2Authorization}'s in-memory.
+ * An {@link OAuth2AuthorizationService} that stores {@link OAuth2Authorization}'s
+ * in-memory.
*
*
* NOTE: This implementation should ONLY be used during development/testing.
@@ -44,15 +45,17 @@ import org.springframework.util.Assert;
* @see OAuth2AuthorizationService
*/
public final class InMemoryOAuth2AuthorizationService implements OAuth2AuthorizationService {
+
private int maxInitializedAuthorizations = 100;
/*
- * Stores "initialized" (uncompleted) authorizations, where an access token has not yet been granted.
- * This state occurs with the authorization_code grant flow during the user consent step OR
- * when the code is returned in the authorization response but the access token request is not yet initiated.
+ * Stores "initialized" (uncompleted) authorizations, where an access token has not
+ * yet been granted. This state occurs with the authorization_code grant flow during
+ * the user consent step OR when the code is returned in the authorization response
+ * but the access token request is not yet initiated.
*/
- private Map initializedAuthorizations =
- Collections.synchronizedMap(new MaxSizeHashMap<>(this.maxInitializedAuthorizations));
+ private Map initializedAuthorizations = Collections
+ .synchronizedMap(new MaxSizeHashMap<>(this.maxInitializedAuthorizations));
/*
* Stores "completed" authorizations, where an access token has been granted.
@@ -64,7 +67,8 @@ public final class InMemoryOAuth2AuthorizationService implements OAuth2Authoriza
*/
InMemoryOAuth2AuthorizationService(int maxInitializedAuthorizations) {
this.maxInitializedAuthorizations = maxInitializedAuthorizations;
- this.initializedAuthorizations = Collections.synchronizedMap(new MaxSizeHashMap<>(this.maxInitializedAuthorizations));
+ this.initializedAuthorizations = Collections
+ .synchronizedMap(new MaxSizeHashMap<>(this.maxInitializedAuthorizations));
}
/**
@@ -75,8 +79,8 @@ public final class InMemoryOAuth2AuthorizationService implements OAuth2Authoriza
}
/**
- * Constructs an {@code InMemoryOAuth2AuthorizationService} using the provided parameters.
- *
+ * Constructs an {@code InMemoryOAuth2AuthorizationService} using the provided
+ * parameters.
* @param authorizations the authorization(s)
*/
public InMemoryOAuth2AuthorizationService(OAuth2Authorization... authorizations) {
@@ -84,8 +88,8 @@ public final class InMemoryOAuth2AuthorizationService implements OAuth2Authoriza
}
/**
- * Constructs an {@code InMemoryOAuth2AuthorizationService} using the provided parameters.
- *
+ * Constructs an {@code InMemoryOAuth2AuthorizationService} using the provided
+ * parameters.
* @param authorizations the authorization(s)
*/
public InMemoryOAuth2AuthorizationService(List authorizations) {
@@ -103,7 +107,8 @@ public final class InMemoryOAuth2AuthorizationService implements OAuth2Authoriza
Assert.notNull(authorization, "authorization cannot be null");
if (isComplete(authorization)) {
this.authorizations.put(authorization.getId(), authorization);
- } else {
+ }
+ else {
this.initializedAuthorizations.put(authorization.getId(), authorization);
}
}
@@ -113,7 +118,8 @@ public final class InMemoryOAuth2AuthorizationService implements OAuth2Authoriza
Assert.notNull(authorization, "authorization cannot be null");
if (isComplete(authorization)) {
this.authorizations.remove(authorization.getId(), authorization);
- } else {
+ }
+ else {
this.initializedAuthorizations.remove(authorization.getId(), authorization);
}
}
@@ -123,9 +129,7 @@ public final class InMemoryOAuth2AuthorizationService implements OAuth2Authoriza
public OAuth2Authorization findById(String id) {
Assert.hasText(id, "id cannot be empty");
OAuth2Authorization authorization = this.authorizations.get(id);
- return authorization != null ?
- authorization :
- this.initializedAuthorizations.get(id);
+ return authorization != null ? authorization : this.initializedAuthorizations.get(id);
}
@Nullable
@@ -149,7 +153,8 @@ public final class InMemoryOAuth2AuthorizationService implements OAuth2Authoriza
return authorization.getAccessToken() != null;
}
- private static boolean hasToken(OAuth2Authorization authorization, String token, @Nullable OAuth2TokenType tokenType) {
+ private static boolean hasToken(OAuth2Authorization authorization, String token,
+ @Nullable OAuth2TokenType tokenType) {
// @formatter:off
if (tokenType == null) {
return matchesState(authorization, token) ||
@@ -183,42 +188,38 @@ public final class InMemoryOAuth2AuthorizationService implements OAuth2Authoriza
}
private static boolean matchesAuthorizationCode(OAuth2Authorization authorization, String token) {
- OAuth2Authorization.Token authorizationCode =
- authorization.getToken(OAuth2AuthorizationCode.class);
+ OAuth2Authorization.Token authorizationCode = authorization
+ .getToken(OAuth2AuthorizationCode.class);
return authorizationCode != null && authorizationCode.getToken().getTokenValue().equals(token);
}
private static boolean matchesAccessToken(OAuth2Authorization authorization, String token) {
- OAuth2Authorization.Token accessToken =
- authorization.getToken(OAuth2AccessToken.class);
+ OAuth2Authorization.Token accessToken = authorization.getToken(OAuth2AccessToken.class);
return accessToken != null && accessToken.getToken().getTokenValue().equals(token);
}
private static boolean matchesRefreshToken(OAuth2Authorization authorization, String token) {
- OAuth2Authorization.Token refreshToken =
- authorization.getToken(OAuth2RefreshToken.class);
+ OAuth2Authorization.Token refreshToken = authorization.getToken(OAuth2RefreshToken.class);
return refreshToken != null && refreshToken.getToken().getTokenValue().equals(token);
}
private static boolean matchesIdToken(OAuth2Authorization authorization, String token) {
- OAuth2Authorization.Token idToken =
- authorization.getToken(OidcIdToken.class);
+ OAuth2Authorization.Token idToken = authorization.getToken(OidcIdToken.class);
return idToken != null && idToken.getToken().getTokenValue().equals(token);
}
private static boolean matchesDeviceCode(OAuth2Authorization authorization, String token) {
- OAuth2Authorization.Token deviceCode =
- authorization.getToken(OAuth2DeviceCode.class);
+ OAuth2Authorization.Token deviceCode = authorization.getToken(OAuth2DeviceCode.class);
return deviceCode != null && deviceCode.getToken().getTokenValue().equals(token);
}
private static boolean matchesUserCode(OAuth2Authorization authorization, String token) {
- OAuth2Authorization.Token userCode =
- authorization.getToken(OAuth2UserCode.class);
+ OAuth2Authorization.Token userCode = authorization.getToken(OAuth2UserCode.class);
return userCode != null && userCode.getToken().getTokenValue().equals(token);
}
private static final class MaxSizeHashMap extends LinkedHashMap {
+
private final int maxSize;
private MaxSizeHashMap(int maxSize) {
diff --git a/oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/JdbcOAuth2AuthorizationConsentService.java b/oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/JdbcOAuth2AuthorizationConsentService.java
index 24ca449e..a0313360 100644
--- a/oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/JdbcOAuth2AuthorizationConsentService.java
+++ b/oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/JdbcOAuth2AuthorizationConsentService.java
@@ -43,16 +43,18 @@ import org.springframework.util.StringUtils;
* {@link JdbcOperations} for {@link OAuth2AuthorizationConsent} persistence.
*
*
- * IMPORTANT: This {@code OAuth2AuthorizationConsentService} depends on the table definition
- * described in
- * "classpath:org/springframework/security/oauth2/server/authorization/oauth2-authorization-consent-schema.sql" and
- * therefore MUST be defined in the database schema.
+ * IMPORTANT: This {@code OAuth2AuthorizationConsentService} depends on the table
+ * definition described in
+ * "classpath:org/springframework/security/oauth2/server/authorization/oauth2-authorization-consent-schema.sql"
+ * and therefore MUST be defined in the database schema.
*
*
- * NOTE: This {@code OAuth2AuthorizationConsentService} is a simplified JDBC implementation that MAY be used in a production environment.
- * However, it does have limitations as it likely won't perform well in an environment requiring high throughput.
- * The expectation is that the consuming application will provide their own implementation of {@code OAuth2AuthorizationConsentService}
- * that meets the performance requirements for its deployment environment.
+ * NOTE: This {@code OAuth2AuthorizationConsentService} is a simplified JDBC
+ * implementation that MAY be used in a production environment. However, it does have
+ * limitations as it likely won't perform well in an environment requiring high
+ * throughput. The expectation is that the consuming application will provide their own
+ * implementation of {@code OAuth2AuthorizationConsentService} that meets the performance
+ * requirements for its deployment environment.
*
* @author Ovidiu Popa
* @since 0.1.2
@@ -93,13 +95,15 @@ public class JdbcOAuth2AuthorizationConsentService implements OAuth2Authorizatio
private static final String REMOVE_AUTHORIZATION_CONSENT_SQL = "DELETE FROM " + TABLE_NAME + " WHERE " + PK_FILTER;
private final JdbcOperations jdbcOperations;
+
private RowMapper authorizationConsentRowMapper;
+
private Function> authorizationConsentParametersMapper;
/**
- * Constructs a {@code JdbcOAuth2AuthorizationConsentService} using the provided parameters.
- *
- * @param jdbcOperations the JDBC operations
+ * Constructs a {@code JdbcOAuth2AuthorizationConsentService} using the provided
+ * parameters.
+ * @param jdbcOperations the JDBC operations
* @param registeredClientRepository the registered client repository
*/
public JdbcOAuth2AuthorizationConsentService(JdbcOperations jdbcOperations,
@@ -114,11 +118,12 @@ public class JdbcOAuth2AuthorizationConsentService implements OAuth2Authorizatio
@Override
public void save(OAuth2AuthorizationConsent authorizationConsent) {
Assert.notNull(authorizationConsent, "authorizationConsent cannot be null");
- OAuth2AuthorizationConsent existingAuthorizationConsent = findById(
- authorizationConsent.getRegisteredClientId(), authorizationConsent.getPrincipalName());
+ OAuth2AuthorizationConsent existingAuthorizationConsent = findById(authorizationConsent.getRegisteredClientId(),
+ authorizationConsent.getPrincipalName());
if (existingAuthorizationConsent == null) {
insertAuthorizationConsent(authorizationConsent);
- } else {
+ }
+ else {
updateAuthorizationConsent(authorizationConsent);
}
}
@@ -144,8 +149,7 @@ public class JdbcOAuth2AuthorizationConsentService implements OAuth2Authorizatio
Assert.notNull(authorizationConsent, "authorizationConsent cannot be null");
SqlParameterValue[] parameters = new SqlParameterValue[] {
new SqlParameterValue(Types.VARCHAR, authorizationConsent.getRegisteredClientId()),
- new SqlParameterValue(Types.VARCHAR, authorizationConsent.getPrincipalName())
- };
+ new SqlParameterValue(Types.VARCHAR, authorizationConsent.getPrincipalName()) };
PreparedStatementSetter pss = new ArgumentPreparedStatementSetter(parameters);
this.jdbcOperations.update(REMOVE_AUTHORIZATION_CONSENT_SQL, pss);
}
@@ -157,7 +161,7 @@ public class JdbcOAuth2AuthorizationConsentService implements OAuth2Authorizatio
Assert.hasText(principalName, "principalName cannot be empty");
SqlParameterValue[] parameters = new SqlParameterValue[] {
new SqlParameterValue(Types.VARCHAR, registeredClientId),
- new SqlParameterValue(Types.VARCHAR, principalName)};
+ new SqlParameterValue(Types.VARCHAR, principalName) };
PreparedStatementSetter pss = new ArgumentPreparedStatementSetter(parameters);
List result = this.jdbcOperations.query(LOAD_AUTHORIZATION_CONSENT_SQL, pss,
this.authorizationConsentRowMapper);
@@ -168,22 +172,21 @@ public class JdbcOAuth2AuthorizationConsentService implements OAuth2Authorizatio
* Sets the {@link RowMapper} used for mapping the current row in
* {@code java.sql.ResultSet} to {@link OAuth2AuthorizationConsent}. The default is
* {@link OAuth2AuthorizationConsentRowMapper}.
- *
- * @param authorizationConsentRowMapper the {@link RowMapper} used for mapping the current
- * row in {@code ResultSet} to {@link OAuth2AuthorizationConsent}
+ * @param authorizationConsentRowMapper the {@link RowMapper} used for mapping the
+ * current row in {@code ResultSet} to {@link OAuth2AuthorizationConsent}
*/
- public final void setAuthorizationConsentRowMapper(RowMapper authorizationConsentRowMapper) {
+ public final void setAuthorizationConsentRowMapper(
+ RowMapper authorizationConsentRowMapper) {
Assert.notNull(authorizationConsentRowMapper, "authorizationConsentRowMapper cannot be null");
this.authorizationConsentRowMapper = authorizationConsentRowMapper;
}
/**
- * Sets the {@code Function} used for mapping {@link OAuth2AuthorizationConsent} to
- * a {@code List} of {@link SqlParameterValue}. The default is
+ * Sets the {@code Function} used for mapping {@link OAuth2AuthorizationConsent} to a
+ * {@code List} of {@link SqlParameterValue}. The default is
* {@link OAuth2AuthorizationConsentParametersMapper}.
- *
* @param authorizationConsentParametersMapper the {@code Function} used for mapping
- * {@link OAuth2AuthorizationConsent} to a {@code List} of {@link SqlParameterValue}
+ * {@link OAuth2AuthorizationConsent} to a {@code List} of {@link SqlParameterValue}
*/
public final void setAuthorizationConsentParametersMapper(
Function> authorizationConsentParametersMapper) {
@@ -204,10 +207,11 @@ public class JdbcOAuth2AuthorizationConsentService implements OAuth2Authorizatio
}
/**
- * The default {@link RowMapper} that maps the current row in
- * {@code ResultSet} to {@link OAuth2AuthorizationConsent}.
+ * The default {@link RowMapper} that maps the current row in {@code ResultSet} to
+ * {@link OAuth2AuthorizationConsent}.
*/
public static class OAuth2AuthorizationConsentRowMapper implements RowMapper {
+
private final RegisteredClientRepository registeredClientRepository;
public OAuth2AuthorizationConsentRowMapper(RegisteredClientRepository registeredClientRepository) {
@@ -220,13 +224,14 @@ public class JdbcOAuth2AuthorizationConsentService implements OAuth2Authorizatio
String registeredClientId = rs.getString("registered_client_id");
RegisteredClient registeredClient = this.registeredClientRepository.findById(registeredClientId);
if (registeredClient == null) {
- throw new DataRetrievalFailureException(
- "The RegisteredClient with id '" + registeredClientId + "' was not found in the RegisteredClientRepository.");
+ throw new DataRetrievalFailureException("The RegisteredClient with id '" + registeredClientId
+ + "' was not found in the RegisteredClientRepository.");
}
String principalName = rs.getString("principal_name");
- OAuth2AuthorizationConsent.Builder builder = OAuth2AuthorizationConsent.withId(registeredClientId, principalName);
+ OAuth2AuthorizationConsent.Builder builder = OAuth2AuthorizationConsent.withId(registeredClientId,
+ principalName);
String authorizationConsentAuthorities = rs.getString("authorities");
if (authorizationConsentAuthorities != null) {
for (String authority : StringUtils.commaDelimitedListToSet(authorizationConsentAuthorities)) {
@@ -246,7 +251,8 @@ public class JdbcOAuth2AuthorizationConsentService implements OAuth2Authorizatio
* The default {@code Function} that maps {@link OAuth2AuthorizationConsent} to a
* {@code List} of {@link SqlParameterValue}.
*/
- public static class OAuth2AuthorizationConsentParametersMapper implements Function> {
+ public static class OAuth2AuthorizationConsentParametersMapper
+ implements Function> {
@Override
public List apply(OAuth2AuthorizationConsent authorizationConsent) {
@@ -258,7 +264,8 @@ public class JdbcOAuth2AuthorizationConsentService implements OAuth2Authorizatio
for (GrantedAuthority authority : authorizationConsent.getAuthorities()) {
authorities.add(authority.getAuthority());
}
- parameters.add(new SqlParameterValue(Types.VARCHAR, StringUtils.collectionToDelimitedString(authorities, ",")));
+ parameters
+ .add(new SqlParameterValue(Types.VARCHAR, StringUtils.collectionToDelimitedString(authorities, ",")));
return parameters;
}
diff --git a/oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/JdbcOAuth2AuthorizationService.java b/oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/JdbcOAuth2AuthorizationService.java
index 96e08966..9bbbb912 100644
--- a/oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/JdbcOAuth2AuthorizationService.java
+++ b/oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/JdbcOAuth2AuthorizationService.java
@@ -68,16 +68,18 @@ import org.springframework.util.StringUtils;
* {@link JdbcOperations} for {@link OAuth2Authorization} persistence.
*
*
- * IMPORTANT: This {@code OAuth2AuthorizationService} depends on the table definition
- * described in
- * "classpath:org/springframework/security/oauth2/server/authorization/oauth2-authorization-schema.sql" and
- * therefore MUST be defined in the database schema.
+ * IMPORTANT: This {@code OAuth2AuthorizationService} depends on the table
+ * definition described in
+ * "classpath:org/springframework/security/oauth2/server/authorization/oauth2-authorization-schema.sql"
+ * and therefore MUST be defined in the database schema.
*
*
- * NOTE: This {@code OAuth2AuthorizationService} is a simplified JDBC implementation that MAY be used in a production environment.
- * However, it does have limitations as it likely won't perform well in an environment requiring high throughput.
- * The expectation is that the consuming application will provide their own implementation of {@code OAuth2AuthorizationService}
- * that meets the performance requirements for its deployment environment.
+ * NOTE: This {@code OAuth2AuthorizationService} is a simplified JDBC
+ * implementation that MAY be used in a production environment. However, it does have
+ * limitations as it likely won't perform well in an environment requiring high
+ * throughput. The expectation is that the consuming application will provide their own
+ * implementation of {@code OAuth2AuthorizationService} that meets the performance
+ * requirements for its deployment environment.
*
* @author Ovidiu Popa
* @author Joe Grandja
@@ -128,16 +130,23 @@ public class JdbcOAuth2AuthorizationService implements OAuth2AuthorizationServic
private static final String TABLE_NAME = "oauth2_authorization";
private static final String PK_FILTER = "id = ?";
+
private static final String UNKNOWN_TOKEN_TYPE_FILTER = "state = ? OR authorization_code_value = ? OR "
+ "access_token_value = ? OR oidc_id_token_value = ? OR refresh_token_value = ? OR user_code_value = ? OR "
+ "device_code_value = ?";
private static final String STATE_FILTER = "state = ?";
+
private static final String AUTHORIZATION_CODE_FILTER = "authorization_code_value = ?";
+
private static final String ACCESS_TOKEN_FILTER = "access_token_value = ?";
+
private static final String ID_TOKEN_FILTER = "oidc_id_token_value = ?";
+
private static final String REFRESH_TOKEN_FILTER = "refresh_token_value = ?";
+
private static final String USER_CODE_FILTER = "user_code_value = ?";
+
private static final String DEVICE_CODE_FILTER = "device_code_value = ?";
// @formatter:off
@@ -168,14 +177,16 @@ public class JdbcOAuth2AuthorizationService implements OAuth2AuthorizationServic
private static Map columnMetadataMap;
private final JdbcOperations jdbcOperations;
+
private final LobHandler lobHandler;
+
private RowMapper authorizationRowMapper;
+
private Function> authorizationParametersMapper;
/**
* Constructs a {@code JdbcOAuth2AuthorizationService} using the provided parameters.
- *
- * @param jdbcOperations the JDBC operations
+ * @param jdbcOperations the JDBC operations
* @param registeredClientRepository the registered client repository
*/
public JdbcOAuth2AuthorizationService(JdbcOperations jdbcOperations,
@@ -185,10 +196,9 @@ public class JdbcOAuth2AuthorizationService implements OAuth2AuthorizationServic
/**
* Constructs a {@code JdbcOAuth2AuthorizationService} using the provided parameters.
- *
- * @param jdbcOperations the JDBC operations
+ * @param jdbcOperations the JDBC operations
* @param registeredClientRepository the registered client repository
- * @param lobHandler the handler for large binary fields and large text fields
+ * @param lobHandler the handler for large binary fields and large text fields
*/
public JdbcOAuth2AuthorizationService(JdbcOperations jdbcOperations,
RegisteredClientRepository registeredClientRepository, LobHandler lobHandler) {
@@ -197,7 +207,8 @@ public class JdbcOAuth2AuthorizationService implements OAuth2AuthorizationServic
Assert.notNull(lobHandler, "lobHandler cannot be null");
this.jdbcOperations = jdbcOperations;
this.lobHandler = lobHandler;
- OAuth2AuthorizationRowMapper authorizationRowMapper = new OAuth2AuthorizationRowMapper(registeredClientRepository);
+ OAuth2AuthorizationRowMapper authorizationRowMapper = new OAuth2AuthorizationRowMapper(
+ registeredClientRepository);
authorizationRowMapper.setLobHandler(lobHandler);
this.authorizationRowMapper = authorizationRowMapper;
this.authorizationParametersMapper = new OAuth2AuthorizationParametersMapper();
@@ -210,7 +221,8 @@ public class JdbcOAuth2AuthorizationService implements OAuth2AuthorizationServic
OAuth2Authorization existingAuthorization = findById(authorization.getId());
if (existingAuthorization == null) {
insertAuthorization(authorization);
- } else {
+ }
+ else {
updateAuthorization(authorization);
}
}
@@ -239,8 +251,7 @@ public class JdbcOAuth2AuthorizationService implements OAuth2AuthorizationServic
public void remove(OAuth2Authorization authorization) {
Assert.notNull(authorization, "authorization cannot be null");
SqlParameterValue[] parameters = new SqlParameterValue[] {
- new SqlParameterValue(Types.VARCHAR, authorization.getId())
- };
+ new SqlParameterValue(Types.VARCHAR, authorization.getId()) };
PreparedStatementSetter pss = new ArgumentPreparedStatementSetter(parameters);
this.jdbcOperations.update(REMOVE_AUTHORIZATION_SQL, pss);
}
@@ -268,25 +279,32 @@ public class JdbcOAuth2AuthorizationService implements OAuth2AuthorizationServic
parameters.add(mapToSqlParameter("user_code_value", token));
parameters.add(mapToSqlParameter("device_code_value", token));
return findBy(UNKNOWN_TOKEN_TYPE_FILTER, parameters);
- } else if (OAuth2ParameterNames.STATE.equals(tokenType.getValue())) {
+ }
+ else if (OAuth2ParameterNames.STATE.equals(tokenType.getValue())) {
parameters.add(new SqlParameterValue(Types.VARCHAR, token));
return findBy(STATE_FILTER, parameters);
- } else if (OAuth2ParameterNames.CODE.equals(tokenType.getValue())) {
+ }
+ else if (OAuth2ParameterNames.CODE.equals(tokenType.getValue())) {
parameters.add(mapToSqlParameter("authorization_code_value", token));
return findBy(AUTHORIZATION_CODE_FILTER, parameters);
- } else if (OAuth2TokenType.ACCESS_TOKEN.equals(tokenType)) {
+ }
+ else if (OAuth2TokenType.ACCESS_TOKEN.equals(tokenType)) {
parameters.add(mapToSqlParameter("access_token_value", token));
return findBy(ACCESS_TOKEN_FILTER, parameters);
- } else if (OidcParameterNames.ID_TOKEN.equals(tokenType.getValue())) {
+ }
+ else if (OidcParameterNames.ID_TOKEN.equals(tokenType.getValue())) {
parameters.add(mapToSqlParameter("oidc_id_token_value", token));
return findBy(ID_TOKEN_FILTER, parameters);
- } else if (OAuth2TokenType.REFRESH_TOKEN.equals(tokenType)) {
+ }
+ else if (OAuth2TokenType.REFRESH_TOKEN.equals(tokenType)) {
parameters.add(mapToSqlParameter("refresh_token_value", token));
return findBy(REFRESH_TOKEN_FILTER, parameters);
- } else if (OAuth2ParameterNames.USER_CODE.equals(tokenType.getValue())) {
+ }
+ else if (OAuth2ParameterNames.USER_CODE.equals(tokenType.getValue())) {
parameters.add(mapToSqlParameter("user_code_value", token));
return findBy(USER_CODE_FILTER, parameters);
- } else if (OAuth2ParameterNames.DEVICE_CODE.equals(tokenType.getValue())) {
+ }
+ else if (OAuth2ParameterNames.DEVICE_CODE.equals(tokenType.getValue())) {
parameters.add(mapToSqlParameter("device_code_value", token));
return findBy(DEVICE_CODE_FILTER, parameters);
}
@@ -297,7 +315,8 @@ public class JdbcOAuth2AuthorizationService implements OAuth2AuthorizationServic
try (LobCreator lobCreator = getLobHandler().getLobCreator()) {
PreparedStatementSetter pss = new LobCreatorArgumentPreparedStatementSetter(lobCreator,
parameters.toArray());
- List result = getJdbcOperations().query(LOAD_AUTHORIZATION_SQL + filter, pss, getAuthorizationRowMapper());
+ List result = getJdbcOperations().query(LOAD_AUTHORIZATION_SQL + filter, pss,
+ getAuthorizationRowMapper());
return !result.isEmpty() ? result.get(0) : null;
}
}
@@ -306,9 +325,8 @@ public class JdbcOAuth2AuthorizationService implements OAuth2AuthorizationServic
* Sets the {@link RowMapper} used for mapping the current row in
* {@code java.sql.ResultSet} to {@link OAuth2Authorization}. The default is
* {@link OAuth2AuthorizationRowMapper}.
- *
* @param authorizationRowMapper the {@link RowMapper} used for mapping the current
- * row in {@code ResultSet} to {@link OAuth2Authorization}
+ * row in {@code ResultSet} to {@link OAuth2Authorization}
*/
public final void setAuthorizationRowMapper(RowMapper authorizationRowMapper) {
Assert.notNull(authorizationRowMapper, "authorizationRowMapper cannot be null");
@@ -316,12 +334,11 @@ public class JdbcOAuth2AuthorizationService implements OAuth2AuthorizationServic
}
/**
- * Sets the {@code Function} used for mapping {@link OAuth2Authorization} to
- * a {@code List} of {@link SqlParameterValue}. The default is
+ * Sets the {@code Function} used for mapping {@link OAuth2Authorization} to a
+ * {@code List} of {@link SqlParameterValue}. The default is
* {@link OAuth2AuthorizationParametersMapper}.
- *
* @param authorizationParametersMapper the {@code Function} used for mapping
- * {@link OAuth2Authorization} to a {@code List} of {@link SqlParameterValue}
+ * {@link OAuth2Authorization} to a {@code List} of {@link SqlParameterValue}
*/
public final void setAuthorizationParametersMapper(
Function> authorizationParametersMapper) {
@@ -350,8 +367,11 @@ public class JdbcOAuth2AuthorizationService implements OAuth2AuthorizationServic
* {@code java.sql.ResultSet} to {@link OAuth2Authorization}.
*/
public static class OAuth2AuthorizationRowMapper implements RowMapper {
+
private final RegisteredClientRepository registeredClientRepository;
+
private LobHandler lobHandler = new DefaultLobHandler();
+
private ObjectMapper objectMapper = new ObjectMapper();
public OAuth2AuthorizationRowMapper(RegisteredClientRepository registeredClientRepository) {
@@ -370,8 +390,8 @@ public class JdbcOAuth2AuthorizationService implements OAuth2AuthorizationServic
String registeredClientId = rs.getString("registered_client_id");
RegisteredClient registeredClient = this.registeredClientRepository.findById(registeredClientId);
if (registeredClient == null) {
- throw new DataRetrievalFailureException(
- "The RegisteredClient with id '" + registeredClientId + "' was not found in the RegisteredClientRepository.");
+ throw new DataRetrievalFailureException("The RegisteredClient with id '" + registeredClientId
+ + "' was not found in the RegisteredClientRepository.");
}
OAuth2Authorization.Builder builder = OAuth2Authorization.withRegisteredClient(registeredClient);
@@ -386,10 +406,10 @@ public class JdbcOAuth2AuthorizationService implements OAuth2AuthorizationServic
Map attributes = parseMap(getLobValue(rs, "attributes"));
builder.id(id)
- .principalName(principalName)
- .authorizationGrantType(new AuthorizationGrantType(authorizationGrantType))
- .authorizedScopes(authorizedScopes)
- .attributes((attrs) -> attrs.putAll(attributes));
+ .principalName(principalName)
+ .authorizationGrantType(new AuthorizationGrantType(authorizationGrantType))
+ .authorizedScopes(authorizedScopes)
+ .attributes((attrs) -> attrs.putAll(attributes));
String state = rs.getString("state");
if (StringUtils.hasText(state)) {
@@ -403,10 +423,11 @@ public class JdbcOAuth2AuthorizationService implements OAuth2AuthorizationServic
if (StringUtils.hasText(authorizationCodeValue)) {
tokenIssuedAt = rs.getTimestamp("authorization_code_issued_at").toInstant();
tokenExpiresAt = rs.getTimestamp("authorization_code_expires_at").toInstant();
- Map authorizationCodeMetadata = parseMap(getLobValue(rs, "authorization_code_metadata"));
+ Map authorizationCodeMetadata = parseMap(
+ getLobValue(rs, "authorization_code_metadata"));
- OAuth2AuthorizationCode authorizationCode = new OAuth2AuthorizationCode(
- authorizationCodeValue, tokenIssuedAt, tokenExpiresAt);
+ OAuth2AuthorizationCode authorizationCode = new OAuth2AuthorizationCode(authorizationCodeValue,
+ tokenIssuedAt, tokenExpiresAt);
builder.token(authorizationCode, (metadata) -> metadata.putAll(authorizationCodeMetadata));
}
@@ -425,7 +446,8 @@ public class JdbcOAuth2AuthorizationService implements OAuth2AuthorizationServic
if (accessTokenScopes != null) {
scopes = StringUtils.commaDelimitedListToSet(accessTokenScopes);
}
- OAuth2AccessToken accessToken = new OAuth2AccessToken(tokenType, accessTokenValue, tokenIssuedAt, tokenExpiresAt, scopes);
+ OAuth2AccessToken accessToken = new OAuth2AccessToken(tokenType, accessTokenValue, tokenIssuedAt,
+ tokenExpiresAt, scopes);
builder.token(accessToken, (metadata) -> metadata.putAll(accessTokenMetadata));
}
@@ -435,8 +457,8 @@ public class JdbcOAuth2AuthorizationService implements OAuth2AuthorizationServic
tokenExpiresAt = rs.getTimestamp("oidc_id_token_expires_at").toInstant();
Map oidcTokenMetadata = parseMap(getLobValue(rs, "oidc_id_token_metadata"));
- OidcIdToken oidcToken = new OidcIdToken(
- oidcIdTokenValue, tokenIssuedAt, tokenExpiresAt, (Map) oidcTokenMetadata.get(OAuth2Authorization.Token.CLAIMS_METADATA_NAME));
+ OidcIdToken oidcToken = new OidcIdToken(oidcIdTokenValue, tokenIssuedAt, tokenExpiresAt,
+ (Map) oidcTokenMetadata.get(OAuth2Authorization.Token.CLAIMS_METADATA_NAME));
builder.token(oidcToken, (metadata) -> metadata.putAll(oidcTokenMetadata));
}
@@ -450,8 +472,8 @@ public class JdbcOAuth2AuthorizationService implements OAuth2AuthorizationServic
}
Map refreshTokenMetadata = parseMap(getLobValue(rs, "refresh_token_metadata"));
- OAuth2RefreshToken refreshToken = new OAuth2RefreshToken(
- refreshTokenValue, tokenIssuedAt, tokenExpiresAt);
+ OAuth2RefreshToken refreshToken = new OAuth2RefreshToken(refreshTokenValue, tokenIssuedAt,
+ tokenExpiresAt);
builder.token(refreshToken, (metadata) -> metadata.putAll(refreshTokenMetadata));
}
@@ -486,9 +508,11 @@ public class JdbcOAuth2AuthorizationService implements OAuth2AuthorizationServic
if (columnValueBytes != null) {
columnValue = new String(columnValueBytes, StandardCharsets.UTF_8);
}
- } else if (Types.CLOB == columnMetadata.getDataType()) {
+ }
+ else if (Types.CLOB == columnMetadata.getDataType()) {
columnValue = this.lobHandler.getClobAsString(rs, columnName);
- } else {
+ }
+ else {
columnValue = rs.getString(columnName);
}
return columnValue;
@@ -518,8 +542,10 @@ public class JdbcOAuth2AuthorizationService implements OAuth2AuthorizationServic
private Map parseMap(String data) {
try {
- return this.objectMapper.readValue(data, new TypeReference