use of org.apache.accumulo.server.security.UserImpersonation.UsersWithHosts in project accumulo by apache.
the class UserImpersonationTest method testSingleUser.
@SuppressWarnings("deprecation")
@Test
public void testSingleUser() throws Exception {
final String server = "server/hostname@EXAMPLE.COM", client = "client@EXAMPLE.COM";
cc.set(Property.INSTANCE_RPC_SASL_PROXYUSERS.getKey() + server + ".users", client);
cc.set(Property.INSTANCE_RPC_SASL_PROXYUSERS.getKey() + server + ".hosts", "*");
UserImpersonation impersonation = new UserImpersonation(conf);
UsersWithHosts uwh = impersonation.get(server);
assertNotNull(uwh);
assertTrue(uwh.acceptsAllHosts());
assertFalse(uwh.acceptsAllUsers());
assertTrue(uwh.getUsers().contains(client));
}
use of org.apache.accumulo.server.security.UserImpersonation.UsersWithHosts in project accumulo by apache.
the class UserImpersonationTest method testMultipleExplicitHostsNewConfig.
@Test
public void testMultipleExplicitHostsNewConfig() {
String server = "server", host1 = "host1", host2 = "host2", host3 = "host3";
setValidHostsNewConfig(server, Joiner.on(',').join(host1, host2, host3));
setValidUsersNewConfig(ImmutableMap.of(server, "*"));
UserImpersonation impersonation = new UserImpersonation(conf);
UsersWithHosts uwh = impersonation.get(server);
assertNotNull(uwh);
assertFalse(uwh.acceptsAllHosts());
assertTrue(uwh.acceptsAllUsers());
assertNotEquals(AlwaysTrueSet.class, uwh.getHosts().getClass());
assertEquals(AlwaysTrueSet.class, uwh.getUsers().getClass());
assertTrue(uwh.getHosts().contains(host1));
assertTrue(uwh.getHosts().contains(host2));
assertTrue(uwh.getHosts().contains(host3));
assertFalse(uwh.getHosts().contains("other_host"));
}
use of org.apache.accumulo.server.security.UserImpersonation.UsersWithHosts in project accumulo by apache.
the class UserImpersonationTest method testMultipleExplicitHosts.
@Test
public void testMultipleExplicitHosts() {
String server = "server", host1 = "host1", host2 = "host2", host3 = "host3";
setValidHosts(server, Joiner.on(',').join(host1, host2, host3));
setValidUsers(server, "*");
UserImpersonation impersonation = new UserImpersonation(conf);
UsersWithHosts uwh = impersonation.get(server);
assertNotNull(uwh);
assertFalse(uwh.acceptsAllHosts());
assertTrue(uwh.acceptsAllUsers());
assertNotEquals(AlwaysTrueSet.class, uwh.getHosts().getClass());
assertEquals(AlwaysTrueSet.class, uwh.getUsers().getClass());
assertTrue(uwh.getHosts().contains(host1));
assertTrue(uwh.getHosts().contains(host2));
assertTrue(uwh.getHosts().contains(host3));
assertFalse(uwh.getHosts().contains("other_host"));
}
use of org.apache.accumulo.server.security.UserImpersonation.UsersWithHosts in project accumulo by apache.
the class UserImpersonationTest method testNoHostByDefault.
@Test
public void testNoHostByDefault() {
String server = "server";
setValidUsers(server, "*");
UserImpersonation impersonation = new UserImpersonation(conf);
UsersWithHosts uwh = impersonation.get(server);
assertNotNull(uwh);
assertFalse(uwh.acceptsAllHosts());
assertTrue(uwh.acceptsAllUsers());
assertNotEquals(AlwaysTrueSet.class, uwh.getHosts().getClass());
assertEquals(AlwaysTrueSet.class, uwh.getUsers().getClass());
}
use of org.apache.accumulo.server.security.UserImpersonation.UsersWithHosts in project accumulo by apache.
the class UserImpersonationTest method testMultipleAllowedImpersonatorsNewConfig.
@Test
public void testMultipleAllowedImpersonatorsNewConfig() {
String server1 = "server1", server2 = "server2", host1 = "host1", host2 = "host2", host3 = "host3", client1 = "client1", client2 = "client2", client3 = "client3";
// server1 can impersonate client1 and client2 from host1 or host2
// server2 can impersonate only client3 from host3
setValidHostsNewConfig(server1, Joiner.on(',').join(host1, host2), host3);
setValidUsersNewConfig(ImmutableMap.of(server1, Joiner.on(',').join(client1, client2), server2, client3));
UserImpersonation impersonation = new UserImpersonation(conf);
UsersWithHosts uwh = impersonation.get(server1);
assertNotNull(uwh);
assertFalse(uwh.acceptsAllHosts());
assertFalse(uwh.acceptsAllUsers());
assertNotEquals(AlwaysTrueSet.class, uwh.getHosts().getClass());
assertNotEquals(AlwaysTrueSet.class, uwh.getUsers().getClass());
assertTrue(uwh.getUsers().contains(client1));
assertTrue(uwh.getUsers().contains(client2));
assertFalse(uwh.getUsers().contains(client3));
assertFalse(uwh.getUsers().contains("other_client"));
assertTrue(uwh.getHosts().contains(host1));
assertTrue(uwh.getHosts().contains(host2));
assertFalse(uwh.getHosts().contains(host3));
assertFalse(uwh.getHosts().contains("other_host"));
uwh = impersonation.get(server2);
assertNotNull(uwh);
assertFalse(uwh.acceptsAllHosts());
assertFalse(uwh.acceptsAllUsers());
assertNotEquals(AlwaysTrueSet.class, uwh.getHosts().getClass());
assertNotEquals(AlwaysTrueSet.class, uwh.getUsers().getClass());
assertFalse(uwh.getUsers().contains(client1));
assertFalse(uwh.getUsers().contains(client2));
assertTrue(uwh.getUsers().contains(client3));
assertFalse(uwh.getUsers().contains("other_client"));
assertFalse(uwh.getHosts().contains(host1));
assertFalse(uwh.getHosts().contains(host2));
assertTrue(uwh.getHosts().contains(host3));
assertFalse(uwh.getHosts().contains("other_host"));
// client3 is not allowed to impersonate anyone
assertNull(impersonation.get(client3));
}
Aggregations