Search in sources :

Example 1 with OAuthTokenCredentials

use of org.apache.drill.exec.store.security.oauth.OAuthTokenCredentials in project drill by apache.

the class PluginConfigWrapper method isOauth.

/**
 * Determines whether the storage plugin in question needs the OAuth button in the UI.  In
 * order to be considered an OAuth plugin, the plugin must:
 * 1. Use AbstractSecuredStoragePluginConfig
 * 2. The credential provider must not be null
 * 3. The credentialsProvider must contain a client_id and client_secret
 * @return true if the plugin uses OAuth, false if not.
 */
@JsonIgnore
public boolean isOauth() {
    if (!(config instanceof AbstractSecuredStoragePluginConfig)) {
        return false;
    }
    AbstractSecuredStoragePluginConfig securedStoragePluginConfig = (AbstractSecuredStoragePluginConfig) config;
    CredentialsProvider credentialsProvider = securedStoragePluginConfig.getCredentialsProvider();
    if (credentialsProvider == null) {
        return false;
    }
    OAuthTokenCredentials tokenCredentials = new OAuthTokenCredentials(credentialsProvider);
    return !StringUtils.isEmpty(tokenCredentials.getClientID()) || !StringUtils.isEmpty(tokenCredentials.getClientSecret());
}
Also used : OAuthTokenCredentials(org.apache.drill.exec.store.security.oauth.OAuthTokenCredentials) CredentialsProvider(org.apache.drill.common.logical.security.CredentialsProvider) AbstractSecuredStoragePluginConfig(org.apache.drill.common.logical.AbstractSecuredStoragePluginConfig) JsonIgnore(com.fasterxml.jackson.annotation.JsonIgnore)

Aggregations

JsonIgnore (com.fasterxml.jackson.annotation.JsonIgnore)1 AbstractSecuredStoragePluginConfig (org.apache.drill.common.logical.AbstractSecuredStoragePluginConfig)1 CredentialsProvider (org.apache.drill.common.logical.security.CredentialsProvider)1 OAuthTokenCredentials (org.apache.drill.exec.store.security.oauth.OAuthTokenCredentials)1