public class StandardKeytabUser extends Object implements KeytabUser
Modifier and Type | Field and Description |
---|---|
(package private) static String |
DATE_FORMAT |
private String |
keytabFile |
private AtomicBoolean |
loggedIn |
private static org.slf4j.Logger |
LOGGER |
private LoginContext |
loginContext |
private String |
principal |
private Subject |
subject |
(package private) static float |
TICKET_RENEW_WINDOW
Percentage of the ticket window to use before we renew the TGT.
|
Constructor and Description |
---|
StandardKeytabUser(String principal,
String keytabFile) |
Modifier and Type | Method and Description |
---|---|
boolean |
checkTGTAndRelogin()
Re-login a user from keytab if TGT is expired or is close to expiry.
|
<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 |
getKeytabFile() |
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
private final String principal
private final String keytabFile
private final AtomicBoolean loggedIn
private Subject subject
private LoginContext loginContext
public void login() throws LoginException
login
in interface KeytabUser
LoginException
- if the login failspublic void logout() throws LoginException
logout
in interface KeytabUser
LoginException
- if the logout failspublic <T> T doAs(PrivilegedAction<T> action) throws IllegalStateException
doAs
in interface KeytabUser
T
- 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 KeytabUser
T
- 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 KeytabUser
LoginException
- 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 KeytabUser
public String getPrincipal()
getPrincipal
in interface KeytabUser
public String getKeytabFile()
getKeytabFile
in interface KeytabUser
Subject getSubject()
Copyright © 2018 Apache NiFi Project. All rights reserved.