public class KnoxSession extends Object implements Closeable
| Modifier and Type | Field and Description |
|---|---|
static String |
BEGIN_CERTIFICATE |
static String |
END_CERTIFICATE |
static String |
JGSS_LOGIN_MOUDLE |
| Modifier | Constructor and Description |
|---|---|
protected |
KnoxSession() |
|
KnoxSession(ClientContext clientContext) |
| Modifier and Type | Method and Description |
|---|---|
String |
base() |
void |
close() |
protected org.apache.http.impl.client.CloseableHttpClient |
createClient(ClientContext clientContext) |
protected void |
discoverTruststoreDetails(ClientContext clientContext) |
<T> Future<T> |
executeLater(Callable<T> callable) |
org.apache.http.client.methods.CloseableHttpResponse |
executeNow(org.apache.http.HttpRequest request) |
protected X509Certificate |
generateCertificateFromBytes(byte[] certBytes) |
Map<String,String> |
getHeaders() |
static <T> Map<String,T> |
getMapFromJsonString(String json) |
static Map<String,KnoxDataSource> |
getMapOfDataSourcesFromJsonString(String json) |
static Map<String,List<String>> |
getMapOfStringArrayListsFromJsonString(String json) |
static KnoxSession |
kerberosLogin(String url)
Support kerberos authentication.
|
static KnoxSession |
kerberosLogin(String url,
boolean debug)
Support kerberos authentication.
|
static KnoxSession |
kerberosLogin(String url,
String jaasConf,
String krb5Conf,
boolean debug)
Support kerberos authentication.
|
static Map<String,KnoxDataSource> |
loadDataSources()
Load and return a map of datasource names to KnoxDataSource
objects from the {user.home}/.knoxshell/knoxdatasources.json file.
|
static Map<String,String> |
loadMountPoints() |
static Map<String,List<String>> |
loadSQLHistories()
Load and return a map of datasource names to sql commands
from the {user.home}/.knoxshell/knoxsqlhistories.json file.
|
static KnoxSession |
login(ClientContext context) |
static KnoxSession |
login(String url,
Map<String,String> headers) |
static KnoxSession |
login(String url,
Map<String,String> headers,
String truststoreLocation,
String truststorePass) |
static KnoxSession |
login(String url,
String username,
String password) |
static KnoxSession |
login(String url,
String username,
String password,
String truststoreLocation,
String truststorePass) |
static KnoxSession |
loginInsecure(String url,
String username,
String password) |
static void |
persistDataSources(Map<String,KnoxDataSource> datasources) |
static <T> void |
persistDataSourcesToKnoxShell(String fileName,
Map<String,T> map)
Persist provided Map to a file within the {user.home}/.knoxshell directory
|
static <T> void |
persistMapToKnoxShell(String fileName,
Map<String,T> map)
Persist provided Map to a file within the {user.home}/.knoxshell directory
|
static void |
persistMountPoints(Map<String,String> mounts) |
static void |
persistSQLHistory(Map<String,List<String>> sqlHistories) |
static <T> void |
persistToKnoxShell(String fileName,
Map<String,List<T>> map)
Persist provided Map to a file within the {user.home}/.knoxshell directory
|
void |
setHeaders(Map<String,String> headers) |
void |
shutdown() |
boolean |
shutdown(long timeout,
TimeUnit unit) |
String |
toString() |
void |
waitFor(Future<?>... futures) |
void |
waitFor(long timeout,
TimeUnit units,
Future<?>... futures) |
public static final String JGSS_LOGIN_MOUDLE
public static final String END_CERTIFICATE
public static final String BEGIN_CERTIFICATE
protected KnoxSession()
throws KnoxShellException,
URISyntaxException
KnoxShellExceptionURISyntaxExceptionpublic KnoxSession(ClientContext clientContext) throws KnoxShellException, URISyntaxException
KnoxShellExceptionURISyntaxExceptionpublic static KnoxSession login(String url, Map<String,String> headers) throws URISyntaxException
URISyntaxExceptionpublic static KnoxSession login(String url, Map<String,String> headers, String truststoreLocation, String truststorePass) throws URISyntaxException
URISyntaxExceptionpublic static KnoxSession login(String url, String username, String password) throws URISyntaxException
URISyntaxExceptionpublic static KnoxSession login(String url, String username, String password, String truststoreLocation, String truststorePass) throws URISyntaxException
URISyntaxExceptionpublic static KnoxSession login(ClientContext context) throws URISyntaxException
URISyntaxExceptionpublic static KnoxSession kerberosLogin(String url, String jaasConf, String krb5Conf, boolean debug) throws URISyntaxException
url - Gateway urljaasConf - jaas configuration (optional- can be null)krb5Conf - kerberos configuration (optional - can be null)debug - enable debug messagesURISyntaxException - exception in case of malformed urlpublic static KnoxSession kerberosLogin(String url) throws URISyntaxException
url - Gateway urlURISyntaxException - exception in case of malformed urlpublic static KnoxSession kerberosLogin(String url, boolean debug) throws URISyntaxException
url - Gateway urldebug - enable debug messagesURISyntaxException - exception in case of malformed urlpublic static KnoxSession loginInsecure(String url, String username, String password) throws URISyntaxException
URISyntaxExceptionprotected org.apache.http.impl.client.CloseableHttpClient createClient(ClientContext clientContext) throws GeneralSecurityException
GeneralSecurityExceptionprotected X509Certificate generateCertificateFromBytes(byte[] certBytes) throws CertificateException
CertificateExceptionprotected void discoverTruststoreDetails(ClientContext clientContext)
public String base()
public org.apache.http.client.methods.CloseableHttpResponse executeNow(org.apache.http.HttpRequest request)
throws IOException
IOExceptionpublic void waitFor(Future<?>... futures) throws ExecutionException, InterruptedException
public void waitFor(long timeout,
TimeUnit units,
Future<?>... futures)
throws ExecutionException,
TimeoutException,
InterruptedException
public void shutdown()
throws InterruptedException,
IOException
InterruptedExceptionIOExceptionpublic boolean shutdown(long timeout,
TimeUnit unit)
throws InterruptedException,
IOException
InterruptedExceptionIOExceptionpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionpublic static <T> void persistToKnoxShell(String fileName, Map<String,List<T>> map)
T - type of the listfileName - of persisted filemap - to persistpublic static <T> void persistDataSourcesToKnoxShell(String fileName, Map<String,T> map)
T - type of the value in the mapfileName - of persisted filemap - to persistpublic static <T> void persistMapToKnoxShell(String fileName, Map<String,T> map)
T - type of the value in the mapfileName - of persisted filemap - to persistpublic static void persistDataSources(Map<String,KnoxDataSource> datasources)
public static Map<String,List<String>> loadSQLHistories() throws IOException
IOException - exception when loading sql historypublic static Map<String,String> loadMountPoints() throws IOException
IOExceptionpublic static Map<String,KnoxDataSource> loadDataSources() throws IOException
IOException - exception when loading data sourcespublic static Map<String,List<String>> getMapOfStringArrayListsFromJsonString(String json) throws IOException
IOExceptionpublic static <T> Map<String,T> getMapFromJsonString(String json) throws IOException
IOExceptionpublic static Map<String,KnoxDataSource> getMapOfDataSourcesFromJsonString(String json) throws IOException
IOExceptionCopyright © 2020 The Apache Software Foundation. All rights reserved.