File tree Expand file tree Collapse 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 Expand file tree Collapse file tree 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 2222import org .springframework .security .oauth2 .core .OAuth2AuthenticationException ;
2323import org .springframework .security .oauth2 .core .OAuth2Error ;
2424import org .springframework .security .oauth2 .core .OAuth2ErrorCodes ;
25+ import org .springframework .security .oauth2 .core .OAuth2ErrorCodes2 ;
2526import org .springframework .security .oauth2 .server .authorization .OAuth2Authorization ;
2627import org .springframework .security .oauth2 .server .authorization .OAuth2AuthorizationService ;
2728import org .springframework .security .oauth2 .server .authorization .TokenType ;
@@ -71,7 +72,7 @@ public Authentication authenticate(Authentication authentication) throws Authent
7172 } else if (TokenType .ACCESS_TOKEN .getValue ().equals (tokenTypeHint )) {
7273 tokenType = TokenType .ACCESS_TOKEN ;
7374 } else {
74- throw new OAuth2AuthenticationException (new OAuth2Error (OAuth2ErrorCodes .UNSUPPORTED_TOKEN_TYPE ));
75+ throw new OAuth2AuthenticationException (new OAuth2Error (OAuth2ErrorCodes2 .UNSUPPORTED_TOKEN_TYPE ));
7576 }
7677 }
7778
Original file line number Diff line number Diff line change 2222import org .springframework .security .oauth2 .core .OAuth2AccessToken ;
2323import org .springframework .security .oauth2 .core .OAuth2AuthenticationException ;
2424import org .springframework .security .oauth2 .core .OAuth2ErrorCodes ;
25+ import org .springframework .security .oauth2 .core .OAuth2ErrorCodes2 ;
2526import org .springframework .security .oauth2 .core .OAuth2RefreshToken ;
2627import org .springframework .security .oauth2 .server .authorization .OAuth2Authorization ;
2728import org .springframework .security .oauth2 .server .authorization .OAuth2AuthorizationService ;
@@ -100,12 +101,12 @@ public void authenticateWhenInvalidTokenTypeThenThrowOAuth2AuthenticationExcepti
100101 RegisteredClient registeredClient = TestRegisteredClients .registeredClient ().build ();
101102 OAuth2ClientAuthenticationToken clientPrincipal = new OAuth2ClientAuthenticationToken (registeredClient );
102103 OAuth2TokenRevocationAuthenticationToken authentication = new OAuth2TokenRevocationAuthenticationToken (
103- "token" , clientPrincipal , OAuth2ErrorCodes .UNSUPPORTED_TOKEN_TYPE );
104+ "token" , clientPrincipal , OAuth2ErrorCodes2 .UNSUPPORTED_TOKEN_TYPE );
104105 assertThatThrownBy (() -> this .authenticationProvider .authenticate (authentication ))
105106 .isInstanceOf (OAuth2AuthenticationException .class )
106107 .extracting (ex -> ((OAuth2AuthenticationException ) ex ).getError ())
107108 .extracting ("errorCode" )
108- .isEqualTo (OAuth2ErrorCodes .UNSUPPORTED_TOKEN_TYPE );
109+ .isEqualTo (OAuth2ErrorCodes2 .UNSUPPORTED_TOKEN_TYPE );
109110 }
110111
111112 @ Test
You can’t perform that action at this time.
0 commit comments