public class KerberosConnection extends Object
| Modifier and Type | Class and Description |
|---|---|
(package private) static class |
KerberosConnection.KeytabJaasConf
Javax Configuration for performing a keytab-based Kerberos login.
|
(package private) static class |
KerberosConnection.RenewalTask
Runnable for performing Kerberos renewals.
|
| Modifier and Type | Field and Description |
|---|---|
private static String |
IBM_KRB5_LOGIN_MODULE |
private static String |
JAAS_CONF_NAME |
private Configuration |
jaasConf |
private static org.slf4j.Logger |
LOG |
static float |
PERCENT_OF_LIFETIME_TO_RENEW
The percentage of the Kerberos ticket's lifetime which we should start trying to renew it
|
private String |
principal |
static long |
RENEWAL_PERIOD
How long should we sleep between checks to renew the Kerberos ticket
|
private static String |
RENEWAL_THREAD_NAME |
private KerberosConnection.RenewalTask |
renewalTask |
private Thread |
renewalThread |
private Subject |
subject |
private static String |
SUN_KRB5_LOGIN_MODULE |
| Constructor and Description |
|---|
KerberosConnection(String principal,
File keytab)
Constructs an instance.
|
| Modifier and Type | Method and Description |
|---|---|
(package private) LoginContext |
createLoginContext(Configuration conf) |
(package private) Map.Entry<KerberosConnection.RenewalTask,Thread> |
createRenewalThread(LoginContext originalContext,
Subject originalSubject,
long renewalPeriod)
Launches a thread to periodically check the current ticket's lifetime and perform a relogin
as necessary.
|
(package private) static String |
getKrb5LoginModuleName()
Returns the KRB5 LoginModule implementation.
|
Subject |
getSubject() |
(package private) static boolean |
isTGSPrincipal(KerberosPrincipal principal)
Computes if the given
principal is the ticket-granting system's principal ("krbtgt"). |
void |
login()
Perform a Kerberos login and launch a daemon thread to periodically perfrom renewals of that
Kerberos login.
|
(package private) Map.Entry<LoginContext,Subject> |
login(LoginContext prevContext,
Configuration conf,
Subject subject)
Performs a kerberos login, possibly logging out first.
|
(package private) Map.Entry<LoginContext,Subject> |
performKerberosLogin()
Performs a Kerberos login given the
principal and keytab. |
void |
stopRenewalThread()
Stops the Kerberos renewal thread if it is still running.
|
private static final org.slf4j.Logger LOG
private static final String IBM_KRB5_LOGIN_MODULE
private static final String SUN_KRB5_LOGIN_MODULE
private static final String JAAS_CONF_NAME
private static final String RENEWAL_THREAD_NAME
public static final float PERCENT_OF_LIFETIME_TO_RENEW
public static final long RENEWAL_PERIOD
private final String principal
private final Configuration jaasConf
private Subject subject
private KerberosConnection.RenewalTask renewalTask
private Thread renewalThread
public Subject getSubject()
public void login()
RuntimeException - If the Kerberos login failsMap.Entry<LoginContext,Subject> performKerberosLogin()
principal and keytab.Subject and LoginContext from the successful login.RuntimeException - if the login failedMap.Entry<LoginContext,Subject> login(LoginContext prevContext, Configuration conf, Subject subject) throws LoginException
prevContext - The LoginContext from the previous login, or nullconf - JAAS Configuration objectsubject - The JAAS SubjectLoginException - If the login failed.LoginContext createLoginContext(Configuration conf) throws LoginException
LoginExceptionMap.Entry<KerberosConnection.RenewalTask,Thread> createRenewalThread(LoginContext originalContext, Subject originalSubject, long renewalPeriod)
originalContext - The original login's context.originalSubject - The original login's subject.renewalPeriod - The amount of time to sleep inbetween checks to renewpublic void stopRenewalThread()
static boolean isTGSPrincipal(KerberosPrincipal principal)
principal is the ticket-granting system's principal ("krbtgt").principal - A KerberosPrincipal.principal is the TGS principal, false otherwise.static String getKrb5LoginModuleName()
Copyright © 2012–2017 The Apache Software Foundation. All rights reserved.