use of org.apache.hadoop.security.authorize.AuthorizationException in project hadoop by apache.
the class NameNodeRpcServer method refreshServiceAcl.
// RefreshAuthorizationPolicyProtocol
@Override
public void refreshServiceAcl() throws IOException {
checkNNStartup();
if (!serviceAuthEnabled) {
throw new AuthorizationException("Service Level Authorization not enabled!");
}
this.clientRpcServer.refreshServiceAcl(new Configuration(), new HDFSPolicyProvider());
if (this.serviceRpcServer != null) {
this.serviceRpcServer.refreshServiceAcl(new Configuration(), new HDFSPolicyProvider());
}
}
use of org.apache.hadoop.security.authorize.AuthorizationException in project ranger by apache.
the class RangerKmsAuthorizerTest method testGenerateEEK.
@Test
public void testGenerateEEK() throws Throwable {
if (!UNRESTRICTED_POLICIES_INSTALLED) {
return;
}
// bob should have permission to generate EEK
final UserGroupInformation ugi = UserGroupInformation.createRemoteUser("bob");
ugi.doAs(new PrivilegedExceptionAction<Void>() {
public Void run() throws Exception {
KMSWebApp.getACLs().assertAccess(Type.GENERATE_EEK, ugi, KMSOp.GENERATE_EEK, "newkey1", "127.0.0.1");
return null;
}
});
// "eve" should not have permission to generate EEK
final UserGroupInformation ugi2 = UserGroupInformation.createRemoteUser("eve");
ugi2.doAs(new PrivilegedExceptionAction<Void>() {
public Void run() throws Exception {
try {
KMSWebApp.getACLs().assertAccess(Type.GENERATE_EEK, ugi2, KMSOp.GENERATE_EEK, "newkey1", "127.0.0.1");
Assert.fail("Failure expected");
} catch (AuthorizationException ex) {
LOG.error(ex);
}
return null;
}
});
// the IT group should not have permission to generate EEK
final UserGroupInformation ugi3 = UserGroupInformation.createUserForTesting("alice", new String[] { "IT" });
ugi3.doAs(new PrivilegedExceptionAction<Void>() {
public Void run() throws Exception {
try {
KMSWebApp.getACLs().assertAccess(Type.GENERATE_EEK, ugi3, KMSOp.GENERATE_EEK, "newkey1", "127.0.0.1");
Assert.fail("Failure expected");
} catch (AuthorizationException ex) {
LOG.error(ex);
}
return null;
}
});
}
use of org.apache.hadoop.security.authorize.AuthorizationException in project ranger by apache.
the class RangerKmsAuthorizerTest method testGetMetadata.
@Test
public void testGetMetadata() throws Throwable {
if (!UNRESTRICTED_POLICIES_INSTALLED) {
return;
}
// bob should have permission to get the metadata
final UserGroupInformation ugi = UserGroupInformation.createRemoteUser("bob");
ugi.doAs(new PrivilegedExceptionAction<Void>() {
public Void run() throws Exception {
KMSWebApp.getACLs().assertAccess(Type.GET_METADATA, ugi, KMSOp.GET_METADATA, "newkey1", "127.0.0.1");
return null;
}
});
// "eve" should not have permission to get the metadata
final UserGroupInformation ugi2 = UserGroupInformation.createRemoteUser("eve");
ugi2.doAs(new PrivilegedExceptionAction<Void>() {
public Void run() throws Exception {
try {
KMSWebApp.getACLs().assertAccess(Type.GET_METADATA, ugi2, KMSOp.GET_METADATA, "newkey1", "127.0.0.1");
Assert.fail("Failure expected");
} catch (AuthorizationException ex) {
LOG.error(ex);
}
return null;
}
});
// the IT group should have permission to get the metadata
final UserGroupInformation ugi3 = UserGroupInformation.createUserForTesting("alice", new String[] { "IT" });
ugi3.doAs(new PrivilegedExceptionAction<Void>() {
public Void run() throws Exception {
KMSWebApp.getACLs().assertAccess(Type.GET_METADATA, ugi3, KMSOp.GET_METADATA, "newkey1", "127.0.0.1");
return null;
}
});
}
use of org.apache.hadoop.security.authorize.AuthorizationException in project ranger by apache.
the class RangerKmsAuthorizerTest method testRollover.
@Test
public void testRollover() throws Throwable {
if (!UNRESTRICTED_POLICIES_INSTALLED) {
return;
}
// bob should have permission to rollover
final UserGroupInformation ugi = UserGroupInformation.createRemoteUser("bob");
ugi.doAs(new PrivilegedExceptionAction<Void>() {
public Void run() throws Exception {
KMSWebApp.getACLs().assertAccess(Type.ROLLOVER, ugi, KMSOp.ROLL_NEW_VERSION, "newkey1", "127.0.0.1");
return null;
}
});
// "eve" should not have permission to rollover
final UserGroupInformation ugi2 = UserGroupInformation.createRemoteUser("eve");
ugi2.doAs(new PrivilegedExceptionAction<Void>() {
public Void run() throws Exception {
try {
KMSWebApp.getACLs().assertAccess(Type.ROLLOVER, ugi2, KMSOp.ROLL_NEW_VERSION, "newkey1", "127.0.0.1");
Assert.fail("Failure expected");
} catch (AuthorizationException ex) {
LOG.error(ex);
}
return null;
}
});
// the IT group should not have permission to rollover
final UserGroupInformation ugi3 = UserGroupInformation.createUserForTesting("alice", new String[] { "IT" });
ugi3.doAs(new PrivilegedExceptionAction<Void>() {
public Void run() throws Exception {
try {
KMSWebApp.getACLs().assertAccess(Type.ROLLOVER, ugi3, KMSOp.ROLL_NEW_VERSION, "newkey1", "127.0.0.1");
Assert.fail("Failure expected");
} catch (AuthorizationException ex) {
LOG.error(ex);
}
return null;
}
});
}
use of org.apache.hadoop.security.authorize.AuthorizationException in project ranger by apache.
the class RangerKmsAuthorizerTest method testGetKeys.
@Test
public void testGetKeys() throws Throwable {
if (!UNRESTRICTED_POLICIES_INSTALLED) {
return;
}
// bob should have permission to get keys
final UserGroupInformation ugi = UserGroupInformation.createRemoteUser("bob");
ugi.doAs(new PrivilegedExceptionAction<Void>() {
public Void run() throws Exception {
KMSWebApp.getACLs().assertAccess(Type.GET_KEYS, ugi, KMSOp.GET_KEYS, "newkey1", "127.0.0.1");
return null;
}
});
// "eve" should not have permission to get keys
final UserGroupInformation ugi2 = UserGroupInformation.createRemoteUser("eve");
ugi2.doAs(new PrivilegedExceptionAction<Void>() {
public Void run() throws Exception {
try {
KMSWebApp.getACLs().assertAccess(Type.GET_KEYS, ugi2, KMSOp.GET_KEYS, "newkey1", "127.0.0.1");
Assert.fail("Failure expected");
} catch (AuthorizationException ex) {
LOG.error(ex);
}
return null;
}
});
// the IT group should have permission to get keys
final UserGroupInformation ugi3 = UserGroupInformation.createUserForTesting("alice", new String[] { "IT" });
ugi3.doAs(new PrivilegedExceptionAction<Void>() {
public Void run() throws Exception {
KMSWebApp.getACLs().assertAccess(Type.GET_KEYS, ugi3, KMSOp.GET_KEYS, "newkey1", "127.0.0.1");
return null;
}
});
}
Aggregations