Search in sources :

Example 11 with CredentialsProvider

use of org.apache.drill.common.logical.security.CredentialsProvider 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

CredentialsProvider (org.apache.drill.common.logical.security.CredentialsProvider)11 EnvCredentialsProvider (org.apache.drill.exec.store.security.EnvCredentialsProvider)8 HadoopCredentialsProvider (org.apache.drill.exec.store.security.HadoopCredentialsProvider)8 VaultCredentialsProvider (org.apache.drill.exec.store.security.vault.VaultCredentialsProvider)8 ClusterTest (org.apache.drill.test.ClusterTest)8 Test (org.junit.Test)8 PlainCredentialsProvider (org.apache.drill.common.logical.security.PlainCredentialsProvider)6 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)5 DrillConfig (org.apache.drill.common.config.DrillConfig)2 AbstractSecuredStoragePluginConfig (org.apache.drill.common.logical.AbstractSecuredStoragePluginConfig)2 JsonIgnore (com.fasterxml.jackson.annotation.JsonIgnore)1 BufferedReader (java.io.BufferedReader)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 HashMap (java.util.HashMap)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1