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

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

Introduction

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

Prototype

@Private
    public void refreshWithLoadedConfiguration(Configuration conf, PolicyProvider provider) 

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