use of com.datastax.driver.core.PlainTextAuthProvider in project cassandra by apache.
the class CqlConfigHelper method getDefaultAuthProvider.
private static Optional<AuthProvider> getDefaultAuthProvider(Configuration conf) {
Optional<String> username = getStringSetting(USERNAME, conf);
Optional<String> password = getStringSetting(PASSWORD, conf);
if (username.isPresent() && password.isPresent()) {
return Optional.of(new PlainTextAuthProvider(username.get(), password.get()));
} else {
return Optional.absent();
}
}
use of com.datastax.driver.core.PlainTextAuthProvider in project cassandra by apache.
the class PasswordAuthenticatorTest method testDecodeIllegalUserAndPwd.
private void testDecodeIllegalUserAndPwd(String username, String password) {
SaslNegotiator negotiator = authenticator.newSaslNegotiator(null);
Authenticator clientAuthenticator = (new PlainTextAuthProvider(username, password)).newAuthenticator((EndPoint) null, null);
negotiator.evaluateResponse(clientAuthenticator.initialResponse());
negotiator.getAuthenticatedUser();
}
use of com.datastax.driver.core.PlainTextAuthProvider 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 com.datastax.driver.core.PlainTextAuthProvider in project beam by apache.
the class CassandraIO method getCluster.
/**
* Get a Cassandra cluster using hosts and port.
*/
static Cluster getCluster(ValueProvider<List<String>> hosts, ValueProvider<Integer> port, ValueProvider<String> username, ValueProvider<String> password, ValueProvider<String> localDc, ValueProvider<String> consistencyLevel, ValueProvider<Integer> connectTimeout, ValueProvider<Integer> readTimeout) {
Cluster.Builder builder = Cluster.builder().addContactPoints(hosts.get().toArray(new String[0])).withPort(port.get());
if (username != null) {
builder.withAuthProvider(new PlainTextAuthProvider(username.get(), password.get()));
}
DCAwareRoundRobinPolicy.Builder dcAwarePolicyBuilder = new DCAwareRoundRobinPolicy.Builder();
if (localDc != null) {
dcAwarePolicyBuilder.withLocalDc(localDc.get());
}
builder.withLoadBalancingPolicy(new TokenAwarePolicy(dcAwarePolicyBuilder.build()));
if (consistencyLevel != null) {
builder.withQueryOptions(new QueryOptions().setConsistencyLevel(ConsistencyLevel.valueOf(consistencyLevel.get())));
}
SocketOptions socketOptions = new SocketOptions();
builder.withSocketOptions(socketOptions);
if (connectTimeout != null) {
socketOptions.setConnectTimeoutMillis(connectTimeout.get());
}
if (readTimeout != null) {
socketOptions.setReadTimeoutMillis(readTimeout.get());
}
return builder.build();
}
use of com.datastax.driver.core.PlainTextAuthProvider in project cassandra by apache.
the class CredentialsCacheKeysTableTest method cachePermissions.
private void cachePermissions(RoleResource roleResource) {
IAuthenticator.SaslNegotiator saslNegotiator = passwordAuthenticator.newSaslNegotiator(null);
saslNegotiator.evaluateResponse(new PlainTextAuthProvider(roleResource.getRoleName(), "ignored").newAuthenticator((EndPoint) null, null).initialResponse());
saslNegotiator.getAuthenticatedUser();
}
Aggregations