use of io.airlift.http.client.spnego.KerberosConfig in project presto by prestodb.
the class ClientOptions method toKerberosConfig.
public KerberosConfig toKerberosConfig() {
KerberosConfig config = new KerberosConfig();
if (krb5ConfigPath != null) {
config.setConfig(new File(krb5ConfigPath));
}
if (krb5KeytabPath != null) {
config.setKeytab(new File(krb5KeytabPath));
}
if (krb5CredentialCachePath != null) {
config.setCredentialCache(new File(krb5CredentialCachePath));
}
config.setUseCanonicalHostname(!krb5DisableRemoteServiceHostnameCanonicalization);
return config;
}
use of io.airlift.http.client.spnego.KerberosConfig in project presto by prestodb.
the class Console method run.
@Override
public void run() {
ClientSession session = clientOptions.toClientSession();
KerberosConfig kerberosConfig = clientOptions.toKerberosConfig();
boolean hasQuery = !Strings.isNullOrEmpty(clientOptions.execute);
boolean isFromFile = !Strings.isNullOrEmpty(clientOptions.file);
if (!hasQuery && !isFromFile) {
AnsiConsole.systemInstall();
}
initializeLogging(clientOptions.logLevelsFile);
String query = clientOptions.execute;
if (hasQuery) {
query += ";";
}
if (isFromFile) {
if (hasQuery) {
throw new RuntimeException("both --execute and --file specified");
}
try {
query = Files.toString(new File(clientOptions.file), UTF_8);
hasQuery = true;
} catch (IOException e) {
throw new RuntimeException(format("Error reading from file %s: %s", clientOptions.file, e.getMessage()));
}
}
AtomicBoolean exiting = new AtomicBoolean();
interruptThreadOnExit(Thread.currentThread(), exiting);
try (QueryRunner queryRunner = QueryRunner.create(session, Optional.ofNullable(clientOptions.socksProxy), Optional.ofNullable(clientOptions.keystorePath), Optional.ofNullable(clientOptions.keystorePassword), Optional.ofNullable(clientOptions.truststorePath), Optional.ofNullable(clientOptions.truststorePassword), Optional.ofNullable(clientOptions.user), clientOptions.password ? Optional.of(getPassword()) : Optional.empty(), Optional.ofNullable(clientOptions.krb5Principal), Optional.ofNullable(clientOptions.krb5RemoteServiceName), clientOptions.authenticationEnabled, kerberosConfig)) {
if (hasQuery) {
executeCommand(queryRunner, query, clientOptions.outputFormat);
} else {
runConsole(queryRunner, session, exiting);
}
}
}
Aggregations