Example usage for org.apache.hadoop.security.authorize ServiceAuthorizationManager getProtocolsAcls

List of usage examples for org.apache.hadoop.security.authorize ServiceAuthorizationManager getProtocolsAcls

Introduction

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

Prototype

@VisibleForTesting
    public AccessControlList getProtocolsAcls(Class<?> className) 

Source Link

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 ww  w .  ja v  a  2 s .c o m
    assertEquals("*", acl.getAclString());
    assertTrue(acl
            .isUserAllowed(UserGroupInformation.createUserForTesting("testUser", new String[] { "mygroup" })));
    sam.authorize(UserGroupInformation.getCurrentUser(), PBSClient.class, c, InetAddress.getLocalHost());
}