Java Code Examples for

The following are Jave code examples for showing how to use getUGIFromSubject() of the class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: hadoop   File:   Source Code and License Vote up 6 votes
private <T> T doAs(String user, final PrivilegedExceptionAction<T> action)
    throws Exception {
  Set<Principal> principals = new HashSet<Principal>();
  principals.add(new KerberosPrincipal(user));

  //client login
  Subject subject = new Subject(false, principals,
      new HashSet<Object>(), new HashSet<Object>());
  LoginContext loginContext = new LoginContext("", subject, null,
      KerberosConfiguration.createClientConfig(user, keytab));
  try {
    subject = loginContext.getSubject();
    UserGroupInformation ugi =
    return ugi.doAs(action);
  } finally {