Skip to content

Commit

Permalink
minor formatting cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
eugenp committed Apr 14, 2017
1 parent 461c3e8 commit 25c4777
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
package org.baeldung.config;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.security.oauth2.common.OAuth2AccessToken;
import org.springframework.security.oauth2.provider.token.ConsumerTokenServices;
import org.springframework.security.oauth2.provider.token.TokenStore;
import org.springframework.security.oauth2.provider.token.store.JdbcTokenStore;
import java.util.Collection;
import java.util.List;
import java.util.ArrayList;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;

@Controller
public class TokenController {
Expand All @@ -29,11 +30,11 @@ public class TokenController {
@ResponseBody
public void revokeToken(HttpServletRequest request) {
String authorization = request.getHeader("Authorization");
if (authorization != null && authorization.contains("Bearer")){
String tokenId = authorization.substring("Bearer".length()+1);
if (authorization != null && authorization.contains("Bearer")) {
String tokenId = authorization.substring("Bearer".length() + 1);
tokenServices.revokeToken(tokenId);
}
}
}

@RequestMapping(method = RequestMethod.GET, value = "/tokens")
@ResponseBody
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public class CustomPostZuulFilter extends ZuulFilter {
public Object run() {
final RequestContext ctx = RequestContext.getCurrentContext();
logger.info("in zuul filter " + ctx.getRequest().getRequestURI());
String requestURI = ctx.getRequest().getRequestURI();

String requestURI = ctx.getRequest().getRequestURI();

try {
final InputStream is = ctx.getResponseDataStream();
Expand All @@ -47,13 +47,12 @@ public Object run() {
ctx.getResponse().addCookie(cookie);
logger.info("refresh token = " + refreshToken);

}
else if (requestURI.contains("oauth/token/revoke")){
Cookie cookie = new Cookie("refreshToken","");
} else if (requestURI.contains("oauth/token/revoke")) {
Cookie cookie = new Cookie("refreshToken", "");
cookie.setMaxAge(0);
cookie.setPath(ctx.getRequest().getContextPath() + "/oauth/token");
cookie.setPath(ctx.getRequest().getContextPath() + "/oauth/token");
ctx.getResponse().addCookie(cookie);
}
}
ctx.setResponseBody(responseBody);

} catch (final IOException e) {
Expand Down

0 comments on commit 25c4777

Please sign in to comment.