Skip to content

Commit

Permalink
Fix checkstyle violations for main module in 1.3.x
Browse files Browse the repository at this point in the history
Issue gh-1624
  • Loading branch information
jgrandja committed May 23, 2024
1 parent 12b71ea commit fa59682
Show file tree
Hide file tree
Showing 18 changed files with 53 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;

import static org.springframework.security.oauth2.server.authorization.authentication.OAuth2AuthenticationProviderUtils.getAuthenticatedClientElseThrowInvalidClient;

/**
* An {@link AuthenticationProvider} implementation for the OAuth 2.0 Token Exchange
* Grant.
Expand Down Expand Up @@ -103,8 +101,8 @@ public OAuth2TokenExchangeAuthenticationProvider(OAuth2AuthorizationService auth
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
OAuth2TokenExchangeAuthenticationToken tokenExchangeAuthentication = (OAuth2TokenExchangeAuthenticationToken) authentication;

OAuth2ClientAuthenticationToken clientPrincipal = getAuthenticatedClientElseThrowInvalidClient(
tokenExchangeAuthentication);
OAuth2ClientAuthenticationToken clientPrincipal = OAuth2AuthenticationProviderUtils
.getAuthenticatedClientElseThrowInvalidClient(tokenExchangeAuthentication);
RegisteredClient registeredClient = clientPrincipal.getRegisteredClient();

if (this.logger.isTraceEnabled()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ public OAuth2TokenExchangeAuthenticationToken(String requestedTokenType, String
this.actorToken = actorToken;
this.actorTokenType = actorTokenType;
this.resources = Collections
.unmodifiableSet(resources != null ? new LinkedHashSet<>(resources) : Collections.emptySet());
.unmodifiableSet((resources != null) ? new LinkedHashSet<>(resources) : Collections.emptySet());
this.audiences = Collections
.unmodifiableSet(audiences != null ? new LinkedHashSet<>(audiences) : Collections.emptySet());
this.scopes = Collections.unmodifiableSet(scopes != null ? new HashSet<>(scopes) : Collections.emptySet());
.unmodifiableSet((audiences != null) ? new LinkedHashSet<>(audiences) : Collections.emptySet());
this.scopes = Collections.unmodifiableSet((scopes != null) ? new HashSet<>(scopes) : Collections.emptySet());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class OAuth2TokenExchangeCompositeAuthenticationToken extends AbstractAut

public OAuth2TokenExchangeCompositeAuthenticationToken(Authentication subject,
List<OAuth2TokenExchangeActor> actors) {
super(subject != null ? subject.getAuthorities() : null);
super((subject != null) ? subject.getAuthorities() : null);
Assert.notNull(subject, "subject cannot be null");
Assert.notNull(actors, "actors cannot be null");
this.subject = subject;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ private static void throwInvalidClient(String parameterName, Throwable cause) {
throw new OAuth2AuthenticationException(error, error.toString(), cause);
}

private static class JwkSetSupplier implements Function<RegisteredClient, JWKSet> {
private static final class JwkSetSupplier implements Function<RegisteredClient, JWKSet> {

private static final MediaType APPLICATION_JWK_SET_JSON = new MediaType("application", "jwk-set+json");

Expand Down Expand Up @@ -168,7 +168,7 @@ private JWKSet retrieve(String jwkSetUrl) {
return jwkSet;
}

private class JwkSetHolder implements Supplier<JWKSet> {
private final class JwkSetHolder implements Supplier<JWKSet> {

private final ReentrantReadWriteLock rwLock = new ReentrantReadWriteLock();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
*/
final class DefaultOAuth2TokenCustomizers {

private DefaultOAuth2TokenCustomizers() {
}

static OAuth2TokenCustomizer<JwtEncodingContext> jwtCustomizer() {
return (context) -> context.getClaims().claims((claims) -> customize(context, claims));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;

import static org.springframework.security.oauth2.server.authorization.config.annotation.web.configurers.OAuth2ConfigurerUtils.withMultipleIssuersPattern;

/**
* Configurer for the OAuth 2.0 Authorization Endpoint.
*
Expand Down Expand Up @@ -240,7 +238,8 @@ void init(HttpSecurity httpSecurity) {
AuthorizationServerSettings authorizationServerSettings = OAuth2ConfigurerUtils
.getAuthorizationServerSettings(httpSecurity);
String authorizationEndpointUri = authorizationServerSettings.isMultipleIssuersAllowed()
? withMultipleIssuersPattern(authorizationServerSettings.getAuthorizationEndpoint())
? OAuth2ConfigurerUtils
.withMultipleIssuersPattern(authorizationServerSettings.getAuthorizationEndpoint())
: authorizationServerSettings.getAuthorizationEndpoint();
this.requestMatcher = new OrRequestMatcher(
new AntPathRequestMatcher(authorizationEndpointUri, HttpMethod.GET.name()),
Expand All @@ -261,7 +260,8 @@ void configure(HttpSecurity httpSecurity) {
AuthorizationServerSettings authorizationServerSettings = OAuth2ConfigurerUtils
.getAuthorizationServerSettings(httpSecurity);
String authorizationEndpointUri = authorizationServerSettings.isMultipleIssuersAllowed()
? withMultipleIssuersPattern(authorizationServerSettings.getAuthorizationEndpoint())
? OAuth2ConfigurerUtils
.withMultipleIssuersPattern(authorizationServerSettings.getAuthorizationEndpoint())
: authorizationServerSettings.getAuthorizationEndpoint();
OAuth2AuthorizationEndpointFilter authorizationEndpointFilter = new OAuth2AuthorizationEndpointFilter(
authenticationManager, authorizationEndpointUri);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@
import org.springframework.security.web.util.matcher.RequestMatcher;
import org.springframework.util.Assert;

import static org.springframework.security.oauth2.server.authorization.config.annotation.web.configurers.OAuth2ConfigurerUtils.withMultipleIssuersPattern;

/**
* An {@link AbstractHttpConfigurer} for OAuth 2.0 Authorization Server support.
*
Expand Down Expand Up @@ -327,7 +325,7 @@ public void init(HttpSecurity httpSecurity) {
requestMatchers.add(configurer.getRequestMatcher());
});
String jwkSetEndpointUri = authorizationServerSettings.isMultipleIssuersAllowed()
? withMultipleIssuersPattern(authorizationServerSettings.getJwkSetEndpoint())
? OAuth2ConfigurerUtils.withMultipleIssuersPattern(authorizationServerSettings.getJwkSetEndpoint())
: authorizationServerSettings.getJwkSetEndpoint();
requestMatchers.add(new AntPathRequestMatcher(jwkSetEndpointUri, HttpMethod.GET.name()));
this.endpointsMatcher = new OrRequestMatcher(requestMatchers);
Expand Down Expand Up @@ -357,7 +355,7 @@ public void configure(HttpSecurity httpSecurity) {
JWKSource<com.nimbusds.jose.proc.SecurityContext> jwkSource = OAuth2ConfigurerUtils.getJwkSource(httpSecurity);
if (jwkSource != null) {
String jwkSetEndpointUri = authorizationServerSettings.isMultipleIssuersAllowed()
? withMultipleIssuersPattern(authorizationServerSettings.getJwkSetEndpoint())
? OAuth2ConfigurerUtils.withMultipleIssuersPattern(authorizationServerSettings.getJwkSetEndpoint())
: authorizationServerSettings.getJwkSetEndpoint();
NimbusJwkSetEndpointFilter jwkSetEndpointFilter = new NimbusJwkSetEndpointFilter(jwkSource,
jwkSetEndpointUri);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@
import org.springframework.security.web.util.matcher.RequestMatcher;
import org.springframework.util.Assert;

import static org.springframework.security.oauth2.server.authorization.config.annotation.web.configurers.OAuth2ConfigurerUtils.withMultipleIssuersPattern;

/**
* Configurer for OAuth 2.0 Client Authentication.
*
Expand Down Expand Up @@ -184,16 +182,19 @@ void init(HttpSecurity httpSecurity) {
AuthorizationServerSettings authorizationServerSettings = OAuth2ConfigurerUtils
.getAuthorizationServerSettings(httpSecurity);
String tokenEndpointUri = authorizationServerSettings.isMultipleIssuersAllowed()
? withMultipleIssuersPattern(authorizationServerSettings.getTokenEndpoint())
? OAuth2ConfigurerUtils.withMultipleIssuersPattern(authorizationServerSettings.getTokenEndpoint())
: authorizationServerSettings.getTokenEndpoint();
String tokenIntrospectionEndpointUri = authorizationServerSettings.isMultipleIssuersAllowed()
? withMultipleIssuersPattern(authorizationServerSettings.getTokenIntrospectionEndpoint())
? OAuth2ConfigurerUtils
.withMultipleIssuersPattern(authorizationServerSettings.getTokenIntrospectionEndpoint())
: authorizationServerSettings.getTokenIntrospectionEndpoint();
String tokenRevocationEndpointUri = authorizationServerSettings.isMultipleIssuersAllowed()
? withMultipleIssuersPattern(authorizationServerSettings.getTokenRevocationEndpoint())
? OAuth2ConfigurerUtils
.withMultipleIssuersPattern(authorizationServerSettings.getTokenRevocationEndpoint())
: authorizationServerSettings.getTokenRevocationEndpoint();
String deviceAuthorizationEndpointUri = authorizationServerSettings.isMultipleIssuersAllowed()
? withMultipleIssuersPattern(authorizationServerSettings.getDeviceAuthorizationEndpoint())
? OAuth2ConfigurerUtils
.withMultipleIssuersPattern(authorizationServerSettings.getDeviceAuthorizationEndpoint())
: authorizationServerSettings.getDeviceAuthorizationEndpoint();
this.requestMatcher = new OrRequestMatcher(new AntPathRequestMatcher(tokenEndpointUri, HttpMethod.POST.name()),
new AntPathRequestMatcher(tokenIntrospectionEndpointUri, HttpMethod.POST.name()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;

import static org.springframework.security.oauth2.server.authorization.config.annotation.web.configurers.OAuth2ConfigurerUtils.withMultipleIssuersPattern;

/**
* Configurer for the OAuth 2.0 Device Authorization Endpoint.
*
Expand Down Expand Up @@ -201,7 +199,8 @@ public void init(HttpSecurity builder) {
AuthorizationServerSettings authorizationServerSettings = OAuth2ConfigurerUtils
.getAuthorizationServerSettings(builder);
String deviceAuthorizationEndpointUri = authorizationServerSettings.isMultipleIssuersAllowed()
? withMultipleIssuersPattern(authorizationServerSettings.getDeviceAuthorizationEndpoint())
? OAuth2ConfigurerUtils
.withMultipleIssuersPattern(authorizationServerSettings.getDeviceAuthorizationEndpoint())
: authorizationServerSettings.getDeviceAuthorizationEndpoint();
this.requestMatcher = new AntPathRequestMatcher(deviceAuthorizationEndpointUri, HttpMethod.POST.name());

Expand All @@ -221,7 +220,8 @@ public void configure(HttpSecurity builder) {
.getAuthorizationServerSettings(builder);

String deviceAuthorizationEndpointUri = authorizationServerSettings.isMultipleIssuersAllowed()
? withMultipleIssuersPattern(authorizationServerSettings.getDeviceAuthorizationEndpoint())
? OAuth2ConfigurerUtils
.withMultipleIssuersPattern(authorizationServerSettings.getDeviceAuthorizationEndpoint())
: authorizationServerSettings.getDeviceAuthorizationEndpoint();
OAuth2DeviceAuthorizationEndpointFilter deviceAuthorizationEndpointFilter = new OAuth2DeviceAuthorizationEndpointFilter(
authenticationManager, deviceAuthorizationEndpointUri);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;

import static org.springframework.security.oauth2.server.authorization.config.annotation.web.configurers.OAuth2ConfigurerUtils.withMultipleIssuersPattern;

/**
* Configurer for the OAuth 2.0 Device Verification Endpoint.
*
Expand Down Expand Up @@ -236,7 +234,8 @@ public void init(HttpSecurity builder) {
AuthorizationServerSettings authorizationServerSettings = OAuth2ConfigurerUtils
.getAuthorizationServerSettings(builder);
String deviceVerificationEndpointUri = authorizationServerSettings.isMultipleIssuersAllowed()
? withMultipleIssuersPattern(authorizationServerSettings.getDeviceVerificationEndpoint())
? OAuth2ConfigurerUtils
.withMultipleIssuersPattern(authorizationServerSettings.getDeviceVerificationEndpoint())
: authorizationServerSettings.getDeviceVerificationEndpoint();
this.requestMatcher = new OrRequestMatcher(
new AntPathRequestMatcher(deviceVerificationEndpointUri, HttpMethod.GET.name()),
Expand All @@ -258,7 +257,8 @@ public void configure(HttpSecurity builder) {
.getAuthorizationServerSettings(builder);

String deviceVerificationEndpointUri = authorizationServerSettings.isMultipleIssuersAllowed()
? withMultipleIssuersPattern(authorizationServerSettings.getDeviceVerificationEndpoint())
? OAuth2ConfigurerUtils
.withMultipleIssuersPattern(authorizationServerSettings.getDeviceVerificationEndpoint())
: authorizationServerSettings.getDeviceVerificationEndpoint();
OAuth2DeviceVerificationEndpointFilter deviceVerificationEndpointFilter = new OAuth2DeviceVerificationEndpointFilter(
authenticationManager, deviceVerificationEndpointUri);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@
import org.springframework.security.web.util.matcher.RequestMatcher;
import org.springframework.util.Assert;

import static org.springframework.security.oauth2.server.authorization.config.annotation.web.configurers.OAuth2ConfigurerUtils.withMultipleIssuersPattern;

/**
* Configurer for the OAuth 2.0 Token Endpoint.
*
Expand Down Expand Up @@ -189,7 +187,7 @@ void init(HttpSecurity httpSecurity) {
AuthorizationServerSettings authorizationServerSettings = OAuth2ConfigurerUtils
.getAuthorizationServerSettings(httpSecurity);
String tokenEndpointUri = authorizationServerSettings.isMultipleIssuersAllowed()
? withMultipleIssuersPattern(authorizationServerSettings.getTokenEndpoint())
? OAuth2ConfigurerUtils.withMultipleIssuersPattern(authorizationServerSettings.getTokenEndpoint())
: authorizationServerSettings.getTokenEndpoint();
this.requestMatcher = new AntPathRequestMatcher(tokenEndpointUri, HttpMethod.POST.name());

Expand All @@ -209,7 +207,7 @@ void configure(HttpSecurity httpSecurity) {
.getAuthorizationServerSettings(httpSecurity);

String tokenEndpointUri = authorizationServerSettings.isMultipleIssuersAllowed()
? withMultipleIssuersPattern(authorizationServerSettings.getTokenEndpoint())
? OAuth2ConfigurerUtils.withMultipleIssuersPattern(authorizationServerSettings.getTokenEndpoint())
: authorizationServerSettings.getTokenEndpoint();
OAuth2TokenEndpointFilter tokenEndpointFilter = new OAuth2TokenEndpointFilter(authenticationManager,
tokenEndpointUri);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@
import org.springframework.security.web.util.matcher.RequestMatcher;
import org.springframework.util.Assert;

import static org.springframework.security.oauth2.server.authorization.config.annotation.web.configurers.OAuth2ConfigurerUtils.withMultipleIssuersPattern;

/**
* Configurer for the OAuth 2.0 Token Introspection Endpoint.
*
Expand Down Expand Up @@ -184,7 +182,8 @@ void init(HttpSecurity httpSecurity) {
AuthorizationServerSettings authorizationServerSettings = OAuth2ConfigurerUtils
.getAuthorizationServerSettings(httpSecurity);
String tokenIntrospectionEndpointUri = authorizationServerSettings.isMultipleIssuersAllowed()
? withMultipleIssuersPattern(authorizationServerSettings.getTokenIntrospectionEndpoint())
? OAuth2ConfigurerUtils
.withMultipleIssuersPattern(authorizationServerSettings.getTokenIntrospectionEndpoint())
: authorizationServerSettings.getTokenIntrospectionEndpoint();
this.requestMatcher = new AntPathRequestMatcher(tokenIntrospectionEndpointUri, HttpMethod.POST.name());

Expand All @@ -203,7 +202,8 @@ void configure(HttpSecurity httpSecurity) {
AuthorizationServerSettings authorizationServerSettings = OAuth2ConfigurerUtils
.getAuthorizationServerSettings(httpSecurity);
String tokenIntrospectionEndpointUri = authorizationServerSettings.isMultipleIssuersAllowed()
? withMultipleIssuersPattern(authorizationServerSettings.getTokenIntrospectionEndpoint())
? OAuth2ConfigurerUtils
.withMultipleIssuersPattern(authorizationServerSettings.getTokenIntrospectionEndpoint())
: authorizationServerSettings.getTokenIntrospectionEndpoint();
OAuth2TokenIntrospectionEndpointFilter introspectionEndpointFilter = new OAuth2TokenIntrospectionEndpointFilter(
authenticationManager, tokenIntrospectionEndpointUri);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@
import org.springframework.security.web.util.matcher.RequestMatcher;
import org.springframework.util.Assert;

import static org.springframework.security.oauth2.server.authorization.config.annotation.web.configurers.OAuth2ConfigurerUtils.withMultipleIssuersPattern;

/**
* Configurer for the OAuth 2.0 Token Revocation Endpoint.
*
Expand Down Expand Up @@ -183,7 +181,8 @@ void init(HttpSecurity httpSecurity) {
AuthorizationServerSettings authorizationServerSettings = OAuth2ConfigurerUtils
.getAuthorizationServerSettings(httpSecurity);
String tokenRevocationEndpointUri = authorizationServerSettings.isMultipleIssuersAllowed()
? withMultipleIssuersPattern(authorizationServerSettings.getTokenRevocationEndpoint())
? OAuth2ConfigurerUtils
.withMultipleIssuersPattern(authorizationServerSettings.getTokenRevocationEndpoint())
: authorizationServerSettings.getTokenRevocationEndpoint();
this.requestMatcher = new AntPathRequestMatcher(tokenRevocationEndpointUri, HttpMethod.POST.name());

Expand All @@ -203,7 +202,8 @@ void configure(HttpSecurity httpSecurity) {
.getAuthorizationServerSettings(httpSecurity);

String tokenRevocationEndpointUri = authorizationServerSettings.isMultipleIssuersAllowed()
? withMultipleIssuersPattern(authorizationServerSettings.getTokenRevocationEndpoint())
? OAuth2ConfigurerUtils
.withMultipleIssuersPattern(authorizationServerSettings.getTokenRevocationEndpoint())
: authorizationServerSettings.getTokenRevocationEndpoint();
OAuth2TokenRevocationEndpointFilter revocationEndpointFilter = new OAuth2TokenRevocationEndpointFilter(
authenticationManager, tokenRevocationEndpointUri);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@
import org.springframework.security.web.util.matcher.RequestMatcher;
import org.springframework.util.Assert;

import static org.springframework.security.oauth2.server.authorization.config.annotation.web.configurers.OAuth2ConfigurerUtils.withMultipleIssuersPattern;

/**
* Configurer for OpenID Connect 1.0 Dynamic Client Registration Endpoint.
*
Expand Down Expand Up @@ -194,7 +192,8 @@ void init(HttpSecurity httpSecurity) {
AuthorizationServerSettings authorizationServerSettings = OAuth2ConfigurerUtils
.getAuthorizationServerSettings(httpSecurity);
String clientRegistrationEndpointUri = authorizationServerSettings.isMultipleIssuersAllowed()
? withMultipleIssuersPattern(authorizationServerSettings.getOidcClientRegistrationEndpoint())
? OAuth2ConfigurerUtils
.withMultipleIssuersPattern(authorizationServerSettings.getOidcClientRegistrationEndpoint())
: authorizationServerSettings.getOidcClientRegistrationEndpoint();
this.requestMatcher = new OrRequestMatcher(
new AntPathRequestMatcher(clientRegistrationEndpointUri, HttpMethod.POST.name()),
Expand All @@ -216,7 +215,8 @@ void configure(HttpSecurity httpSecurity) {
.getAuthorizationServerSettings(httpSecurity);

String clientRegistrationEndpointUri = authorizationServerSettings.isMultipleIssuersAllowed()
? withMultipleIssuersPattern(authorizationServerSettings.getOidcClientRegistrationEndpoint())
? OAuth2ConfigurerUtils
.withMultipleIssuersPattern(authorizationServerSettings.getOidcClientRegistrationEndpoint())
: authorizationServerSettings.getOidcClientRegistrationEndpoint();
OidcClientRegistrationEndpointFilter oidcClientRegistrationEndpointFilter = new OidcClientRegistrationEndpointFilter(
authenticationManager, clientRegistrationEndpointUri);
Expand Down
Loading

0 comments on commit fa59682

Please sign in to comment.