From f623d53e73eb39af787718309b292aa3f157ba33 Mon Sep 17 00:00:00 2001 From: mountford Date: Wed, 2 Aug 2017 10:31:03 -0700 Subject: [PATCH] Remove invalid comment and add temp variable It was not a problem after all to handle multiple scopes. Also added a temp variable to avoid making the same array conversion over and over. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=164002903 --- .../auth/OAuthAuthenticationMechanism.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/java/google/registry/request/auth/OAuthAuthenticationMechanism.java b/java/google/registry/request/auth/OAuthAuthenticationMechanism.java index 62704a0ee..9b196e04d 100644 --- a/java/google/registry/request/auth/OAuthAuthenticationMechanism.java +++ b/java/google/registry/request/auth/OAuthAuthenticationMechanism.java @@ -84,21 +84,20 @@ public class OAuthAuthenticationMechanism implements AuthenticationMechanism { String rawAccessToken = header.substring(BEARER_PREFIX.length()); // Get the OAuth information. The various oauthService method calls use a single cached - // authentication result, we can call them one by one. Unfortunately, the calls have a - // single-scope form, and a varargs scope list form, but no way to call them with a collection - // of scopes, so it will not be easy to configure multiple scopes. + // authentication result, so we can call them one by one. User currentUser; boolean isUserAdmin; String clientId; ImmutableSet authorizedScopes; try { - currentUser = oauthService.getCurrentUser(availableOauthScopes.toArray(new String[0])); - isUserAdmin = oauthService.isUserAdmin(availableOauthScopes.toArray(new String[0])); + String[] availableOauthScopeArray = availableOauthScopes.toArray(new String[0]); + currentUser = oauthService.getCurrentUser(availableOauthScopeArray); + isUserAdmin = oauthService.isUserAdmin(availableOauthScopeArray); logger.infofmt("current user: %s (%s)", currentUser, isUserAdmin ? "admin" : "not admin"); - clientId = oauthService.getClientId(availableOauthScopes.toArray(new String[0])); + clientId = oauthService.getClientId(availableOauthScopeArray); logger.infofmt("client ID: %s", clientId); - authorizedScopes = ImmutableSet - .copyOf(oauthService.getAuthorizedScopes(availableOauthScopes.toArray(new String[0]))); + authorizedScopes = + ImmutableSet.copyOf(oauthService.getAuthorizedScopes(availableOauthScopeArray)); logger.infofmt("authorized scope(s): %s", authorizedScopes); } catch (OAuthRequestException | OAuthServiceFailureException e) { logger.infofmt(e, "unable to get OAuth information");