|
@@ -1232,7 +1232,26 @@ public class UserGroupInformation {
|
|
reloginFromKeytab(false);
|
|
reloginFromKeytab(false);
|
|
}
|
|
}
|
|
|
|
|
|
- private void reloginFromKeytab(boolean checkTGT) throws IOException {
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Force re-Login a user in from a keytab file. Loads a user identity from a
|
|
|
|
+ * keytab file and logs them in. They become the currently logged-in user.
|
|
|
|
+ * This method assumes that {@link #loginUserFromKeytab(String, String)} had
|
|
|
|
+ * happened already. The Subject field of this UserGroupInformation object is
|
|
|
|
+ * updated to have the new credentials.
|
|
|
|
+ *
|
|
|
|
+ * @param ignoreTimeElapsed Force re-login irrespective of the time of last
|
|
|
|
+ * login
|
|
|
|
+ * @throws IOException
|
|
|
|
+ * @throws KerberosAuthException on a failure
|
|
|
|
+ */
|
|
|
|
+ @InterfaceAudience.Public
|
|
|
|
+ @InterfaceStability.Evolving
|
|
|
|
+ public void reloginFromKeytab(boolean ignoreTimeElapsed) throws IOException {
|
|
|
|
+ reloginFromKeytab(false, ignoreTimeElapsed);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void reloginFromKeytab(boolean checkTGT, boolean ignoreTimeElapsed)
|
|
|
|
+ throws IOException {
|
|
if (!shouldRelogin() || !isFromKeytab()) {
|
|
if (!shouldRelogin() || !isFromKeytab()) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@@ -1247,7 +1266,7 @@ public class UserGroupInformation {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- relogin(login);
|
|
|
|
|
|
+ relogin(login, ignoreTimeElapsed);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -1268,25 +1287,27 @@ public class UserGroupInformation {
|
|
if (login == null) {
|
|
if (login == null) {
|
|
throw new KerberosAuthException(MUST_FIRST_LOGIN);
|
|
throw new KerberosAuthException(MUST_FIRST_LOGIN);
|
|
}
|
|
}
|
|
- relogin(login);
|
|
|
|
|
|
+ relogin(login, false);
|
|
}
|
|
}
|
|
|
|
|
|
- private void relogin(HadoopLoginContext login) throws IOException {
|
|
|
|
|
|
+ private void relogin(HadoopLoginContext login, boolean ignoreTimeElapsed)
|
|
|
|
+ throws IOException {
|
|
// ensure the relogin is atomic to avoid leaving credentials in an
|
|
// ensure the relogin is atomic to avoid leaving credentials in an
|
|
// inconsistent state. prevents other ugi instances, SASL, and SPNEGO
|
|
// inconsistent state. prevents other ugi instances, SASL, and SPNEGO
|
|
// from accessing or altering credentials during the relogin.
|
|
// from accessing or altering credentials during the relogin.
|
|
synchronized(login.getSubjectLock()) {
|
|
synchronized(login.getSubjectLock()) {
|
|
// another racing thread may have beat us to the relogin.
|
|
// another racing thread may have beat us to the relogin.
|
|
if (login == getLogin()) {
|
|
if (login == getLogin()) {
|
|
- unprotectedRelogin(login);
|
|
|
|
|
|
+ unprotectedRelogin(login, ignoreTimeElapsed);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private void unprotectedRelogin(HadoopLoginContext login) throws IOException {
|
|
|
|
|
|
+ private void unprotectedRelogin(HadoopLoginContext login,
|
|
|
|
+ boolean ignoreTimeElapsed) throws IOException {
|
|
assert Thread.holdsLock(login.getSubjectLock());
|
|
assert Thread.holdsLock(login.getSubjectLock());
|
|
long now = Time.now();
|
|
long now = Time.now();
|
|
- if (!hasSufficientTimeElapsed(now)) {
|
|
|
|
|
|
+ if (!hasSufficientTimeElapsed(now) && !ignoreTimeElapsed) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
// register most recent relogin attempt
|
|
// register most recent relogin attempt
|