All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.factset.sdk.FactSetFunds.auth.FactSetOAuth2ClientAuth Maven / Gradle / Ivy

There is a newer version: 2.1.1
Show newest version
package com.factset.sdk.FactSetFunds.auth;

import com.factset.sdk.FactSetFunds.ApiException;
import com.factset.sdk.FactSetFunds.Pair;
import com.factset.sdk.utils.authentication.OAuth2Client;
import com.factset.sdk.utils.exceptions.AccessTokenException;
import com.factset.sdk.utils.exceptions.SigningJwsException;

import java.net.URI;
import java.util.List;
import java.util.Map;

public class FactSetOAuth2ClientAuth implements Authentication {
  private OAuth2Client client;

  public FactSetOAuth2ClientAuth() {}

  public FactSetOAuth2ClientAuth(OAuth2Client client) {
    this.client = client;
  }

  public void setClient(OAuth2Client client) {
    this.client = client;
  }

  public OAuth2Client getClient() {
    return client;
  }

  @Override
  public void applyToParams(List queryParams, Map headerParams,
                            Map cookieParams, String payload, String method, URI uri)
          throws ApiException {
      if (client == null) {
        return;
      }

      try {
        headerParams.put("Authorization", "Bearer " + client.getAccessToken());
      } catch (SigningJwsException | AccessTokenException e) {
        throw new ApiException(e);
      }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy