The following issues were found

oauth2-authorization-server/src/test/java/org/springframework/security/oauth2/server/authorization/web/authentication/ClientSecretPostAuthenticationConverterTests.java
33 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 40

               * @author Anoop Garlapati
 */
public class ClientSecretPostAuthenticationConverterTests {
	private final ClientSecretPostAuthenticationConverter converter = new ClientSecretPostAuthenticationConverter();

	@Test
	public void convertWhenMissingClientIdThenReturnNull() {
		MockHttpServletRequest request = new MockHttpServletRequest();
		Authentication authentication = this.converter.convert(request);

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 46

              	public void convertWhenMissingClientIdThenReturnNull() {
		MockHttpServletRequest request = new MockHttpServletRequest();
		Authentication authentication = this.converter.convert(request);
		assertThat(authentication).isNull();
	}

	@Test
	public void convertWhenMultipleClientIdsThenInvalidRequestError() {
		MockHttpServletRequest request = new MockHttpServletRequest();

            

Reported by PMD.

The String literal 'client-1' appears 7 times in this file; the first occurrence is on line 52
Error

Line: 52

              	@Test
	public void convertWhenMultipleClientIdsThenInvalidRequestError() {
		MockHttpServletRequest request = new MockHttpServletRequest();
		request.addParameter(OAuth2ParameterNames.CLIENT_ID, "client-1");
		request.addParameter(OAuth2ParameterNames.CLIENT_ID, "client-2");
		assertThatThrownBy(() -> this.converter.convert(request))
				.isInstanceOf(OAuth2AuthenticationException.class)
				.extracting(ex -> ((OAuth2AuthenticationException) ex).getError())
				.extracting("errorCode")

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 54

              		MockHttpServletRequest request = new MockHttpServletRequest();
		request.addParameter(OAuth2ParameterNames.CLIENT_ID, "client-1");
		request.addParameter(OAuth2ParameterNames.CLIENT_ID, "client-2");
		assertThatThrownBy(() -> this.converter.convert(request))
				.isInstanceOf(OAuth2AuthenticationException.class)
				.extracting(ex -> ((OAuth2AuthenticationException) ex).getError())
				.extracting("errorCode")
				.isEqualTo(OAuth2ErrorCodes.INVALID_REQUEST);
	}

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 54

              		MockHttpServletRequest request = new MockHttpServletRequest();
		request.addParameter(OAuth2ParameterNames.CLIENT_ID, "client-1");
		request.addParameter(OAuth2ParameterNames.CLIENT_ID, "client-2");
		assertThatThrownBy(() -> this.converter.convert(request))
				.isInstanceOf(OAuth2AuthenticationException.class)
				.extracting(ex -> ((OAuth2AuthenticationException) ex).getError())
				.extracting("errorCode")
				.isEqualTo(OAuth2ErrorCodes.INVALID_REQUEST);
	}

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 54

              		MockHttpServletRequest request = new MockHttpServletRequest();
		request.addParameter(OAuth2ParameterNames.CLIENT_ID, "client-1");
		request.addParameter(OAuth2ParameterNames.CLIENT_ID, "client-2");
		assertThatThrownBy(() -> this.converter.convert(request))
				.isInstanceOf(OAuth2AuthenticationException.class)
				.extracting(ex -> ((OAuth2AuthenticationException) ex).getError())
				.extracting("errorCode")
				.isEqualTo(OAuth2ErrorCodes.INVALID_REQUEST);
	}

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 54

              		MockHttpServletRequest request = new MockHttpServletRequest();
		request.addParameter(OAuth2ParameterNames.CLIENT_ID, "client-1");
		request.addParameter(OAuth2ParameterNames.CLIENT_ID, "client-2");
		assertThatThrownBy(() -> this.converter.convert(request))
				.isInstanceOf(OAuth2AuthenticationException.class)
				.extracting(ex -> ((OAuth2AuthenticationException) ex).getError())
				.extracting("errorCode")
				.isEqualTo(OAuth2ErrorCodes.INVALID_REQUEST);
	}

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 66

              		MockHttpServletRequest request = new MockHttpServletRequest();
		request.addParameter(OAuth2ParameterNames.CLIENT_ID, "client-1");
		Authentication authentication = this.converter.convert(request);
		assertThat(authentication).isNull();
	}

	@Test
	public void convertWhenMultipleClientSecretsThenInvalidRequestError() {
		MockHttpServletRequest request = new MockHttpServletRequest();

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 75

              		request.addParameter(OAuth2ParameterNames.CLIENT_ID, "client-1");
		request.addParameter(OAuth2ParameterNames.CLIENT_SECRET, "client-secret-1");
		request.addParameter(OAuth2ParameterNames.CLIENT_SECRET, "client-secret-2");
		assertThatThrownBy(() -> this.converter.convert(request))
				.isInstanceOf(OAuth2AuthenticationException.class)
				.extracting(ex -> ((OAuth2AuthenticationException) ex).getError())
				.extracting("errorCode")
				.isEqualTo(OAuth2ErrorCodes.INVALID_REQUEST);
	}

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 75

              		request.addParameter(OAuth2ParameterNames.CLIENT_ID, "client-1");
		request.addParameter(OAuth2ParameterNames.CLIENT_SECRET, "client-secret-1");
		request.addParameter(OAuth2ParameterNames.CLIENT_SECRET, "client-secret-2");
		assertThatThrownBy(() -> this.converter.convert(request))
				.isInstanceOf(OAuth2AuthenticationException.class)
				.extracting(ex -> ((OAuth2AuthenticationException) ex).getError())
				.extracting("errorCode")
				.isEqualTo(OAuth2ErrorCodes.INVALID_REQUEST);
	}

            

Reported by PMD.

oauth2-authorization-server/src/test/java/org/springframework/security/oauth2/server/authorization/authentication/OAuth2TokenRevocationAuthenticationTokenTests.java
32 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 39

               * @author Joe Grandja
 */
public class OAuth2TokenRevocationAuthenticationTokenTests {
	private String token = "token";
	private RegisteredClient registeredClient = TestRegisteredClients.registeredClient().build();
	private OAuth2ClientAuthenticationToken clientPrincipal = new OAuth2ClientAuthenticationToken(
			this.registeredClient, ClientAuthenticationMethod.CLIENT_SECRET_BASIC, this.registeredClient.getClientSecret());
	private String tokenTypeHint = OAuth2TokenType.ACCESS_TOKEN.getValue();
	private OAuth2AccessToken accessToken = new OAuth2AccessToken(

            

Reported by PMD.

Private field 'token' could be made final; it is only initialized in the declaration or constructor.
Design

Line: 39

               * @author Joe Grandja
 */
public class OAuth2TokenRevocationAuthenticationTokenTests {
	private String token = "token";
	private RegisteredClient registeredClient = TestRegisteredClients.registeredClient().build();
	private OAuth2ClientAuthenticationToken clientPrincipal = new OAuth2ClientAuthenticationToken(
			this.registeredClient, ClientAuthenticationMethod.CLIENT_SECRET_BASIC, this.registeredClient.getClientSecret());
	private String tokenTypeHint = OAuth2TokenType.ACCESS_TOKEN.getValue();
	private OAuth2AccessToken accessToken = new OAuth2AccessToken(

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 40

               */
public class OAuth2TokenRevocationAuthenticationTokenTests {
	private String token = "token";
	private RegisteredClient registeredClient = TestRegisteredClients.registeredClient().build();
	private OAuth2ClientAuthenticationToken clientPrincipal = new OAuth2ClientAuthenticationToken(
			this.registeredClient, ClientAuthenticationMethod.CLIENT_SECRET_BASIC, this.registeredClient.getClientSecret());
	private String tokenTypeHint = OAuth2TokenType.ACCESS_TOKEN.getValue();
	private OAuth2AccessToken accessToken = new OAuth2AccessToken(
			OAuth2AccessToken.TokenType.BEARER, this.token,

            

Reported by PMD.

Private field 'registeredClient' could be made final; it is only initialized in the declaration or constructor.
Design

Line: 40

               */
public class OAuth2TokenRevocationAuthenticationTokenTests {
	private String token = "token";
	private RegisteredClient registeredClient = TestRegisteredClients.registeredClient().build();
	private OAuth2ClientAuthenticationToken clientPrincipal = new OAuth2ClientAuthenticationToken(
			this.registeredClient, ClientAuthenticationMethod.CLIENT_SECRET_BASIC, this.registeredClient.getClientSecret());
	private String tokenTypeHint = OAuth2TokenType.ACCESS_TOKEN.getValue();
	private OAuth2AccessToken accessToken = new OAuth2AccessToken(
			OAuth2AccessToken.TokenType.BEARER, this.token,

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 41

              public class OAuth2TokenRevocationAuthenticationTokenTests {
	private String token = "token";
	private RegisteredClient registeredClient = TestRegisteredClients.registeredClient().build();
	private OAuth2ClientAuthenticationToken clientPrincipal = new OAuth2ClientAuthenticationToken(
			this.registeredClient, ClientAuthenticationMethod.CLIENT_SECRET_BASIC, this.registeredClient.getClientSecret());
	private String tokenTypeHint = OAuth2TokenType.ACCESS_TOKEN.getValue();
	private OAuth2AccessToken accessToken = new OAuth2AccessToken(
			OAuth2AccessToken.TokenType.BEARER, this.token,
			Instant.now(), Instant.now().plus(Duration.ofHours(1)));

            

Reported by PMD.

Private field 'clientPrincipal' could be made final; it is only initialized in the declaration or constructor.
Design

Line: 41

              public class OAuth2TokenRevocationAuthenticationTokenTests {
	private String token = "token";
	private RegisteredClient registeredClient = TestRegisteredClients.registeredClient().build();
	private OAuth2ClientAuthenticationToken clientPrincipal = new OAuth2ClientAuthenticationToken(
			this.registeredClient, ClientAuthenticationMethod.CLIENT_SECRET_BASIC, this.registeredClient.getClientSecret());
	private String tokenTypeHint = OAuth2TokenType.ACCESS_TOKEN.getValue();
	private OAuth2AccessToken accessToken = new OAuth2AccessToken(
			OAuth2AccessToken.TokenType.BEARER, this.token,
			Instant.now(), Instant.now().plus(Duration.ofHours(1)));

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 43

              	private RegisteredClient registeredClient = TestRegisteredClients.registeredClient().build();
	private OAuth2ClientAuthenticationToken clientPrincipal = new OAuth2ClientAuthenticationToken(
			this.registeredClient, ClientAuthenticationMethod.CLIENT_SECRET_BASIC, this.registeredClient.getClientSecret());
	private String tokenTypeHint = OAuth2TokenType.ACCESS_TOKEN.getValue();
	private OAuth2AccessToken accessToken = new OAuth2AccessToken(
			OAuth2AccessToken.TokenType.BEARER, this.token,
			Instant.now(), Instant.now().plus(Duration.ofHours(1)));

	@Test

            

Reported by PMD.

Private field 'tokenTypeHint' could be made final; it is only initialized in the declaration or constructor.
Design

Line: 43

              	private RegisteredClient registeredClient = TestRegisteredClients.registeredClient().build();
	private OAuth2ClientAuthenticationToken clientPrincipal = new OAuth2ClientAuthenticationToken(
			this.registeredClient, ClientAuthenticationMethod.CLIENT_SECRET_BASIC, this.registeredClient.getClientSecret());
	private String tokenTypeHint = OAuth2TokenType.ACCESS_TOKEN.getValue();
	private OAuth2AccessToken accessToken = new OAuth2AccessToken(
			OAuth2AccessToken.TokenType.BEARER, this.token,
			Instant.now(), Instant.now().plus(Duration.ofHours(1)));

	@Test

            

Reported by PMD.

Private field 'accessToken' could be made final; it is only initialized in the declaration or constructor.
Design

Line: 44

              	private OAuth2ClientAuthenticationToken clientPrincipal = new OAuth2ClientAuthenticationToken(
			this.registeredClient, ClientAuthenticationMethod.CLIENT_SECRET_BASIC, this.registeredClient.getClientSecret());
	private String tokenTypeHint = OAuth2TokenType.ACCESS_TOKEN.getValue();
	private OAuth2AccessToken accessToken = new OAuth2AccessToken(
			OAuth2AccessToken.TokenType.BEARER, this.token,
			Instant.now(), Instant.now().plus(Duration.ofHours(1)));

	@Test
	public void constructorWhenTokenNullThenThrowIllegalArgumentException() {

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 44

              	private OAuth2ClientAuthenticationToken clientPrincipal = new OAuth2ClientAuthenticationToken(
			this.registeredClient, ClientAuthenticationMethod.CLIENT_SECRET_BASIC, this.registeredClient.getClientSecret());
	private String tokenTypeHint = OAuth2TokenType.ACCESS_TOKEN.getValue();
	private OAuth2AccessToken accessToken = new OAuth2AccessToken(
			OAuth2AccessToken.TokenType.BEARER, this.token,
			Instant.now(), Instant.now().plus(Duration.ofHours(1)));

	@Test
	public void constructorWhenTokenNullThenThrowIllegalArgumentException() {

            

Reported by PMD.

oauth2-authorization-server/src/test/java/org/springframework/security/oauth2/server/authorization/client/TestRegisteredClients.java
32 issues
All methods are static. Consider using a utility class instead. Alternatively, you could add a private constructor or make the class abstract to silence this warning.
Design

Line: 28

              /**
 * @author Anoop Garlapati
 */
public class TestRegisteredClients {

	public static RegisteredClient.Builder registeredClient() {
		return RegisteredClient.withId("registration-1")
				.clientId("client-1")
				.clientIdIssuedAt(Instant.now().truncatedTo(ChronoUnit.SECONDS))

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 31

              public class TestRegisteredClients {

	public static RegisteredClient.Builder registeredClient() {
		return RegisteredClient.withId("registration-1")
				.clientId("client-1")
				.clientIdIssuedAt(Instant.now().truncatedTo(ChronoUnit.SECONDS))
				.clientSecret("secret")
				.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE)
				.authorizationGrantType(AuthorizationGrantType.REFRESH_TOKEN)

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 31

              public class TestRegisteredClients {

	public static RegisteredClient.Builder registeredClient() {
		return RegisteredClient.withId("registration-1")
				.clientId("client-1")
				.clientIdIssuedAt(Instant.now().truncatedTo(ChronoUnit.SECONDS))
				.clientSecret("secret")
				.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE)
				.authorizationGrantType(AuthorizationGrantType.REFRESH_TOKEN)

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 31

              public class TestRegisteredClients {

	public static RegisteredClient.Builder registeredClient() {
		return RegisteredClient.withId("registration-1")
				.clientId("client-1")
				.clientIdIssuedAt(Instant.now().truncatedTo(ChronoUnit.SECONDS))
				.clientSecret("secret")
				.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE)
				.authorizationGrantType(AuthorizationGrantType.REFRESH_TOKEN)

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 31

              public class TestRegisteredClients {

	public static RegisteredClient.Builder registeredClient() {
		return RegisteredClient.withId("registration-1")
				.clientId("client-1")
				.clientIdIssuedAt(Instant.now().truncatedTo(ChronoUnit.SECONDS))
				.clientSecret("secret")
				.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE)
				.authorizationGrantType(AuthorizationGrantType.REFRESH_TOKEN)

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 31

              public class TestRegisteredClients {

	public static RegisteredClient.Builder registeredClient() {
		return RegisteredClient.withId("registration-1")
				.clientId("client-1")
				.clientIdIssuedAt(Instant.now().truncatedTo(ChronoUnit.SECONDS))
				.clientSecret("secret")
				.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE)
				.authorizationGrantType(AuthorizationGrantType.REFRESH_TOKEN)

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 31

              public class TestRegisteredClients {

	public static RegisteredClient.Builder registeredClient() {
		return RegisteredClient.withId("registration-1")
				.clientId("client-1")
				.clientIdIssuedAt(Instant.now().truncatedTo(ChronoUnit.SECONDS))
				.clientSecret("secret")
				.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE)
				.authorizationGrantType(AuthorizationGrantType.REFRESH_TOKEN)

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 31

              public class TestRegisteredClients {

	public static RegisteredClient.Builder registeredClient() {
		return RegisteredClient.withId("registration-1")
				.clientId("client-1")
				.clientIdIssuedAt(Instant.now().truncatedTo(ChronoUnit.SECONDS))
				.clientSecret("secret")
				.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE)
				.authorizationGrantType(AuthorizationGrantType.REFRESH_TOKEN)

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 31

              public class TestRegisteredClients {

	public static RegisteredClient.Builder registeredClient() {
		return RegisteredClient.withId("registration-1")
				.clientId("client-1")
				.clientIdIssuedAt(Instant.now().truncatedTo(ChronoUnit.SECONDS))
				.clientSecret("secret")
				.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE)
				.authorizationGrantType(AuthorizationGrantType.REFRESH_TOKEN)

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 33

              	public static RegisteredClient.Builder registeredClient() {
		return RegisteredClient.withId("registration-1")
				.clientId("client-1")
				.clientIdIssuedAt(Instant.now().truncatedTo(ChronoUnit.SECONDS))
				.clientSecret("secret")
				.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE)
				.authorizationGrantType(AuthorizationGrantType.REFRESH_TOKEN)
				.clientAuthenticationMethod(ClientAuthenticationMethod.CLIENT_SECRET_BASIC)
				.redirectUri("https://example.com")

            

Reported by PMD.

oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/authentication/OAuth2AuthorizationCodeRequestAuthenticationToken.java
31 issues
The class 'OAuth2AuthorizationCodeRequestAuthenticationToken' is suspected to be a Data Class (WOC=16.667%, NOPA=0, NOAM=10, WMC=13)
Design

Line: 42

               * @since 0.1.2
 * @see OAuth2AuthorizationCodeRequestAuthenticationProvider
 */
public final class OAuth2AuthorizationCodeRequestAuthenticationToken extends AbstractAuthenticationToken {
	private static final long serialVersionUID = Version.SERIAL_VERSION_UID;
	private String authorizationUri;
	private String clientId;
	private Authentication principal;
	private String redirectUri;

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 44

               */
public final class OAuth2AuthorizationCodeRequestAuthenticationToken extends AbstractAuthenticationToken {
	private static final long serialVersionUID = Version.SERIAL_VERSION_UID;
	private String authorizationUri;
	private String clientId;
	private Authentication principal;
	private String redirectUri;
	private Set<String> scopes;
	private String state;

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 45

              public final class OAuth2AuthorizationCodeRequestAuthenticationToken extends AbstractAuthenticationToken {
	private static final long serialVersionUID = Version.SERIAL_VERSION_UID;
	private String authorizationUri;
	private String clientId;
	private Authentication principal;
	private String redirectUri;
	private Set<String> scopes;
	private String state;
	private Map<String, Object> additionalParameters;

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 46

              	private static final long serialVersionUID = Version.SERIAL_VERSION_UID;
	private String authorizationUri;
	private String clientId;
	private Authentication principal;
	private String redirectUri;
	private Set<String> scopes;
	private String state;
	private Map<String, Object> additionalParameters;
	private boolean consentRequired;

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 47

              	private String authorizationUri;
	private String clientId;
	private Authentication principal;
	private String redirectUri;
	private Set<String> scopes;
	private String state;
	private Map<String, Object> additionalParameters;
	private boolean consentRequired;
	private boolean consent;

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 48

              	private String clientId;
	private Authentication principal;
	private String redirectUri;
	private Set<String> scopes;
	private String state;
	private Map<String, Object> additionalParameters;
	private boolean consentRequired;
	private boolean consent;
	private OAuth2AuthorizationCode authorizationCode;

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 49

              	private Authentication principal;
	private String redirectUri;
	private Set<String> scopes;
	private String state;
	private Map<String, Object> additionalParameters;
	private boolean consentRequired;
	private boolean consent;
	private OAuth2AuthorizationCode authorizationCode;


            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 50

              	private String redirectUri;
	private Set<String> scopes;
	private String state;
	private Map<String, Object> additionalParameters;
	private boolean consentRequired;
	private boolean consent;
	private OAuth2AuthorizationCode authorizationCode;

	private OAuth2AuthorizationCodeRequestAuthenticationToken() {

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 51

              	private Set<String> scopes;
	private String state;
	private Map<String, Object> additionalParameters;
	private boolean consentRequired;
	private boolean consent;
	private OAuth2AuthorizationCode authorizationCode;

	private OAuth2AuthorizationCodeRequestAuthenticationToken() {
		super(Collections.emptyList());

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 52

              	private String state;
	private Map<String, Object> additionalParameters;
	private boolean consentRequired;
	private boolean consent;
	private OAuth2AuthorizationCode authorizationCode;

	private OAuth2AuthorizationCodeRequestAuthenticationToken() {
		super(Collections.emptyList());
	}

            

Reported by PMD.

oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/OAuth2Authorization.java
30 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 62

              	public static final String AUTHORIZED_SCOPE_ATTRIBUTE_NAME =
			OAuth2Authorization.class.getName().concat(".AUTHORIZED_SCOPE");

	private String id;
	private String registeredClientId;
	private String principalName;
	private AuthorizationGrantType authorizationGrantType;
	private Map<Class<? extends OAuth2Token>, Token<?>> tokens;
	private Map<String, Object> attributes;

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 63

              			OAuth2Authorization.class.getName().concat(".AUTHORIZED_SCOPE");

	private String id;
	private String registeredClientId;
	private String principalName;
	private AuthorizationGrantType authorizationGrantType;
	private Map<Class<? extends OAuth2Token>, Token<?>> tokens;
	private Map<String, Object> attributes;


            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 64

              
	private String id;
	private String registeredClientId;
	private String principalName;
	private AuthorizationGrantType authorizationGrantType;
	private Map<Class<? extends OAuth2Token>, Token<?>> tokens;
	private Map<String, Object> attributes;

	protected OAuth2Authorization() {

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 65

              	private String id;
	private String registeredClientId;
	private String principalName;
	private AuthorizationGrantType authorizationGrantType;
	private Map<Class<? extends OAuth2Token>, Token<?>> tokens;
	private Map<String, Object> attributes;

	protected OAuth2Authorization() {
	}

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 66

              	private String registeredClientId;
	private String principalName;
	private AuthorizationGrantType authorizationGrantType;
	private Map<Class<? extends OAuth2Token>, Token<?>> tokens;
	private Map<String, Object> attributes;

	protected OAuth2Authorization() {
	}


            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 67

              	private String principalName;
	private AuthorizationGrantType authorizationGrantType;
	private Map<Class<? extends OAuth2Token>, Token<?>> tokens;
	private Map<String, Object> attributes;

	protected OAuth2Authorization() {
	}

	/**

            

Reported by PMD.

The String literal 'unchecked' appears 4 times in this file; the first occurrence is on line 135
Error

Line: 135

              	 * @return the {@link Token}, or {@code null} if not available
	 */
	@Nullable
	@SuppressWarnings("unchecked")
	public <T extends OAuth2Token> Token<T> getToken(Class<T> tokenType) {
		Assert.notNull(tokenType, "tokenType cannot be null");
		Token<?> token = this.tokens.get(tokenType);
		return token != null ? (Token<T>) token : null;
	}

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 154

              	public <T extends OAuth2Token> Token<T> getToken(String tokenValue) {
		Assert.hasText(tokenValue, "tokenValue cannot be empty");
		for (Token<?> token : this.tokens.values()) {
			if (token.getToken().getTokenValue().equals(tokenValue)) {
				return (Token<T>) token;
			}
		}
		return null;
	}

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 154

              	public <T extends OAuth2Token> Token<T> getToken(String tokenValue) {
		Assert.hasText(tokenValue, "tokenValue cannot be empty");
		for (Token<?> token : this.tokens.values()) {
			if (token.getToken().getTokenValue().equals(tokenValue)) {
				return (Token<T>) token;
			}
		}
		return null;
	}

            

Reported by PMD.

It is somewhat confusing to have a field name matching the declaring class name
Error

Line: 254

              		 */
		public static final String CLAIMS_METADATA_NAME = TOKEN_METADATA_NAMESPACE.concat("claims");

		private final T token;
		private final Map<String, Object> metadata;

		protected Token(T token) {
			this(token, defaultMetadata());
		}

            

Reported by PMD.

oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/authentication/OAuth2ClientAuthenticationProvider.java
29 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 59

               */
public final class OAuth2ClientAuthenticationProvider implements AuthenticationProvider {
	private static final OAuth2TokenType AUTHORIZATION_CODE_TOKEN_TYPE = new OAuth2TokenType(OAuth2ParameterNames.CODE);
	private final RegisteredClientRepository registeredClientRepository;
	private final OAuth2AuthorizationService authorizationService;
	private PasswordEncoder passwordEncoder;

	/**
	 * Constructs an {@code OAuth2ClientAuthenticationProvider} using the provided parameters.

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 60

              public final class OAuth2ClientAuthenticationProvider implements AuthenticationProvider {
	private static final OAuth2TokenType AUTHORIZATION_CODE_TOKEN_TYPE = new OAuth2TokenType(OAuth2ParameterNames.CODE);
	private final RegisteredClientRepository registeredClientRepository;
	private final OAuth2AuthorizationService authorizationService;
	private PasswordEncoder passwordEncoder;

	/**
	 * Constructs an {@code OAuth2ClientAuthenticationProvider} using the provided parameters.
	 *

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 61

              	private static final OAuth2TokenType AUTHORIZATION_CODE_TOKEN_TYPE = new OAuth2TokenType(OAuth2ParameterNames.CODE);
	private final RegisteredClientRepository registeredClientRepository;
	private final OAuth2AuthorizationService authorizationService;
	private PasswordEncoder passwordEncoder;

	/**
	 * Constructs an {@code OAuth2ClientAuthenticationProvider} using the provided parameters.
	 *
	 * @param registeredClientRepository the repository of registered clients

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 96

              		OAuth2ClientAuthenticationToken clientAuthentication =
				(OAuth2ClientAuthenticationToken) authentication;

		String clientId = clientAuthentication.getPrincipal().toString();
		RegisteredClient registeredClient = this.registeredClientRepository.findByClientId(clientId);
		if (registeredClient == null) {
			throwInvalidClient();
		}


            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 96

              		OAuth2ClientAuthenticationToken clientAuthentication =
				(OAuth2ClientAuthenticationToken) authentication;

		String clientId = clientAuthentication.getPrincipal().toString();
		RegisteredClient registeredClient = this.registeredClientRepository.findByClientId(clientId);
		if (registeredClient == null) {
			throwInvalidClient();
		}


            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 102

              			throwInvalidClient();
		}

		if (!registeredClient.getClientAuthenticationMethods().contains(
				clientAuthentication.getClientAuthenticationMethod())) {
			throwInvalidClient();
		}

		boolean authenticatedCredentials = false;

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 102

              			throwInvalidClient();
		}

		if (!registeredClient.getClientAuthenticationMethods().contains(
				clientAuthentication.getClientAuthenticationMethod())) {
			throwInvalidClient();
		}

		boolean authenticatedCredentials = false;

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 103

              		}

		if (!registeredClient.getClientAuthenticationMethods().contains(
				clientAuthentication.getClientAuthenticationMethod())) {
			throwInvalidClient();
		}

		boolean authenticatedCredentials = false;


            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 109

              
		boolean authenticatedCredentials = false;

		if (clientAuthentication.getCredentials() != null) {
			String clientSecret = clientAuthentication.getCredentials().toString();
			if (!this.passwordEncoder.matches(clientSecret, registeredClient.getClientSecret())) {
				throwInvalidClient();
			}
			authenticatedCredentials = true;

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 110

              		boolean authenticatedCredentials = false;

		if (clientAuthentication.getCredentials() != null) {
			String clientSecret = clientAuthentication.getCredentials().toString();
			if (!this.passwordEncoder.matches(clientSecret, registeredClient.getClientSecret())) {
				throwInvalidClient();
			}
			authenticatedCredentials = true;
		}

            

Reported by PMD.

oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/jackson2/StdConverters.java
29 issues
No abstract method which means that the keyword is most likely used to prevent instantiation. Use a private or protected constructor instead.
Design

Line: 37

               * @author Joe Grandja
 * @since 5.3
 */
abstract class StdConverters {

	static final class AccessTokenTypeConverter extends StdConverter<JsonNode, OAuth2AccessToken.TokenType> {

		@Override
		public OAuth2AccessToken.TokenType convert(JsonNode jsonNode) {

            

Reported by PMD.

This abstract class does not have any abstract methods
Design

Line: 37

               * @author Joe Grandja
 * @since 5.3
 */
abstract class StdConverters {

	static final class AccessTokenTypeConverter extends StdConverter<JsonNode, OAuth2AccessToken.TokenType> {

		@Override
		public OAuth2AccessToken.TokenType convert(JsonNode jsonNode) {

            

Reported by PMD.

The String literal 'value' appears 4 times in this file; the first occurrence is on line 43
Error

Line: 43

              
		@Override
		public OAuth2AccessToken.TokenType convert(JsonNode jsonNode) {
			String value = JsonNodeUtils.findStringValue(jsonNode, "value");
			if (OAuth2AccessToken.TokenType.BEARER.getValue().equalsIgnoreCase(value)) {
				return OAuth2AccessToken.TokenType.BEARER;
			}
			return null;
		}

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 44

              		@Override
		public OAuth2AccessToken.TokenType convert(JsonNode jsonNode) {
			String value = JsonNodeUtils.findStringValue(jsonNode, "value");
			if (OAuth2AccessToken.TokenType.BEARER.getValue().equalsIgnoreCase(value)) {
				return OAuth2AccessToken.TokenType.BEARER;
			}
			return null;
		}


            

Reported by PMD.

Potential violation of Law of Demeter (static property access)
Design

Line: 44

              		@Override
		public OAuth2AccessToken.TokenType convert(JsonNode jsonNode) {
			String value = JsonNodeUtils.findStringValue(jsonNode, "value");
			if (OAuth2AccessToken.TokenType.BEARER.getValue().equalsIgnoreCase(value)) {
				return OAuth2AccessToken.TokenType.BEARER;
			}
			return null;
		}


            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 57

              		@Override
		public ClientAuthenticationMethod convert(JsonNode jsonNode) {
			String value = JsonNodeUtils.findStringValue(jsonNode, "value");
			if (ClientAuthenticationMethod.CLIENT_SECRET_BASIC.getValue().equalsIgnoreCase(value)
					|| ClientAuthenticationMethod.BASIC.getValue().equalsIgnoreCase(value)) {
				return ClientAuthenticationMethod.CLIENT_SECRET_BASIC;
			}
			if (ClientAuthenticationMethod.CLIENT_SECRET_POST.getValue().equalsIgnoreCase(value)
					|| ClientAuthenticationMethod.POST.getValue().equalsIgnoreCase(value)) {

            

Reported by PMD.

Potential violation of Law of Demeter (static property access)
Design

Line: 57

              		@Override
		public ClientAuthenticationMethod convert(JsonNode jsonNode) {
			String value = JsonNodeUtils.findStringValue(jsonNode, "value");
			if (ClientAuthenticationMethod.CLIENT_SECRET_BASIC.getValue().equalsIgnoreCase(value)
					|| ClientAuthenticationMethod.BASIC.getValue().equalsIgnoreCase(value)) {
				return ClientAuthenticationMethod.CLIENT_SECRET_BASIC;
			}
			if (ClientAuthenticationMethod.CLIENT_SECRET_POST.getValue().equalsIgnoreCase(value)
					|| ClientAuthenticationMethod.POST.getValue().equalsIgnoreCase(value)) {

            

Reported by PMD.

Potential violation of Law of Demeter (static property access)
Design

Line: 58

              		public ClientAuthenticationMethod convert(JsonNode jsonNode) {
			String value = JsonNodeUtils.findStringValue(jsonNode, "value");
			if (ClientAuthenticationMethod.CLIENT_SECRET_BASIC.getValue().equalsIgnoreCase(value)
					|| ClientAuthenticationMethod.BASIC.getValue().equalsIgnoreCase(value)) {
				return ClientAuthenticationMethod.CLIENT_SECRET_BASIC;
			}
			if (ClientAuthenticationMethod.CLIENT_SECRET_POST.getValue().equalsIgnoreCase(value)
					|| ClientAuthenticationMethod.POST.getValue().equalsIgnoreCase(value)) {
				return ClientAuthenticationMethod.CLIENT_SECRET_POST;

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 58

              		public ClientAuthenticationMethod convert(JsonNode jsonNode) {
			String value = JsonNodeUtils.findStringValue(jsonNode, "value");
			if (ClientAuthenticationMethod.CLIENT_SECRET_BASIC.getValue().equalsIgnoreCase(value)
					|| ClientAuthenticationMethod.BASIC.getValue().equalsIgnoreCase(value)) {
				return ClientAuthenticationMethod.CLIENT_SECRET_BASIC;
			}
			if (ClientAuthenticationMethod.CLIENT_SECRET_POST.getValue().equalsIgnoreCase(value)
					|| ClientAuthenticationMethod.POST.getValue().equalsIgnoreCase(value)) {
				return ClientAuthenticationMethod.CLIENT_SECRET_POST;

            

Reported by PMD.

Potential violation of Law of Demeter (static property access)
Design

Line: 61

              					|| ClientAuthenticationMethod.BASIC.getValue().equalsIgnoreCase(value)) {
				return ClientAuthenticationMethod.CLIENT_SECRET_BASIC;
			}
			if (ClientAuthenticationMethod.CLIENT_SECRET_POST.getValue().equalsIgnoreCase(value)
					|| ClientAuthenticationMethod.POST.getValue().equalsIgnoreCase(value)) {
				return ClientAuthenticationMethod.CLIENT_SECRET_POST;
			}
			if (ClientAuthenticationMethod.NONE.getValue().equalsIgnoreCase(value)) {
				return ClientAuthenticationMethod.NONE;

            

Reported by PMD.

oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/authentication/OAuth2TokenIntrospectionAuthenticationProvider.java
27 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 51

               * @see <a target="_blank" href="https://tools.ietf.org/html/rfc7662#section-2.1">Section 2.1 Introspection Request</a>
 */
public final class OAuth2TokenIntrospectionAuthenticationProvider implements AuthenticationProvider {
	private final RegisteredClientRepository registeredClientRepository;
	private final OAuth2AuthorizationService authorizationService;

	/**
	 * Constructs an {@code OAuth2TokenIntrospectionAuthenticationProvider} using the provided parameters.
	 *

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 52

               */
public final class OAuth2TokenIntrospectionAuthenticationProvider implements AuthenticationProvider {
	private final RegisteredClientRepository registeredClientRepository;
	private final OAuth2AuthorizationService authorizationService;

	/**
	 * Constructs an {@code OAuth2TokenIntrospectionAuthenticationProvider} using the provided parameters.
	 *
	 * @param registeredClientRepository the repository of registered clients

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 77

              				getAuthenticatedClientElseThrowInvalidClient(tokenIntrospectionAuthentication);

		OAuth2Authorization authorization = this.authorizationService.findByToken(
				tokenIntrospectionAuthentication.getToken(), null);
		if (authorization == null) {
			// Return the authentication request when token not found
			return tokenIntrospectionAuthentication;
		}


            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 84

              		}

		OAuth2Authorization.Token<AbstractOAuth2Token> authorizedToken =
				authorization.getToken(tokenIntrospectionAuthentication.getToken());
		if (!authorizedToken.isActive()) {
			return new OAuth2TokenIntrospectionAuthenticationToken(tokenIntrospectionAuthentication.getToken(),
					clientPrincipal, OAuth2TokenIntrospection.builder().build());
		}


            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 84

              		}

		OAuth2Authorization.Token<AbstractOAuth2Token> authorizedToken =
				authorization.getToken(tokenIntrospectionAuthentication.getToken());
		if (!authorizedToken.isActive()) {
			return new OAuth2TokenIntrospectionAuthenticationToken(tokenIntrospectionAuthentication.getToken(),
					clientPrincipal, OAuth2TokenIntrospection.builder().build());
		}


            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 85

              
		OAuth2Authorization.Token<AbstractOAuth2Token> authorizedToken =
				authorization.getToken(tokenIntrospectionAuthentication.getToken());
		if (!authorizedToken.isActive()) {
			return new OAuth2TokenIntrospectionAuthenticationToken(tokenIntrospectionAuthentication.getToken(),
					clientPrincipal, OAuth2TokenIntrospection.builder().build());
		}

		RegisteredClient authorizedClient = this.registeredClientRepository.findById(authorization.getRegisteredClientId());

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 87

              				authorization.getToken(tokenIntrospectionAuthentication.getToken());
		if (!authorizedToken.isActive()) {
			return new OAuth2TokenIntrospectionAuthenticationToken(tokenIntrospectionAuthentication.getToken(),
					clientPrincipal, OAuth2TokenIntrospection.builder().build());
		}

		RegisteredClient authorizedClient = this.registeredClientRepository.findById(authorization.getRegisteredClientId());
		OAuth2TokenIntrospection tokenClaims = withActiveTokenClaims(authorizedToken, authorizedClient);


            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 90

              					clientPrincipal, OAuth2TokenIntrospection.builder().build());
		}

		RegisteredClient authorizedClient = this.registeredClientRepository.findById(authorization.getRegisteredClientId());
		OAuth2TokenIntrospection tokenClaims = withActiveTokenClaims(authorizedToken, authorizedClient);

		return new OAuth2TokenIntrospectionAuthenticationToken(authorizedToken.getToken().getTokenValue(),
				clientPrincipal, tokenClaims);
	}

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 93

              		RegisteredClient authorizedClient = this.registeredClientRepository.findById(authorization.getRegisteredClientId());
		OAuth2TokenIntrospection tokenClaims = withActiveTokenClaims(authorizedToken, authorizedClient);

		return new OAuth2TokenIntrospectionAuthenticationToken(authorizedToken.getToken().getTokenValue(),
				clientPrincipal, tokenClaims);
	}

	@Override
	public boolean supports(Class<?> authentication) {

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 93

              		RegisteredClient authorizedClient = this.registeredClientRepository.findById(authorization.getRegisteredClientId());
		OAuth2TokenIntrospection tokenClaims = withActiveTokenClaims(authorizedToken, authorizedClient);

		return new OAuth2TokenIntrospectionAuthenticationToken(authorizedToken.getToken().getTokenValue(),
				clientPrincipal, tokenClaims);
	}

	@Override
	public boolean supports(Class<?> authentication) {

            

Reported by PMD.

oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/oidc/web/OidcProviderConfigurationEndpointFilter.java
27 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 56

              	 */
	private static final String DEFAULT_OIDC_PROVIDER_CONFIGURATION_ENDPOINT_URI = "/.well-known/openid-configuration";

	private final ProviderSettings providerSettings;
	private final RequestMatcher requestMatcher;
	private final OidcProviderConfigurationHttpMessageConverter providerConfigurationHttpMessageConverter =
			new OidcProviderConfigurationHttpMessageConverter();

	public OidcProviderConfigurationEndpointFilter(ProviderSettings providerSettings) {

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 57

              	private static final String DEFAULT_OIDC_PROVIDER_CONFIGURATION_ENDPOINT_URI = "/.well-known/openid-configuration";

	private final ProviderSettings providerSettings;
	private final RequestMatcher requestMatcher;
	private final OidcProviderConfigurationHttpMessageConverter providerConfigurationHttpMessageConverter =
			new OidcProviderConfigurationHttpMessageConverter();

	public OidcProviderConfigurationEndpointFilter(ProviderSettings providerSettings) {
		Assert.notNull(providerSettings, "providerSettings cannot be null");

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 58

              
	private final ProviderSettings providerSettings;
	private final RequestMatcher requestMatcher;
	private final OidcProviderConfigurationHttpMessageConverter providerConfigurationHttpMessageConverter =
			new OidcProviderConfigurationHttpMessageConverter();

	public OidcProviderConfigurationEndpointFilter(ProviderSettings providerSettings) {
		Assert.notNull(providerSettings, "providerSettings cannot be null");
		this.providerSettings = providerSettings;

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 79

              			return;
		}

		OidcProviderConfiguration providerConfiguration = OidcProviderConfiguration.builder()
				.issuer(this.providerSettings.getIssuer())
				.authorizationEndpoint(asUrl(this.providerSettings.getIssuer(), this.providerSettings.getAuthorizationEndpoint()))
				.tokenEndpoint(asUrl(this.providerSettings.getIssuer(), this.providerSettings.getTokenEndpoint()))
				.tokenEndpointAuthenticationMethod(ClientAuthenticationMethod.CLIENT_SECRET_BASIC.getValue())
				.tokenEndpointAuthenticationMethod(ClientAuthenticationMethod.CLIENT_SECRET_POST.getValue())

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 79

              			return;
		}

		OidcProviderConfiguration providerConfiguration = OidcProviderConfiguration.builder()
				.issuer(this.providerSettings.getIssuer())
				.authorizationEndpoint(asUrl(this.providerSettings.getIssuer(), this.providerSettings.getAuthorizationEndpoint()))
				.tokenEndpoint(asUrl(this.providerSettings.getIssuer(), this.providerSettings.getTokenEndpoint()))
				.tokenEndpointAuthenticationMethod(ClientAuthenticationMethod.CLIENT_SECRET_BASIC.getValue())
				.tokenEndpointAuthenticationMethod(ClientAuthenticationMethod.CLIENT_SECRET_POST.getValue())

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 79

              			return;
		}

		OidcProviderConfiguration providerConfiguration = OidcProviderConfiguration.builder()
				.issuer(this.providerSettings.getIssuer())
				.authorizationEndpoint(asUrl(this.providerSettings.getIssuer(), this.providerSettings.getAuthorizationEndpoint()))
				.tokenEndpoint(asUrl(this.providerSettings.getIssuer(), this.providerSettings.getTokenEndpoint()))
				.tokenEndpointAuthenticationMethod(ClientAuthenticationMethod.CLIENT_SECRET_BASIC.getValue())
				.tokenEndpointAuthenticationMethod(ClientAuthenticationMethod.CLIENT_SECRET_POST.getValue())

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 79

              			return;
		}

		OidcProviderConfiguration providerConfiguration = OidcProviderConfiguration.builder()
				.issuer(this.providerSettings.getIssuer())
				.authorizationEndpoint(asUrl(this.providerSettings.getIssuer(), this.providerSettings.getAuthorizationEndpoint()))
				.tokenEndpoint(asUrl(this.providerSettings.getIssuer(), this.providerSettings.getTokenEndpoint()))
				.tokenEndpointAuthenticationMethod(ClientAuthenticationMethod.CLIENT_SECRET_BASIC.getValue())
				.tokenEndpointAuthenticationMethod(ClientAuthenticationMethod.CLIENT_SECRET_POST.getValue())

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 79

              			return;
		}

		OidcProviderConfiguration providerConfiguration = OidcProviderConfiguration.builder()
				.issuer(this.providerSettings.getIssuer())
				.authorizationEndpoint(asUrl(this.providerSettings.getIssuer(), this.providerSettings.getAuthorizationEndpoint()))
				.tokenEndpoint(asUrl(this.providerSettings.getIssuer(), this.providerSettings.getTokenEndpoint()))
				.tokenEndpointAuthenticationMethod(ClientAuthenticationMethod.CLIENT_SECRET_BASIC.getValue())
				.tokenEndpointAuthenticationMethod(ClientAuthenticationMethod.CLIENT_SECRET_POST.getValue())

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 79

              			return;
		}

		OidcProviderConfiguration providerConfiguration = OidcProviderConfiguration.builder()
				.issuer(this.providerSettings.getIssuer())
				.authorizationEndpoint(asUrl(this.providerSettings.getIssuer(), this.providerSettings.getAuthorizationEndpoint()))
				.tokenEndpoint(asUrl(this.providerSettings.getIssuer(), this.providerSettings.getTokenEndpoint()))
				.tokenEndpointAuthenticationMethod(ClientAuthenticationMethod.CLIENT_SECRET_BASIC.getValue())
				.tokenEndpointAuthenticationMethod(ClientAuthenticationMethod.CLIENT_SECRET_POST.getValue())

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 79

              			return;
		}

		OidcProviderConfiguration providerConfiguration = OidcProviderConfiguration.builder()
				.issuer(this.providerSettings.getIssuer())
				.authorizationEndpoint(asUrl(this.providerSettings.getIssuer(), this.providerSettings.getAuthorizationEndpoint()))
				.tokenEndpoint(asUrl(this.providerSettings.getIssuer(), this.providerSettings.getTokenEndpoint()))
				.tokenEndpointAuthenticationMethod(ClientAuthenticationMethod.CLIENT_SECRET_BASIC.getValue())
				.tokenEndpointAuthenticationMethod(ClientAuthenticationMethod.CLIENT_SECRET_POST.getValue())

            

Reported by PMD.

oauth2-authorization-server/src/test/java/org/springframework/security/oauth2/server/authorization/authentication/OAuth2AuthorizationCodeAuthenticationTokenTests.java
27 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 38

               * @author Daniel Garnier-Moiroux
 */
public class OAuth2AuthorizationCodeAuthenticationTokenTests {
	private String code = "code";
	private RegisteredClient registeredClient = TestRegisteredClients.registeredClient().build();
	private OAuth2ClientAuthenticationToken clientPrincipal = new OAuth2ClientAuthenticationToken(
			this.registeredClient, ClientAuthenticationMethod.CLIENT_SECRET_BASIC, this.registeredClient.getClientSecret());
	private String redirectUri = "redirectUri";
	private Map<String, Object> additionalParameters = Collections.singletonMap("param1", "value1");

            

Reported by PMD.

Private field 'code' could be made final; it is only initialized in the declaration or constructor.
Design

Line: 38

               * @author Daniel Garnier-Moiroux
 */
public class OAuth2AuthorizationCodeAuthenticationTokenTests {
	private String code = "code";
	private RegisteredClient registeredClient = TestRegisteredClients.registeredClient().build();
	private OAuth2ClientAuthenticationToken clientPrincipal = new OAuth2ClientAuthenticationToken(
			this.registeredClient, ClientAuthenticationMethod.CLIENT_SECRET_BASIC, this.registeredClient.getClientSecret());
	private String redirectUri = "redirectUri";
	private Map<String, Object> additionalParameters = Collections.singletonMap("param1", "value1");

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 39

               */
public class OAuth2AuthorizationCodeAuthenticationTokenTests {
	private String code = "code";
	private RegisteredClient registeredClient = TestRegisteredClients.registeredClient().build();
	private OAuth2ClientAuthenticationToken clientPrincipal = new OAuth2ClientAuthenticationToken(
			this.registeredClient, ClientAuthenticationMethod.CLIENT_SECRET_BASIC, this.registeredClient.getClientSecret());
	private String redirectUri = "redirectUri";
	private Map<String, Object> additionalParameters = Collections.singletonMap("param1", "value1");


            

Reported by PMD.

Private field 'registeredClient' could be made final; it is only initialized in the declaration or constructor.
Design

Line: 39

               */
public class OAuth2AuthorizationCodeAuthenticationTokenTests {
	private String code = "code";
	private RegisteredClient registeredClient = TestRegisteredClients.registeredClient().build();
	private OAuth2ClientAuthenticationToken clientPrincipal = new OAuth2ClientAuthenticationToken(
			this.registeredClient, ClientAuthenticationMethod.CLIENT_SECRET_BASIC, this.registeredClient.getClientSecret());
	private String redirectUri = "redirectUri";
	private Map<String, Object> additionalParameters = Collections.singletonMap("param1", "value1");


            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 40

              public class OAuth2AuthorizationCodeAuthenticationTokenTests {
	private String code = "code";
	private RegisteredClient registeredClient = TestRegisteredClients.registeredClient().build();
	private OAuth2ClientAuthenticationToken clientPrincipal = new OAuth2ClientAuthenticationToken(
			this.registeredClient, ClientAuthenticationMethod.CLIENT_SECRET_BASIC, this.registeredClient.getClientSecret());
	private String redirectUri = "redirectUri";
	private Map<String, Object> additionalParameters = Collections.singletonMap("param1", "value1");

	@Test

            

Reported by PMD.

Private field 'clientPrincipal' could be made final; it is only initialized in the declaration or constructor.
Design

Line: 40

              public class OAuth2AuthorizationCodeAuthenticationTokenTests {
	private String code = "code";
	private RegisteredClient registeredClient = TestRegisteredClients.registeredClient().build();
	private OAuth2ClientAuthenticationToken clientPrincipal = new OAuth2ClientAuthenticationToken(
			this.registeredClient, ClientAuthenticationMethod.CLIENT_SECRET_BASIC, this.registeredClient.getClientSecret());
	private String redirectUri = "redirectUri";
	private Map<String, Object> additionalParameters = Collections.singletonMap("param1", "value1");

	@Test

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 42

              	private RegisteredClient registeredClient = TestRegisteredClients.registeredClient().build();
	private OAuth2ClientAuthenticationToken clientPrincipal = new OAuth2ClientAuthenticationToken(
			this.registeredClient, ClientAuthenticationMethod.CLIENT_SECRET_BASIC, this.registeredClient.getClientSecret());
	private String redirectUri = "redirectUri";
	private Map<String, Object> additionalParameters = Collections.singletonMap("param1", "value1");

	@Test
	public void constructorWhenCodeNullThenThrowIllegalArgumentException() {
		assertThatThrownBy(() -> new OAuth2AuthorizationCodeAuthenticationToken(null, this.clientPrincipal, this.redirectUri, null))

            

Reported by PMD.

Private field 'redirectUri' could be made final; it is only initialized in the declaration or constructor.
Design

Line: 42

              	private RegisteredClient registeredClient = TestRegisteredClients.registeredClient().build();
	private OAuth2ClientAuthenticationToken clientPrincipal = new OAuth2ClientAuthenticationToken(
			this.registeredClient, ClientAuthenticationMethod.CLIENT_SECRET_BASIC, this.registeredClient.getClientSecret());
	private String redirectUri = "redirectUri";
	private Map<String, Object> additionalParameters = Collections.singletonMap("param1", "value1");

	@Test
	public void constructorWhenCodeNullThenThrowIllegalArgumentException() {
		assertThatThrownBy(() -> new OAuth2AuthorizationCodeAuthenticationToken(null, this.clientPrincipal, this.redirectUri, null))

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 43

              	private OAuth2ClientAuthenticationToken clientPrincipal = new OAuth2ClientAuthenticationToken(
			this.registeredClient, ClientAuthenticationMethod.CLIENT_SECRET_BASIC, this.registeredClient.getClientSecret());
	private String redirectUri = "redirectUri";
	private Map<String, Object> additionalParameters = Collections.singletonMap("param1", "value1");

	@Test
	public void constructorWhenCodeNullThenThrowIllegalArgumentException() {
		assertThatThrownBy(() -> new OAuth2AuthorizationCodeAuthenticationToken(null, this.clientPrincipal, this.redirectUri, null))
				.isInstanceOf(IllegalArgumentException.class)

            

Reported by PMD.

Private field 'additionalParameters' could be made final; it is only initialized in the declaration or constructor.
Design

Line: 43

              	private OAuth2ClientAuthenticationToken clientPrincipal = new OAuth2ClientAuthenticationToken(
			this.registeredClient, ClientAuthenticationMethod.CLIENT_SECRET_BASIC, this.registeredClient.getClientSecret());
	private String redirectUri = "redirectUri";
	private Map<String, Object> additionalParameters = Collections.singletonMap("param1", "value1");

	@Test
	public void constructorWhenCodeNullThenThrowIllegalArgumentException() {
		assertThatThrownBy(() -> new OAuth2AuthorizationCodeAuthenticationToken(null, this.clientPrincipal, this.redirectUri, null))
				.isInstanceOf(IllegalArgumentException.class)

            

Reported by PMD.