use of alluxio.security.CurrentUser in project alluxio by Alluxio.
the class AbstractFileSystem method getHadoopSubject.
/**
* @return hadoop UGI's subject, or a fresh subject if the Hadoop UGI does not exist
* @throws IOException if there is an exception when accessing the subject in Hadoop UGI
*/
private Subject getHadoopSubject() throws IOException {
Subject subject = null;
UserGroupInformation ugi = null;
try {
ugi = UserGroupInformation.getCurrentUser();
subject = getSubjectFromUGI(ugi);
} catch (Exception e) {
throw new IOException(String.format("Failed to get Hadoop subject for the Alluxio client. ugi: %s", ugi), e);
}
if (subject == null) {
LOG.warn("Hadoop subject does not exist. Creating a fresh subject for Alluxio client");
subject = new Subject(false, new HashSet<>(), new HashSet<>(), new HashSet<>());
}
if (subject.getPrincipals(CurrentUser.class).isEmpty() && ugi != null) {
subject.getPrincipals().add(new CurrentUser(ugi.getShortUserName(), mUri.toString()));
}
return subject;
}
use of alluxio.security.CurrentUser in project alluxio by Alluxio.
the class ImpersonationIntegrationTest method createHdfsSubject.
private Subject createHdfsSubject() {
// Create a subject for an hdfs user
CurrentUser user = new CurrentUser(HDFS_USER);
Set<Principal> principals = new HashSet<>();
principals.add(user);
return new Subject(false, principals, new HashSet<>(), new HashSet<>());
}
Aggregations