blob: 9549f7b35553db33399ad6f579f35edcceab2b75 [file] [log] [blame]
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.drill.common.logical;
import org.apache.drill.common.logical.security.CredentialsProvider;
import org.apache.drill.common.logical.security.PlainCredentialsProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public abstract class CredentialedStoragePluginConfig extends StoragePluginConfig {
private static final Logger logger = LoggerFactory.getLogger(CredentialedStoragePluginConfig.class);
protected boolean directCredentials;
protected final CredentialsProvider credentialsProvider;
public CredentialedStoragePluginConfig() {
this(PlainCredentialsProvider.EMPTY_CREDENTIALS_PROVIDER, true);
}
public CredentialedStoragePluginConfig(
CredentialsProvider credentialsProvider,
boolean directCredentials
) {
// Default auth mode for credentialed storage plugins is shared user.
this(credentialsProvider, directCredentials, AuthMode.SHARED_USER);
}
public CredentialedStoragePluginConfig(
CredentialsProvider credentialsProvider,
boolean directCredentials,
AuthMode authMode
) {
this.credentialsProvider = credentialsProvider;
this.directCredentials = directCredentials;
this.authMode = authMode;
}
public abstract CredentialedStoragePluginConfig updateCredentialProvider(CredentialsProvider credentialsProvider);
@Override
public boolean isEnabled() {
logger.debug("Enabled status");
return super.isEnabled();
}
public CredentialsProvider getCredentialsProvider() {
if (directCredentials) {
return null;
}
return credentialsProvider;
}
}