# Class Login

java.lang.Object
org.apache.zookeeper.Login

public class Login extends Object

## Field Summary

Fields
Modifier and Type
Field
Description
`static final String`
`MIN_TIME_BEFORE_RELOGIN_CONFIG_KEY`
`static final String`
`SYSTEM_USER`

## Constructor Summary

Constructors
Constructor
Description
`Login(String loginContextName, Supplier<CallbackHandler> callbackHandlerSupplier, ZKConfig zkConfig)`
LoginThread constructor.

## Method Summary

Modifier and Type
Method
Description
`long`
`getLastLogin()`
Get the time of the last login (ticket initialization or last ticket renewal).
`String`
`getLoginContextName()`
`Subject`
`getSubject()`
`String`
`getUserName()`
`protected void`
`logout()`
`CallbackHandler`
`newCallbackHandler()`
Return a new CallbackHandler for connections to avoid race conditions and state sharing in connection login processing.
`void`
`shutdown()`
`protected void`
`sleepBeforeRetryFailedRefresh()`
`void`
`startThreadIfNeeded()`

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### SYSTEM_USER

public static final String SYSTEM_USER

### MIN_TIME_BEFORE_RELOGIN_CONFIG_KEY

public static final String MIN_TIME_BEFORE_RELOGIN_CONFIG_KEY

See Also:
  - Constant Field Values

## Constructor Details

### Login

public Login(String loginContextName, Supplier<CallbackHandler> callbackHandlerSupplier, ZKConfig zkConfig) throws LoginException
LoginThread constructor. The constructor starts the thread used to periodically re-login to the Kerberos Ticket Granting Server.

Parameters:
  `loginContextName` - name of section in JAAS file that will be use to login. Passed as first param to javax.security.auth.login.LoginContext().
  `callbackHandlerSupplier` - Per connection callbackhandler supplier.
  `zkConfig` - client or server configurations
Throws:
  `LoginException` - Thrown if authentication fails.

## Method Details

### newCallbackHandler

public CallbackHandler newCallbackHandler()
Return a new CallbackHandler for connections to avoid race conditions and state sharing in connection login processing.

Returns:
  connection dependent CallbackHandler

### startThreadIfNeeded

public void startThreadIfNeeded()

### shutdown

public void shutdown()

### getSubject

public Subject getSubject()

### getUserName

public String getUserName()

### getLoginContextName

public String getLoginContextName()

### getLastLogin

public long getLastLogin()
Get the time of the last login (ticket initialization or last ticket renewal).

Returns:
  the number of milliseconds since epoch.

### logout

protected void logout() throws LoginException

Throws:
  `LoginException`

### sleepBeforeRetryFailedRefresh

protected void sleepBeforeRetryFailedRefresh() throws InterruptedException

Throws:
  `InterruptedException`