Skip to content

Commit e110bb3

Browse files
author
Les Vogel
committed
More check style goodness.
1 parent 1b008aa commit e110bb3

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

appengine/oauth2/src/main/java/com/example/appengine/Oauth2Filter.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
*/
1414
package com.example.appengine;
1515

16+
import static com.google.appengine.api.utils.SystemProperty.environment;
17+
1618
import com.google.appengine.api.oauth.OAuthRequestException;
1719
import com.google.appengine.api.oauth.OAuthService;
1820
import com.google.appengine.api.oauth.OAuthServiceFactory;
@@ -33,8 +35,6 @@
3335
import javax.servlet.ServletResponse;
3436
import javax.servlet.http.HttpServletResponse;
3537

36-
import static com.google.appengine.api.utils.SystemProperty.environment;
37-
3838
/**
3939
* Filter to verify that request has a "Authorization: Bearer xxxx" header,
4040
* and check if xxxx is authorized to use this app.
@@ -55,11 +55,12 @@ public void init(final FilterConfig config) throws ServletException {
5555
@Override
5656
public void doFilter(final ServletRequest servletReq, final ServletResponse servletResp,
5757
final FilterChain chain) throws IOException, ServletException {
58+
final String scope = "https://www.googleapis.com/auth/userinfo.email";
59+
Set<String> allowedClients = new HashSet<>();
60+
5861
HttpServletResponse resp = (HttpServletResponse) servletResp;
5962

6063
OAuthService oauth = OAuthServiceFactory.getOAuthService();
61-
final String scope = "https://www.googleapis.com/auth/userinfo.email";
62-
Set<String> allowedClients = new HashSet<>();
6364

6465
allowedClients.add("407408718192.apps.googleusercontent.com"); // list of client ids to allow
6566
allowedClients.add("755878275993-j4k7emq6rlupctce1c28enpcrr50vfo1.apps.googleusercontent.com");
@@ -68,7 +69,7 @@ public void doFilter(final ServletRequest servletReq, final ServletResponse serv
6869
SystemProperty.Environment.Value env = environment.value();
6970
if (env == SystemProperty.Environment.Value.Production) { // APIs only work in Production
7071
try {
71-
User user = oauth.getCurrentUser(scope); // From "Authorization: Bearer" http req header
72+
User user = oauth.getCurrentUser(scope);
7273
String tokenAudience = oauth.getClientId(scope);
7374

7475
// The line below is commented out for privacy.

0 commit comments

Comments
 (0)