File tree 3 files changed +35
-3
lines changed
oauth2-authorization-server/src
main/java/org/springframework/security/oauth2
server/authorization/authentication
test/java/org/springframework/security/oauth2/server/authorization/authentication
3 files changed +35
-3
lines changed Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright 2020 the original author or authors.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * https://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ package org .springframework .security .oauth2 .core ;
17
+
18
+ /**
19
+ * TODO
20
+ * This class is temporary and will be removed after upgrading to Spring Security 5.5.0 GA.
21
+ *
22
+ * @author Joe Grandja
23
+ * @since 0.0.3
24
+ * @see <a target="_blank" href="https://github.com/spring-projects/spring-security/issues/9184">Issue gh-9184</a>
25
+ */
26
+ public interface OAuth2ErrorCodes2 extends OAuth2ErrorCodes {
27
+
28
+ String UNSUPPORTED_TOKEN_TYPE = "unsupported_token_type" ;
29
+
30
+ }
Original file line number Diff line number Diff line change 22
22
import org .springframework .security .oauth2 .core .OAuth2AuthenticationException ;
23
23
import org .springframework .security .oauth2 .core .OAuth2Error ;
24
24
import org .springframework .security .oauth2 .core .OAuth2ErrorCodes ;
25
+ import org .springframework .security .oauth2 .core .OAuth2ErrorCodes2 ;
25
26
import org .springframework .security .oauth2 .server .authorization .OAuth2Authorization ;
26
27
import org .springframework .security .oauth2 .server .authorization .OAuth2AuthorizationService ;
27
28
import org .springframework .security .oauth2 .server .authorization .TokenType ;
@@ -71,7 +72,7 @@ public Authentication authenticate(Authentication authentication) throws Authent
71
72
} else if (TokenType .ACCESS_TOKEN .getValue ().equals (tokenTypeHint )) {
72
73
tokenType = TokenType .ACCESS_TOKEN ;
73
74
} else {
74
- throw new OAuth2AuthenticationException (new OAuth2Error (OAuth2ErrorCodes .UNSUPPORTED_TOKEN_TYPE ));
75
+ throw new OAuth2AuthenticationException (new OAuth2Error (OAuth2ErrorCodes2 .UNSUPPORTED_TOKEN_TYPE ));
75
76
}
76
77
}
77
78
Original file line number Diff line number Diff line change 22
22
import org .springframework .security .oauth2 .core .OAuth2AccessToken ;
23
23
import org .springframework .security .oauth2 .core .OAuth2AuthenticationException ;
24
24
import org .springframework .security .oauth2 .core .OAuth2ErrorCodes ;
25
+ import org .springframework .security .oauth2 .core .OAuth2ErrorCodes2 ;
25
26
import org .springframework .security .oauth2 .core .OAuth2RefreshToken ;
26
27
import org .springframework .security .oauth2 .server .authorization .OAuth2Authorization ;
27
28
import org .springframework .security .oauth2 .server .authorization .OAuth2AuthorizationService ;
@@ -100,12 +101,12 @@ public void authenticateWhenInvalidTokenTypeThenThrowOAuth2AuthenticationExcepti
100
101
RegisteredClient registeredClient = TestRegisteredClients .registeredClient ().build ();
101
102
OAuth2ClientAuthenticationToken clientPrincipal = new OAuth2ClientAuthenticationToken (registeredClient );
102
103
OAuth2TokenRevocationAuthenticationToken authentication = new OAuth2TokenRevocationAuthenticationToken (
103
- "token" , clientPrincipal , OAuth2ErrorCodes .UNSUPPORTED_TOKEN_TYPE );
104
+ "token" , clientPrincipal , OAuth2ErrorCodes2 .UNSUPPORTED_TOKEN_TYPE );
104
105
assertThatThrownBy (() -> this .authenticationProvider .authenticate (authentication ))
105
106
.isInstanceOf (OAuth2AuthenticationException .class )
106
107
.extracting (ex -> ((OAuth2AuthenticationException ) ex ).getError ())
107
108
.extracting ("errorCode" )
108
- .isEqualTo (OAuth2ErrorCodes .UNSUPPORTED_TOKEN_TYPE );
109
+ .isEqualTo (OAuth2ErrorCodes2 .UNSUPPORTED_TOKEN_TYPE );
109
110
}
110
111
111
112
@ Test
You can’t perform that action at this time.
0 commit comments