protected void reLogin() throws LoginException {
        if (!isKrbTicket) {
            return;
        }
        if (loginContext == null) {
            throw new LoginException("Login must be done first");
        }
        if (!hasSufficientTimeElapsed()) {
            return;
        }
        synchronized (KerberosLogin.class) {
            log.info("Initiating logout for {}", principal);
            // register most recent relogin attempt
            lastLogin = currentElapsedTime();
            //clear up the kerberos state. But the tokens are not cleared! As per
            //the Java kerberos login module code, only the kerberos credentials
            //are cleared. If previous logout succeeded but login failed, we shouldn't
            //logout again since duplicate logout causes NPE from Java 9 onwards.
            if (subject != null && !subject.getPrincipals().isEmpty()) {
                logout();
            }
            //login and also update the subject field of this instance to
            //have the new credentials (pass it to the LoginContext constructor)
            loginContext = new LoginContext(contextName(), subject, null, configuration());
            log.info("Initiating re-login for {}", principal);
            login(loginContext);
        }
    }
Re-login a principal. This method assumes that {@link #login()} has happened already.
@throws javax.security.auth.login.LoginException on a failure
clients/src/main/java/org/apache/kafka/common/security/kerberos/KerberosLogin.java