1
1
package org .baeldung .config ;
2
2
3
+ import java .util .ArrayList ;
4
+ import java .util .Collection ;
5
+ import java .util .List ;
6
+
3
7
import javax .annotation .Resource ;
4
8
import javax .servlet .http .HttpServletRequest ;
5
9
6
10
import org .springframework .security .oauth2 .common .OAuth2AccessToken ;
7
11
import org .springframework .security .oauth2 .provider .token .ConsumerTokenServices ;
8
12
import org .springframework .security .oauth2 .provider .token .TokenStore ;
9
13
import org .springframework .security .oauth2 .provider .token .store .JdbcTokenStore ;
10
- import java .util .Collection ;
11
- import java .util .List ;
12
- import java .util .ArrayList ;
13
14
import org .springframework .stereotype .Controller ;
14
15
import org .springframework .web .bind .annotation .PathVariable ;
15
16
import org .springframework .web .bind .annotation .RequestMapping ;
16
17
import org .springframework .web .bind .annotation .RequestMethod ;
17
18
import org .springframework .web .bind .annotation .ResponseBody ;
18
- import javax .servlet .http .HttpServletRequest ;
19
19
20
20
@ Controller
21
21
public class TokenController {
@@ -30,17 +30,17 @@ public class TokenController {
30
30
@ ResponseBody
31
31
public void revokeToken (HttpServletRequest request ) {
32
32
String authorization = request .getHeader ("Authorization" );
33
- if (authorization != null && authorization .contains ("Bearer" )){
34
- String tokenId = authorization .substring ("Bearer" .length ()+ 1 );
33
+ if (authorization != null && authorization .contains ("Bearer" )) {
34
+ String tokenId = authorization .substring ("Bearer" .length () + 1 );
35
35
tokenServices .revokeToken (tokenId );
36
36
}
37
- }
38
-
37
+ }
38
+
39
39
@ RequestMapping (method = RequestMethod .POST , value = "/oauth/token/revokeById/{tokenId}" )
40
40
@ ResponseBody
41
41
public void revokeToken (HttpServletRequest request , @ PathVariable String tokenId ) {
42
42
tokenServices .revokeToken (tokenId );
43
- }
43
+ }
44
44
45
45
@ RequestMapping (method = RequestMethod .GET , value = "/tokens" )
46
46
@ ResponseBody
0 commit comments