コード例 #1
0
ファイル: GitHubImpl.java プロジェクト: jolivares/socialauth
 private String getScope() {
   StringBuffer result = new StringBuffer();
   String arr[] = null;
   if (Permission.AUTHENTICATE_ONLY.equals(scope)) {
     arr = AuthPerms;
   } else if (Permission.CUSTOM.equals(scope) && config.getCustomPermissions() != null) {
     arr = config.getCustomPermissions().split(",");
   } else {
     arr = AllPerms;
   }
   result.append(arr[0]);
   for (int i = 1; i < arr.length; i++) {
     result.append(",").append(arr[i]);
   }
   String pluginScopes = getPluginsScope(config);
   if (pluginScopes != null) {
     result.append(",").append(pluginScopes);
   }
   return result.toString();
 }
コード例 #2
0
ファイル: GitHubImpl.java プロジェクト: jolivares/socialauth
  /**
   * Stores configuration for the provider
   *
   * @param providerConfig It contains the configuration of application like consumer key and
   *     consumer secret
   * @throws Exception
   */
  public GitHubImpl(final OAuthConfig providerConfig) throws Exception {
    config = providerConfig;
    if (config.getCustomPermissions() != null) {
      scope = Permission.CUSTOM;
    }

    if (config.getAuthenticationUrl() != null) {
      ENDPOINTS.put(Constants.OAUTH_AUTHORIZATION_URL, config.getAuthenticationUrl());
    } else {
      config.setAuthenticationUrl(ENDPOINTS.get(Constants.OAUTH_AUTHORIZATION_URL));
    }

    if (config.getAccessTokenUrl() != null) {
      ENDPOINTS.put(Constants.OAUTH_ACCESS_TOKEN_URL, config.getAccessTokenUrl());
    } else {
      config.setAccessTokenUrl(ENDPOINTS.get(Constants.OAUTH_ACCESS_TOKEN_URL));
    }

    authenticationStrategy = new OAuth2(config, ENDPOINTS);
    authenticationStrategy.setPermission(scope);
    authenticationStrategy.setScope(getScope());
  }