Example usage for org.apache.hadoop.security.authorize AccessControlList getAclString

List of usage examples for org.apache.hadoop.security.authorize AccessControlList getAclString

Introduction

In this page you can find the example usage for org.apache.hadoop.security.authorize AccessControlList getAclString.

Prototype

public String getAclString() 

Source Link

Document

Returns the access control list as a String that can be used for building a new instance by sending it to the constructor of AccessControlList .

Usage

From source file:probos.TestStaticMethods.java

License:Open Source License

@Test
public void testPolicy() throws Exception {
    Configuration c = new Configuration();
    ServiceAuthorizationManager sam = new ServiceAuthorizationManager();
    System.setProperty("hadoop.policy.file", "probos-policy.xml");
    sam.refreshWithLoadedConfiguration(c, new ControllerPolicyProvider());
    AccessControlList acl = sam.getProtocolsAcls(PBSClient.class);
    assertNotNull(acl);/*from  w  ww.ja  v a  2s  .com*/
    assertEquals("*", acl.getAclString());
    assertTrue(acl
            .isUserAllowed(UserGroupInformation.createUserForTesting("testUser", new String[] { "mygroup" })));
    sam.authorize(UserGroupInformation.getCurrentUser(), PBSClient.class, c, InetAddress.getLocalHost());
}