use of org.apache.cassandra.auth.IRoleManager in project cassandra by apache.
the class CQLTester method requireAuthentication.
protected static void requireAuthentication() {
DatabaseDescriptor.setAuthenticator(new AuthTestUtils.LocalPasswordAuthenticator());
DatabaseDescriptor.setAuthorizer(new AuthTestUtils.LocalCassandraAuthorizer());
DatabaseDescriptor.setNetworkAuthorizer(new AuthTestUtils.LocalCassandraNetworkAuthorizer());
// The CassandraRoleManager constructor set the supported and alterable options based on
// DatabaseDescriptor authenticator type so it needs to be created only after the authenticator is set.
IRoleManager roleManager = new AuthTestUtils.LocalCassandraRoleManager() {
public void setup() {
loadRoleStatement();
QueryProcessor.executeInternal(createDefaultRoleQuery());
}
};
DatabaseDescriptor.setRoleManager(roleManager);
MigrationManager.announceNewKeyspace(AuthKeyspace.metadata(), true);
DatabaseDescriptor.getRoleManager().setup();
DatabaseDescriptor.getAuthenticator().setup();
DatabaseDescriptor.getAuthorizer().setup();
DatabaseDescriptor.getNetworkAuthorizer().setup();
Schema.instance.registerListener(new AuthSchemaChangeListener());
AuthCacheService.initializeAndRegisterCaches();
}
use of org.apache.cassandra.auth.IRoleManager in project cassandra by apache.
the class InvalidateJmxPermissionsCacheTest method setup.
@BeforeClass
public static void setup() throws Exception {
CQLTester.setUpClass();
CQLTester.requireAuthentication();
IRoleManager roleManager = DatabaseDescriptor.getRoleManager();
roleManager.createRole(AuthenticatedUser.SYSTEM_USER, ROLE_A, AuthTestUtils.getLoginRoleOptions());
roleManager.createRole(AuthenticatedUser.SYSTEM_USER, ROLE_B, AuthTestUtils.getLoginRoleOptions());
JMXResource rootJmxResource = JMXResource.root();
Set<Permission> jmxPermissions = rootJmxResource.applicablePermissions();
IAuthorizer authorizer = DatabaseDescriptor.getAuthorizer();
authorizer.grant(AuthenticatedUser.SYSTEM_USER, jmxPermissions, rootJmxResource, ROLE_A);
authorizer.grant(AuthenticatedUser.SYSTEM_USER, jmxPermissions, rootJmxResource, ROLE_B);
AuthCacheService.initializeAndRegisterCaches();
startJMXServer();
}
use of org.apache.cassandra.auth.IRoleManager in project cassandra by apache.
the class InvalidateCredentialsCacheTest method setup.
@BeforeClass
public static void setup() throws Exception {
CQLTester.setUpClass();
CQLTester.requireAuthentication();
IRoleManager roleManager = DatabaseDescriptor.getRoleManager();
roleManager.createRole(AuthenticatedUser.SYSTEM_USER, ROLE_A, AuthTestUtils.getLoginRoleOptions());
roleManager.createRole(AuthenticatedUser.SYSTEM_USER, ROLE_B, AuthTestUtils.getLoginRoleOptions());
PasswordAuthenticator passwordAuthenticator = (PasswordAuthenticator) DatabaseDescriptor.getAuthenticator();
roleANegotiator = passwordAuthenticator.newSaslNegotiator(null);
roleANegotiator.evaluateResponse(new PlainTextAuthProvider(ROLE_A.getRoleName(), "ignored").newAuthenticator((EndPoint) null, null).initialResponse());
roleBNegotiator = passwordAuthenticator.newSaslNegotiator(null);
roleBNegotiator.evaluateResponse(new PlainTextAuthProvider(ROLE_B.getRoleName(), "ignored").newAuthenticator((EndPoint) null, null).initialResponse());
startJMXServer();
}
use of org.apache.cassandra.auth.IRoleManager in project cassandra by apache.
the class RolesCacheKeysTableTest method setUpClass.
@BeforeClass
public static void setUpClass() {
// high value is used for convenient debugging
DatabaseDescriptor.setRolesValidity(20_000);
CQLTester.setUpClass();
CQLTester.requireAuthentication();
IRoleManager roleManager = DatabaseDescriptor.getRoleManager();
roleManager.createRole(AuthenticatedUser.SYSTEM_USER, ROLE_A, AuthTestUtils.getLoginRoleOptions());
roleManager.createRole(AuthenticatedUser.SYSTEM_USER, ROLE_B, AuthTestUtils.getLoginRoleOptions());
roleManager.createRole(AuthenticatedUser.SYSTEM_USER, ROLE_C, AuthTestUtils.getLoginRoleOptions());
AuthTestUtils.grantRolesTo(roleManager, ROLE_A, ROLE_C);
AuthTestUtils.grantRolesTo(roleManager, ROLE_B, ROLE_C);
}
use of org.apache.cassandra.auth.IRoleManager in project cassandra by apache.
the class CredentialsCacheKeysTableTest method setUpClass.
@BeforeClass
public static void setUpClass() {
// high value is used for convenient debugging
DatabaseDescriptor.setCredentialsValidity(20_000);
CQLTester.setUpClass();
CQLTester.requireAuthentication();
passwordAuthenticator = (AuthTestUtils.LocalPasswordAuthenticator) DatabaseDescriptor.getAuthenticator();
IRoleManager roleManager = DatabaseDescriptor.getRoleManager();
roleManager.createRole(AuthenticatedUser.SYSTEM_USER, ROLE_A, AuthTestUtils.getLoginRoleOptions());
roleManager.createRole(AuthenticatedUser.SYSTEM_USER, ROLE_B, AuthTestUtils.getLoginRoleOptions());
}
Aggregations