com.factset.sdk.FactSetOwnershipReportBuilder.auth.FactSetOAuth2ClientAuth Maven / Gradle / Ivy
package com.factset.sdk.FactSetOwnershipReportBuilder.auth;
import com.factset.sdk.FactSetOwnershipReportBuilder.ApiException;
import com.factset.sdk.FactSetOwnershipReportBuilder.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);
}
}
}