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

io.github.jpmorganchase.fusion.oauth.provider.SimpleDatasetTokenProvider Maven / Gradle / Ivy

There is a newer version: 0.0.14
Show newest version
package io.github.jpmorganchase.fusion.oauth.provider;

import io.github.jpmorganchase.fusion.oauth.exception.OAuthException;
import io.github.jpmorganchase.fusion.oauth.model.BearerToken;
import java.util.Map;

public class SimpleDatasetTokenProvider implements DatasetTokenProvider {

    private static final String BEARER_TOKEN_NOT_FOUND_ERROR = "Bearer token not found for catalog %s and dataset %s";

    private final Map datasetTokens;

    public SimpleDatasetTokenProvider(Map datasetTokens) {
        this.datasetTokens = datasetTokens;
    }

    @Override
    public String getDatasetBearerToken(String catalog, String dataset) {

        String tokenKey = String.format("%s_%s", catalog, dataset);
        if (datasetTokens.containsKey(tokenKey)) {
            return datasetTokens.get(tokenKey).getToken();
        }

        throw new OAuthException(String.format(BEARER_TOKEN_NOT_FOUND_ERROR, catalog, dataset));
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy