Fixed final field warnings in opaque token introspectors

This commit is contained in:
Ashley Scopes 2021-08-15 15:18:19 +01:00 committed by Josh Cummings
parent 729418ad7a
commit e9d5bbba34
4 changed files with 17 additions and 17 deletions

View File

@ -61,14 +61,14 @@ import org.springframework.web.client.RestTemplate;
*/ */
public class NimbusOpaqueTokenIntrospector implements OpaqueTokenIntrospector { public class NimbusOpaqueTokenIntrospector implements OpaqueTokenIntrospector {
private static final String AUTHORITY_PREFIX = "SCOPE_";
private final Log logger = LogFactory.getLog(getClass()); private final Log logger = LogFactory.getLog(getClass());
private final RestOperations restOperations;
private Converter<String, RequestEntity<?>> requestEntityConverter; private Converter<String, RequestEntity<?>> requestEntityConverter;
private RestOperations restOperations;
private final String authorityPrefix = "SCOPE_";
/** /**
* Creates a {@code OpaqueTokenAuthenticationProvider} with the provided parameters * Creates a {@code OpaqueTokenAuthenticationProvider} with the provided parameters
* @param introspectionUri The introspection endpoint uri * @param introspectionUri The introspection endpoint uri
@ -258,7 +258,7 @@ public class NimbusOpaqueTokenIntrospector implements OpaqueTokenIntrospector {
List<String> scopes = Collections.unmodifiableList(response.getScope().toStringList()); List<String> scopes = Collections.unmodifiableList(response.getScope().toStringList());
claims.put(OAuth2TokenIntrospectionClaimNames.SCOPE, scopes); claims.put(OAuth2TokenIntrospectionClaimNames.SCOPE, scopes);
for (String scope : scopes) { for (String scope : scopes) {
authorities.add(new SimpleGrantedAuthority(this.authorityPrefix + scope)); authorities.add(new SimpleGrantedAuthority(AUTHORITY_PREFIX + scope));
} }
} }
return new OAuth2IntrospectionAuthenticatedPrincipal(claims, authorities); return new OAuth2IntrospectionAuthenticatedPrincipal(claims, authorities);

View File

@ -57,14 +57,14 @@ import org.springframework.web.reactive.function.client.WebClient;
*/ */
public class NimbusReactiveOpaqueTokenIntrospector implements ReactiveOpaqueTokenIntrospector { public class NimbusReactiveOpaqueTokenIntrospector implements ReactiveOpaqueTokenIntrospector {
private static final String AUTHORITY_PREFIX = "SCOPE_";
private final Log logger = LogFactory.getLog(getClass()); private final Log logger = LogFactory.getLog(getClass());
private final URI introspectionUri; private final URI introspectionUri;
private final WebClient webClient; private final WebClient webClient;
private String authorityPrefix = "SCOPE_";
/** /**
* Creates a {@code OpaqueTokenReactiveAuthenticationManager} with the provided * Creates a {@code OpaqueTokenReactiveAuthenticationManager} with the provided
* parameters * parameters
@ -227,7 +227,7 @@ public class NimbusReactiveOpaqueTokenIntrospector implements ReactiveOpaqueToke
claims.put(OAuth2TokenIntrospectionClaimNames.SCOPE, scopes); claims.put(OAuth2TokenIntrospectionClaimNames.SCOPE, scopes);
for (String scope : scopes) { for (String scope : scopes) {
authorities.add(new SimpleGrantedAuthority(this.authorityPrefix + scope)); authorities.add(new SimpleGrantedAuthority(AUTHORITY_PREFIX + scope));
} }
} }
return new OAuth2IntrospectionAuthenticatedPrincipal(claims, authorities); return new OAuth2IntrospectionAuthenticatedPrincipal(claims, authorities);

View File

@ -57,17 +57,17 @@ import org.springframework.web.client.RestTemplate;
*/ */
public class SpringOpaqueTokenIntrospector implements OpaqueTokenIntrospector { public class SpringOpaqueTokenIntrospector implements OpaqueTokenIntrospector {
private final Log logger = LogFactory.getLog(getClass()); private static final String AUTHORITY_PREFIX = "SCOPE_";
private static final ParameterizedTypeReference<Map<String, Object>> STRING_OBJECT_MAP = new ParameterizedTypeReference<Map<String, Object>>() { private static final ParameterizedTypeReference<Map<String, Object>> STRING_OBJECT_MAP = new ParameterizedTypeReference<Map<String, Object>>() {
}; };
private final Log logger = LogFactory.getLog(getClass());
private final RestOperations restOperations;
private Converter<String, RequestEntity<?>> requestEntityConverter; private Converter<String, RequestEntity<?>> requestEntityConverter;
private RestOperations restOperations;
private final String authorityPrefix = "SCOPE_";
/** /**
* Creates a {@code OpaqueTokenAuthenticationProvider} with the provided parameters * Creates a {@code OpaqueTokenAuthenticationProvider} with the provided parameters
* @param introspectionUri The introspection endpoint uri * @param introspectionUri The introspection endpoint uri
@ -216,7 +216,7 @@ public class SpringOpaqueTokenIntrospector implements OpaqueTokenIntrospector {
if (v instanceof String) { if (v instanceof String) {
Collection<String> scopes = Arrays.asList(((String) v).split(" ")); Collection<String> scopes = Arrays.asList(((String) v).split(" "));
for (String scope : scopes) { for (String scope : scopes) {
authorities.add(new SimpleGrantedAuthority(this.authorityPrefix + scope)); authorities.add(new SimpleGrantedAuthority(AUTHORITY_PREFIX + scope));
} }
return scopes; return scopes;
} }

View File

@ -51,6 +51,8 @@ import org.springframework.web.reactive.function.client.WebClient;
*/ */
public class SpringReactiveOpaqueTokenIntrospector implements ReactiveOpaqueTokenIntrospector { public class SpringReactiveOpaqueTokenIntrospector implements ReactiveOpaqueTokenIntrospector {
private static final String AUTHORITY_PREFIX = "SCOPE_";
private static final ParameterizedTypeReference<Map<String, Object>> STRING_OBJECT_MAP = new ParameterizedTypeReference<Map<String, Object>>() { private static final ParameterizedTypeReference<Map<String, Object>> STRING_OBJECT_MAP = new ParameterizedTypeReference<Map<String, Object>>() {
}; };
@ -58,8 +60,6 @@ public class SpringReactiveOpaqueTokenIntrospector implements ReactiveOpaqueToke
private final WebClient webClient; private final WebClient webClient;
private String authorityPrefix = "SCOPE_";
/** /**
* Creates a {@code OpaqueTokenReactiveAuthenticationManager} with the provided * Creates a {@code OpaqueTokenReactiveAuthenticationManager} with the provided
* parameters * parameters
@ -171,7 +171,7 @@ public class SpringReactiveOpaqueTokenIntrospector implements ReactiveOpaqueToke
if (v instanceof String) { if (v instanceof String) {
Collection<String> scopes = Arrays.asList(((String) v).split(" ")); Collection<String> scopes = Arrays.asList(((String) v).split(" "));
for (String scope : scopes) { for (String scope : scopes) {
authorities.add(new SimpleGrantedAuthority(this.authorityPrefix + scope)); authorities.add(new SimpleGrantedAuthority(AUTHORITY_PREFIX + scope));
} }
return scopes; return scopes;
} }