Package com.google.apphosting.api.UserServicePb

Examples of com.google.apphosting.api.UserServicePb.GetOAuthUserResponse


    return getCurrentUser(scopes);
  }

  @Override
  public User getCurrentUser(String... scopes) throws OAuthRequestException {
    GetOAuthUserResponse response = getGetOAuthUserResponse(scopes);
    return new User(response.getEmail(), response.getAuthDomain(),
        response.getUserId());
  }
View Full Code Here


    return getClientId(scopes);
  }

  @Override
  public String getClientId(String... scopes) throws OAuthRequestException {
    GetOAuthUserResponse response = getGetOAuthUserResponse(scopes);
    return response.getClientId();
  }
View Full Code Here

    return response.getClientId();
  }

  @Override
  public String[] getAuthorizedScopes(String... scopes) throws OAuthRequestException {
    GetOAuthUserResponse response = getGetOAuthUserResponse(scopes);
    return response.scopess().toArray(new String[response.scopesSize()]);
  }
View Full Code Here

  }

  private GetOAuthUserResponse getGetOAuthUserResponse(String[] scopes)
      throws OAuthRequestException {
    ApiProxy.Environment environment = ApiProxy.getCurrentEnvironment();
    GetOAuthUserResponse response = (GetOAuthUserResponse)
        environment.getAttributes().get(GET_OAUTH_USER_RESPONSE_KEY);
    String scopesKey = "[]";
    if (scopes != null && scopes.length > 0) {
      String[] scopesCopy = scopes.clone();
      Arrays.sort(scopesCopy);
      scopesKey = Arrays.toString(scopesCopy);
    }
    String lastScopesKey = (String) environment.getAttributes().get(GET_OAUTH_USER_SCOPE_KEY);
    if (response == null || !Objects.equals(lastScopesKey, scopesKey)) {
      GetOAuthUserRequest request = new GetOAuthUserRequest();
      if (scopes != null) {
        for (String scope : scopes) {
          request.addScopes(scope);
        }
      }
      Boolean requestWriterPermission = (Boolean) environment.getAttributes().get(
          REQUEST_WRITER_PERMISSION_KEY);
      if (requestWriterPermission != null && requestWriterPermission) {
        request.setRequestWriterPermission(true);
      }
      byte[] responseBytes = makeSyncCall(GET_OAUTH_USER_METHOD, request);
      response = new GetOAuthUserResponse();
      response.mergeFrom(responseBytes);
      environment.getAttributes().put(GET_OAUTH_USER_RESPONSE_KEY, response);
      environment.getAttributes().put(GET_OAUTH_USER_SCOPE_KEY, scopesKey);
    }
    return response;
  }
View Full Code Here

  public User getCurrentUser() throws OAuthRequestException {
    return getCurrentUser(null);
  }

  public User getCurrentUser(String scope) throws OAuthRequestException {
    GetOAuthUserResponse response = getGetOAuthUserResponse(scope);
    return new User(response.getEmail(), response.getAuthDomain(),
        response.getUserId());
  }
View Full Code Here

      throws OAuthRequestException {
    if (scope == null) {
      scope = "";
    }
    ApiProxy.Environment environment = ApiProxy.getCurrentEnvironment();
    GetOAuthUserResponse response = (GetOAuthUserResponse)
        environment.getAttributes().get(GET_OAUTH_USER_RESPONSE_KEY);
    String lastScope = (String) environment.getAttributes().get(GET_OAUTH_USER_SCOPE_KEY);
    if (response == null || !Objects.equal(lastScope, scope)) {
      GetOAuthUserRequest request = new GetOAuthUserRequest();
      if (!scope.isEmpty()) {
        request.setScope(scope);
      }
      byte[] responseBytes = makeSyncCall(GET_OAUTH_USER_METHOD, request);
      response = new GetOAuthUserResponse();
      response.mergeFrom(responseBytes);
      environment.getAttributes().put(GET_OAUTH_USER_RESPONSE_KEY, response);
      environment.getAttributes().put(GET_OAUTH_USER_SCOPE_KEY, scope);
    }
    return response;
  }
View Full Code Here

    return responseBytes;
  }

  @Override
  public String getClientId(String scope) throws OAuthRequestException {
    GetOAuthUserResponse response = getGetOAuthUserResponse(scope);
    return response.getClientId();
  }
View Full Code Here

TOP

Related Classes of com.google.apphosting.api.UserServicePb.GetOAuthUserResponse

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.