public abstract class AbstractKerberosUser extends Object implements KerberosUser
| Modifier and Type | Field and Description |
|---|---|
(package private) static String |
DATE_FORMAT |
protected AtomicBoolean |
loggedIn |
private static org.slf4j.Logger |
LOGGER |
protected LoginContext |
loginContext |
protected String |
principal |
protected Subject |
subject |
(package private) static float |
TICKET_RENEW_WINDOW
Percentage of the ticket window to use before we renew the TGT.
|
| Constructor and Description |
|---|
AbstractKerberosUser(String principal) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
checkTGTAndRelogin()
Re-login a user from keytab if TGT is expired or is close to expiry.
|
protected abstract LoginContext |
createLoginContext(Subject subject) |
<T> T |
doAs(PrivilegedAction<T> action)
Executes the PrivilegedAction as this user.
|
<T> T |
doAs(PrivilegedExceptionAction<T> action)
Executes the PrivilegedAction as this user.
|
String |
getPrincipal() |
private long |
getRefreshTime(KerberosTicket tgt) |
(package private) Subject |
getSubject() |
private KerberosTicket |
getTGT()
Get the Kerberos TGT.
|
boolean |
isLoggedIn() |
private boolean |
isTGSPrincipal(KerberosPrincipal principal)
TGS must have the server principal of the form "krbtgt/FOO@FOO".
|
void |
login()
Performs a login using the specified principal and keytab.
|
void |
logout()
Performs a logout of the current user.
|
private static final org.slf4j.Logger LOGGER
static final String DATE_FORMAT
static final float TICKET_RENEW_WINDOW
protected final String principal
protected final AtomicBoolean loggedIn
protected Subject subject
protected LoginContext loginContext
public AbstractKerberosUser(String principal)
public void login()
throws LoginException
login in interface KerberosUserLoginException - if the login failsprotected abstract LoginContext createLoginContext(Subject subject) throws LoginException
LoginExceptionpublic void logout()
throws LoginException
logout in interface KerberosUserLoginException - if the logout failspublic <T> T doAs(PrivilegedAction<T> action) throws IllegalStateException
doAs in interface KerberosUserT - the type of resultaction - the action to executeIllegalStateException - if this method is called while not logged inpublic <T> T doAs(PrivilegedExceptionAction<T> action) throws IllegalStateException, PrivilegedActionException
doAs in interface KerberosUserT - the type of resultaction - the action to executeIllegalStateException - if this method is called while not logged inPrivilegedActionException - if an exception is thrown from the actionpublic boolean checkTGTAndRelogin()
throws LoginException
checkTGTAndRelogin in interface KerberosUserLoginException - if an error happens performing the re-loginprivate KerberosTicket getTGT()
private boolean isTGSPrincipal(KerberosPrincipal principal)
principal - the principal to checkprivate long getRefreshTime(KerberosTicket tgt)
public boolean isLoggedIn()
isLoggedIn in interface KerberosUserpublic String getPrincipal()
getPrincipal in interface KerberosUserSubject getSubject()
Copyright © 2020 Apache NiFi Project. All rights reserved.