use of org.apache.cassandra.config.EncryptionOptions in project cassandra by apache.
the class Client method main.
public static void main(String[] args) throws Exception {
DatabaseDescriptor.clientInitialization();
// Print usage if no argument is specified.
if (args.length < 2 || args.length > 3) {
System.err.println("Usage: " + Client.class.getSimpleName() + " <host> <port> [<version>]");
return;
}
// Parse options.
String host = args[0];
int port = Integer.parseInt(args[1]);
ProtocolVersion version = args.length == 3 ? ProtocolVersion.decode(Integer.parseInt(args[2]), DatabaseDescriptor.getNativeTransportAllowOlderProtocols()) : ProtocolVersion.CURRENT;
EncryptionOptions encryptionOptions = new EncryptionOptions().applyConfig();
System.out.println("CQL binary protocol console " + host + "@" + port + " using native protocol version " + version);
new Client(host, port, version, encryptionOptions).run();
System.exit(0);
}
use of org.apache.cassandra.config.EncryptionOptions in project cassandra by apache.
the class SSLFactoryTest method testCacheKeyInequalityForCustomSslContextFactory.
@Test
public void testCacheKeyInequalityForCustomSslContextFactory() {
Map<String, String> parameters1 = new HashMap<>();
parameters1.put("key1", "value11");
parameters1.put("key2", "value12");
EncryptionOptions encryptionOptions1 = new EncryptionOptions().withSslContextFactory(new ParameterizedClass(DummySslContextFactoryImpl.class.getName(), parameters1)).withProtocol("TLSv1.1");
SSLFactory.CacheKey cacheKey1 = new SSLFactory.CacheKey(encryptionOptions1, ISslContextFactory.SocketType.SERVER);
Map<String, String> parameters2 = new HashMap<>();
parameters2.put("key1", "value21");
parameters2.put("key2", "value22");
EncryptionOptions encryptionOptions2 = new EncryptionOptions().withSslContextFactory(new ParameterizedClass(DummySslContextFactoryImpl.class.getName(), parameters2)).withProtocol("TLSv1.1");
SSLFactory.CacheKey cacheKey2 = new SSLFactory.CacheKey(encryptionOptions2, ISslContextFactory.SocketType.SERVER);
Assert.assertNotEquals(cacheKey1, cacheKey2);
}
use of org.apache.cassandra.config.EncryptionOptions in project cassandra by apache.
the class ClientWarningsTest method testTombstoneWarning.
@Test
public void testTombstoneWarning() throws Exception {
final int iterations = 10000;
createTable("CREATE TABLE %s (pk int, ck int, v int, PRIMARY KEY (pk, ck))");
try (SimpleClient client = new SimpleClient(nativeAddr.getHostAddress(), nativePort, version, true, new EncryptionOptions())) {
client.connect(false);
for (int i = 0; i < iterations; i++) {
QueryMessage query = new QueryMessage(String.format("INSERT INTO %s.%s (pk, ck, v) VALUES (1, %s, 1)", KEYSPACE, currentTable(), i), QueryOptions.DEFAULT);
client.execute(query);
}
ColumnFamilyStore store = Keyspace.open(KEYSPACE).getColumnFamilyStore(currentTable());
store.forceBlockingFlush();
for (int i = 0; i < iterations; i++) {
QueryMessage query = new QueryMessage(String.format("DELETE v FROM %s.%s WHERE pk = 1 AND ck = %s", KEYSPACE, currentTable(), i), QueryOptions.DEFAULT);
client.execute(query);
}
store.forceBlockingFlush();
{
QueryMessage query = new QueryMessage(String.format("SELECT * FROM %s.%s WHERE pk = 1", KEYSPACE, currentTable()), QueryOptions.DEFAULT);
Message.Response resp = client.execute(query);
assertEquals(1, resp.getWarnings().size());
}
}
}
use of org.apache.cassandra.config.EncryptionOptions in project cassandra by apache.
the class DefaultSslContextFactoryTest method getSslContextOpenSSL.
@Test
public void getSslContextOpenSSL() throws IOException {
EncryptionOptions options = new EncryptionOptions().withTrustStore("test/conf/cassandra_ssl_test.truststore").withTrustStorePassword("cassandra").withKeyStore("test/conf/cassandra_ssl_test.keystore").withKeyStorePassword("cassandra").withRequireClientAuth(false).withCipherSuites("TLS_RSA_WITH_AES_128_CBC_SHA");
SslContext sslContext = SSLFactory.getOrCreateSslContext(options, true, ISslContextFactory.SocketType.CLIENT);
Assert.assertNotNull(sslContext);
if (OpenSsl.isAvailable())
Assert.assertTrue(sslContext instanceof OpenSslContext);
else
Assert.assertTrue(sslContext instanceof SslContext);
}
Aggregations