Skip to content

Commit 0f03ed0

Browse files
committed
Change interface that only contain constants to final class
Closes spring-projectsgh-728
1 parent ecd220f commit 0f03ed0

File tree

4 files changed

+56
-44
lines changed

4 files changed

+56
-44
lines changed

oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/core/OAuth2AuthorizationServerMetadataClaimNames.java

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2021 the original author or authors.
2+
* Copyright 2020-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -24,71 +24,74 @@
2424
* @see <a target="_blank" href="https://tools.ietf.org/html/rfc8414#section-2">2. Authorization Server Metadata</a>
2525
* @see <a target="_blank" href="https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata">3. OpenID Provider Metadata</a>
2626
*/
27-
public interface OAuth2AuthorizationServerMetadataClaimNames {
27+
public class OAuth2AuthorizationServerMetadataClaimNames {
2828

2929
/**
3030
* {@code issuer} - the {@code URL} the Authorization Server asserts as its Issuer Identifier
3131
*/
32-
String ISSUER = "issuer";
32+
public static final String ISSUER = "issuer";
3333

3434
/**
3535
* {@code authorization_endpoint} - the {@code URL} of the OAuth 2.0 Authorization Endpoint
3636
*/
37-
String AUTHORIZATION_ENDPOINT = "authorization_endpoint";
37+
public static final String AUTHORIZATION_ENDPOINT = "authorization_endpoint";
3838

3939
/**
4040
* {@code token_endpoint} - the {@code URL} of the OAuth 2.0 Token Endpoint
4141
*/
42-
String TOKEN_ENDPOINT = "token_endpoint";
42+
public static final String TOKEN_ENDPOINT = "token_endpoint";
4343

4444
/**
4545
* {@code token_endpoint_auth_methods_supported} - the client authentication methods supported by the OAuth 2.0 Token Endpoint
4646
*/
47-
String TOKEN_ENDPOINT_AUTH_METHODS_SUPPORTED = "token_endpoint_auth_methods_supported";
47+
public static final String TOKEN_ENDPOINT_AUTH_METHODS_SUPPORTED = "token_endpoint_auth_methods_supported";
4848

4949
/**
5050
* {@code jwks_uri} - the {@code URL} of the JSON Web Key Set
5151
*/
52-
String JWKS_URI = "jwks_uri";
52+
public static final String JWKS_URI = "jwks_uri";
5353

5454
/**
5555
* {@code scopes_supported} - the OAuth 2.0 {@code scope} values supported
5656
*/
57-
String SCOPES_SUPPORTED = "scopes_supported";
57+
public static final String SCOPES_SUPPORTED = "scopes_supported";
5858

5959
/**
6060
* {@code response_types_supported} - the OAuth 2.0 {@code response_type} values supported
6161
*/
62-
String RESPONSE_TYPES_SUPPORTED = "response_types_supported";
62+
public static final String RESPONSE_TYPES_SUPPORTED = "response_types_supported";
6363

6464
/**
6565
* {@code grant_types_supported} - the OAuth 2.0 {@code grant_type} values supported
6666
*/
67-
String GRANT_TYPES_SUPPORTED = "grant_types_supported";
67+
public static final String GRANT_TYPES_SUPPORTED = "grant_types_supported";
6868

6969
/**
7070
* {@code revocation_endpoint} - the {@code URL} of the OAuth 2.0 Token Revocation Endpoint
7171
*/
72-
String REVOCATION_ENDPOINT = "revocation_endpoint";
72+
public static final String REVOCATION_ENDPOINT = "revocation_endpoint";
7373

7474
/**
7575
* {@code revocation_endpoint_auth_methods_supported} - the client authentication methods supported by the OAuth 2.0 Token Revocation Endpoint
7676
*/
77-
String REVOCATION_ENDPOINT_AUTH_METHODS_SUPPORTED = "revocation_endpoint_auth_methods_supported";
77+
public static final String REVOCATION_ENDPOINT_AUTH_METHODS_SUPPORTED = "revocation_endpoint_auth_methods_supported";
7878

7979
/**
8080
* {@code introspection_endpoint} - the {@code URL} of the OAuth 2.0 Token Introspection Endpoint
8181
*/
82-
String INTROSPECTION_ENDPOINT = "introspection_endpoint";
82+
public static final String INTROSPECTION_ENDPOINT = "introspection_endpoint";
8383

8484
/**
8585
* {@code introspection_endpoint_auth_methods_supported} - the client authentication methods supported by the OAuth 2.0 Token Introspection Endpoint
8686
*/
87-
String INTROSPECTION_ENDPOINT_AUTH_METHODS_SUPPORTED = "introspection_endpoint_auth_methods_supported";
87+
public static final String INTROSPECTION_ENDPOINT_AUTH_METHODS_SUPPORTED = "introspection_endpoint_auth_methods_supported";
8888

8989
/**
9090
* {@code code_challenge_methods_supported} - the Proof Key for Code Exchange (PKCE) {@code code_challenge_method} values supported
9191
*/
92-
String CODE_CHALLENGE_METHODS_SUPPORTED = "code_challenge_methods_supported";
92+
public static final String CODE_CHALLENGE_METHODS_SUPPORTED = "code_challenge_methods_supported";
93+
94+
protected OAuth2AuthorizationServerMetadataClaimNames() {
95+
}
9396

9497
}

oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/core/oidc/OidcClientMetadataClaimNames.java

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2021 the original author or authors.
2+
* Copyright 2020-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -28,87 +28,90 @@
2828
* @since 0.1.1
2929
* @see <a target="_blank" href="https://openid.net/specs/openid-connect-registration-1_0.html#ClientMetadata">2. Client Metadata</a>
3030
*/
31-
public interface OidcClientMetadataClaimNames {
31+
public final class OidcClientMetadataClaimNames {
3232

3333
/**
3434
* {@code client_id} - the Client Identifier
3535
*/
36-
String CLIENT_ID = "client_id";
36+
public static final String CLIENT_ID = "client_id";
3737

3838
/**
3939
* {@code client_id_issued_at} - the time at which the Client Identifier was issued
4040
*/
41-
String CLIENT_ID_ISSUED_AT = "client_id_issued_at";
41+
public static final String CLIENT_ID_ISSUED_AT = "client_id_issued_at";
4242

4343
/**
4444
* {@code client_secret} - the Client Secret
4545
*/
46-
String CLIENT_SECRET = "client_secret";
46+
public static final String CLIENT_SECRET = "client_secret";
4747

4848
/**
4949
* {@code client_secret_expires_at} - the time at which the {@code client_secret} will expire or 0 if it will not expire
5050
*/
51-
String CLIENT_SECRET_EXPIRES_AT = "client_secret_expires_at";
51+
public static final String CLIENT_SECRET_EXPIRES_AT = "client_secret_expires_at";
5252

5353
/**
5454
* {@code client_name} - the name of the Client to be presented to the End-User
5555
*/
56-
String CLIENT_NAME = "client_name";
56+
public static final String CLIENT_NAME = "client_name";
5757

5858
/**
5959
* {@code redirect_uris} - the redirection {@code URI} values used by the Client
6060
*/
61-
String REDIRECT_URIS = "redirect_uris";
61+
public static final String REDIRECT_URIS = "redirect_uris";
6262

6363
/**
6464
* {@code token_endpoint_auth_method} - the authentication method used by the Client for the Token Endpoint
6565
*/
66-
String TOKEN_ENDPOINT_AUTH_METHOD = "token_endpoint_auth_method";
66+
public static final String TOKEN_ENDPOINT_AUTH_METHOD = "token_endpoint_auth_method";
6767

6868
/**
6969
* {@code token_endpoint_auth_signing_alg} - the {@link JwsAlgorithm JWS} algorithm that must be used for signing the {@link Jwt JWT}
7070
* used to authenticate the Client at the Token Endpoint for the {@link ClientAuthenticationMethod#PRIVATE_KEY_JWT private_key_jwt} and
7171
* {@link ClientAuthenticationMethod#CLIENT_SECRET_JWT client_secret_jwt} authentication methods
7272
* @since 0.2.2
7373
*/
74-
String TOKEN_ENDPOINT_AUTH_SIGNING_ALG = "token_endpoint_auth_signing_alg";
74+
public static final String TOKEN_ENDPOINT_AUTH_SIGNING_ALG = "token_endpoint_auth_signing_alg";
7575

7676
/**
7777
* {@code grant_types} - the OAuth 2.0 {@code grant_type} values that the Client will restrict itself to using
7878
*/
79-
String GRANT_TYPES = "grant_types";
79+
public static final String GRANT_TYPES = "grant_types";
8080

8181
/**
8282
* {@code response_types} - the OAuth 2.0 {@code response_type} values that the Client will restrict itself to using
8383
*/
84-
String RESPONSE_TYPES = "response_types";
84+
public static final String RESPONSE_TYPES = "response_types";
8585

8686
/**
8787
* {@code scope} - a space-separated list of OAuth 2.0 {@code scope} values that the Client will restrict itself to using
8888
*/
89-
String SCOPE = "scope";
89+
public static final String SCOPE = "scope";
9090

9191
/**
9292
* {@code jwks_uri} - the {@code URL} for the Client's JSON Web Key Set
9393
* @since 0.2.2
9494
*/
95-
String JWKS_URI = "jwks_uri";
95+
public static final String JWKS_URI = "jwks_uri";
9696

9797
/**
9898
* {@code id_token_signed_response_alg} - the {@link JwsAlgorithm JWS} algorithm required for signing the {@link OidcIdToken ID Token} issued to the Client
9999
*/
100-
String ID_TOKEN_SIGNED_RESPONSE_ALG = "id_token_signed_response_alg";
100+
public static final String ID_TOKEN_SIGNED_RESPONSE_ALG = "id_token_signed_response_alg";
101101

102102
/**
103103
* {@code registration_access_token} - the Registration Access Token that can be used at the Client Configuration Endpoint
104104
* @since 0.2.1
105105
*/
106-
String REGISTRATION_ACCESS_TOKEN = "registration_access_token";
106+
public static final String REGISTRATION_ACCESS_TOKEN = "registration_access_token";
107107

108108
/**
109109
* {@code registration_client_uri} - the {@code URL} of the Client Configuration Endpoint where the Registration Access Token can be used
110110
* @since 0.2.1
111111
*/
112-
String REGISTRATION_CLIENT_URI = "registration_client_uri";
112+
public static final String REGISTRATION_CLIENT_URI = "registration_client_uri";
113+
114+
private OidcClientMetadataClaimNames() {
115+
}
113116

114117
}

oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/core/oidc/OidcProviderMetadataClaimNames.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,25 @@
2727
* @see OAuth2AuthorizationServerMetadataClaimNames
2828
* @see <a target="_blank" href="https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata">3. OpenID Provider Metadata</a>
2929
*/
30-
public interface OidcProviderMetadataClaimNames extends OAuth2AuthorizationServerMetadataClaimNames {
30+
public final class OidcProviderMetadataClaimNames extends OAuth2AuthorizationServerMetadataClaimNames {
3131

3232
/**
3333
* {@code subject_types_supported} - the Subject Identifier types supported
3434
*/
35-
String SUBJECT_TYPES_SUPPORTED = "subject_types_supported";
35+
public static final String SUBJECT_TYPES_SUPPORTED = "subject_types_supported";
3636

3737
/**
3838
* {@code id_token_signing_alg_values_supported} - the {@link JwsAlgorithm JWS} signing algorithms supported for the {@link OidcIdToken ID Token}
3939
*/
40-
String ID_TOKEN_SIGNING_ALG_VALUES_SUPPORTED = "id_token_signing_alg_values_supported";
40+
public static final String ID_TOKEN_SIGNING_ALG_VALUES_SUPPORTED = "id_token_signing_alg_values_supported";
4141

4242
/**
4343
* {@code userinfo_endpoint} - the {@code URL} of the OpenID Connect 1.0 UserInfo Endpoint
4444
* @since 0.2.2
4545
*/
46-
String USER_INFO_ENDPOINT = "userinfo_endpoint";
46+
public static final String USER_INFO_ENDPOINT = "userinfo_endpoint";
47+
48+
private OidcProviderMetadataClaimNames() {
49+
}
4750

4851
}

oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/token/OAuth2TokenClaimNames.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,43 +27,46 @@
2727
* @see OAuth2TokenClaimsSet
2828
* @see OAuth2Token
2929
*/
30-
public interface OAuth2TokenClaimNames {
30+
public final class OAuth2TokenClaimNames {
3131

3232
/**
3333
* {@code iss} - the Issuer claim identifies the principal that issued the OAuth 2.0 Token
3434
*/
35-
String ISS = "iss";
35+
public static final String ISS = "iss";
3636

3737
/**
3838
* {@code sub} - the Subject claim identifies the principal that is the subject of the OAuth 2.0 Token
3939
*/
40-
String SUB = "sub";
40+
public static final String SUB = "sub";
4141

4242
/**
4343
* {@code aud} - the Audience claim identifies the recipient(s) that the OAuth 2.0 Token is intended for
4444
*/
45-
String AUD = "aud";
45+
public static final String AUD = "aud";
4646

4747
/**
4848
* {@code exp} - the Expiration time claim identifies the expiration time on or after
4949
* which the OAuth 2.0 Token MUST NOT be accepted for processing
5050
*/
51-
String EXP = "exp";
51+
public static final String EXP = "exp";
5252

5353
/**
5454
* {@code nbf} - the Not Before claim identifies the time before which the OAuth 2.0 Token
5555
* MUST NOT be accepted for processing
5656
*/
57-
String NBF = "nbf";
57+
public static final String NBF = "nbf";
5858

5959
/**
6060
* {@code iat} - The Issued at claim identifies the time at which the OAuth 2.0 Token was issued
6161
*/
62-
String IAT = "iat";
62+
public static final String IAT = "iat";
6363

6464
/**
6565
* {@code jti} - The ID claim provides a unique identifier for the OAuth 2.0 Token
6666
*/
67-
String JTI = "jti";
67+
public static final String JTI = "jti";
68+
69+
private OAuth2TokenClaimNames() {
70+
}
6871

6972
}

0 commit comments

Comments
 (0)