Package org.apache.hadoop.security

Examples of org.apache.hadoop.security.UserGroupInformation


   * talking to a server at the named address. */
  public static VersionedProtocol getProxy(
      Class<? extends VersionedProtocol> protocol,
      long clientVersion, InetSocketAddress addr, Configuration conf,
      SocketFactory factory) throws IOException {
    UserGroupInformation ugi = UserGroupInformation.getCurrentUser();
    return getProxy(protocol, clientVersion, addr, ugi, conf, factory);
  }
View Full Code Here


  private Set<Path> deleteOnExit = new TreeSet<Path>();

  public static FileSystem get(final URI uri, final Configuration conf,
      final String user)
  throws IOException, InterruptedException {
    UserGroupInformation ugi;
    if (user == null) {
      ugi = UserGroupInformation.getCurrentUser();
    } else {
      ugi = UserGroupInformation.createRemoteUser(user);
    }
    return ugi.doAs(new PrivilegedExceptionAction<FileSystem>() {
      public FileSystem run() throws IOException {
        return get(uri, conf);
      }
    });
  }
View Full Code Here

    if (remoteUser == null) {
      return true;
    }
    AccessControlList adminsAcl = (AccessControlList) servletContext
        .getAttribute(ADMINS_ACL);
    UserGroupInformation remoteUserUGI =
        UserGroupInformation.createRemoteUser(remoteUser);
    if (adminsAcl != null) {
      if (!adminsAcl.isUserAllowed(remoteUserUGI)) {
        response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "User "
            + remoteUser + " is unauthorized to access this page. "
View Full Code Here

public class TestQueueManagerForJobKillAndJobPriority extends TestQueueManager {

  public void testOwnerAllowedForJobKill()
  throws IOException, InterruptedException {
    try {
      final UserGroupInformation ugi = createNecessaryUsers();
   
      ugi.doAs(new PrivilegedExceptionAction<Object>() {

                 @Override
                   public Object run() throws Exception {

                   JobConf conf
View Full Code Here

  }
 
  public void testUserDisabledACLForJobKill()
  throws IOException, InterruptedException {
    try {
      UserGroupInformation ugi = createNecessaryUsers();
      // create other user who will try to kill the job of ugi.
      final UserGroupInformation otherUGI = UserGroupInformation.
        createUserForTesting("user1", new String [] {"group1"});

      ugi.doAs(new PrivilegedExceptionAction<Object>() {

                 @Override
View Full Code Here

  }
 
  public void testUserEnabledACLForJobKill()
  throws IOException, LoginException, InterruptedException {
    try {
      UserGroupInformation ugi = createNecessaryUsers();
      // create other user who will try to kill the job of ugi.
      final UserGroupInformation otherUGI = UserGroupInformation.
        createUserForTesting("user1", new String [] {"group1"});

      ugi.doAs(new PrivilegedExceptionAction<Object>() {
                 @Override
                   public Object run() throws Exception {
                   UserGroupInformation ugi = UserGroupInformation.getCurrentUser();
                   JobConf conf
                     = setupConf(QueueManager.toFullPropertyName
                                 ("default", adminAcl), "user1");
                   // user1 should be able to kill the job
                   verifyJobKill(otherUGI, conf, true);
View Full Code Here

  }

  public void testUserDisabledForJobPriorityChange()
  throws IOException, InterruptedException {
    try {
      UserGroupInformation ugi = createNecessaryUsers();
      // create other user who will try to change priority of the job of ugi.
      final UserGroupInformation otherUGI = UserGroupInformation.
        createUserForTesting("user1", new String [] {"group1"});

      ugi.doAs(new PrivilegedExceptionAction<Object>() {

                 @Override
View Full Code Here

        UtilsForTests.setUpConfigFile(queueConfProps, queueConfigFile);
     
        //Create a new configuration to be used with QueueManager
        JobConf conf = new JobConf();
        QueueManager queueManager = new QueueManager(conf);
        UserGroupInformation ugi = UserGroupInformation.
          createUserForTesting("user1", new String [] {"group1"});

        //Job Submission should fail because ugi to be used is set to blank.
        assertFalse("User Job Submission Succeeded before refresh.",
                    queueManager.hasAccess("default", QueueACL.SUBMIT_JOB, ugi));
        assertFalse("User Job Submission Succeeded before refresh.",
                    queueManager.hasAccess("q1", QueueACL.SUBMIT_JOB, ugi));
        assertFalse("User Job Submission Succeeded before refresh.",
                    queueManager.hasAccess("q2", QueueACL.SUBMIT_JOB, ugi));
     
        //Test job submission as alternate user.
        UserGroupInformation alternateUgi =
          UserGroupInformation.createUserForTesting("u1", new String[]{"user"});
        assertTrue("Alternate User Job Submission failed before refresh.",
                   queueManager.hasAccess("q2", QueueACL.SUBMIT_JOB, alternateUgi));
     
        //Set acl for user1.
View Full Code Here

        hadoopConfProps.put(JobConf.MR_ACLS_ENABLED, "true");
        UtilsForTests.setUpConfigFile(hadoopConfProps, hadoopConfigFile);
     
        //properties for mapred-queue-acls.xml
        Properties queueConfProps = new Properties();
        UserGroupInformation ugi = UserGroupInformation.getCurrentUser();
        queueConfProps.put(QueueManager.toFullPropertyName
                           ("default", submitAcl), ugi.getShortUserName());
        queueConfProps.put(QueueManager.toFullPropertyName
                           ("q1", submitAcl), ugi.getShortUserName());
        queueConfProps.put(QueueManager.toFullPropertyName
                           ("q2", submitAcl), ugi.getShortUserName());
        UtilsForTests.setUpConfigFile(queueConfProps, queueConfigFile);
     
        Configuration conf = new JobConf();
        QueueManager queueManager = new QueueManager(conf);
        //Testing access to queue.
View Full Code Here

  public void testGroupsEnabledACLForJobSubmission()
  throws IOException, LoginException, InterruptedException {
    try {
      // login as self, get one group, and add in allowed list.
      UserGroupInformation ugi = createNecessaryUsers();

      String[] groups = ugi.getGroupNames();
      JobConf conf
        = setupConf(QueueManager.toFullPropertyName
                    ("default", submitAcl), "3698-junk-user1,3698-junk-user2 "
                    + groups[groups.length-1]
                    + ",3698-junk-group");
      verifyJobSubmissionToDefaultQueue
        (conf, true, ugi.getShortUserName()+","+groups[groups.length-1]);
    } finally {
      tearDownCluster();
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.security.UserGroupInformation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.