Search in sources :

Example 11 with EncryptionOptions

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);
}
Also used : EncryptionOptions(org.apache.cassandra.config.EncryptionOptions)

Example 12 with EncryptionOptions

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);
}
Also used : HashMap(java.util.HashMap) ParameterizedClass(org.apache.cassandra.config.ParameterizedClass) EncryptionOptions(org.apache.cassandra.config.EncryptionOptions) ServerEncryptionOptions(org.apache.cassandra.config.EncryptionOptions.ServerEncryptionOptions) Test(org.junit.Test)

Example 13 with EncryptionOptions

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());
        }
    }
}
Also used : QueryMessage(org.apache.cassandra.transport.messages.QueryMessage) ColumnFamilyStore(org.apache.cassandra.db.ColumnFamilyStore) SimpleClient(org.apache.cassandra.transport.SimpleClient) EncryptionOptions(org.apache.cassandra.config.EncryptionOptions) Test(org.junit.Test)

Example 14 with EncryptionOptions

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);
}
Also used : OpenSslContext(io.netty.handler.ssl.OpenSslContext) EncryptionOptions(org.apache.cassandra.config.EncryptionOptions) SslContext(io.netty.handler.ssl.SslContext) OpenSslContext(io.netty.handler.ssl.OpenSslContext) Test(org.junit.Test)

Aggregations

EncryptionOptions (org.apache.cassandra.config.EncryptionOptions)14 Test (org.junit.Test)10 QueryMessage (org.apache.cassandra.transport.messages.QueryMessage)5 SslContext (io.netty.handler.ssl.SslContext)4 ServerEncryptionOptions (org.apache.cassandra.config.EncryptionOptions.ServerEncryptionOptions)3 ParameterizedClass (org.apache.cassandra.config.ParameterizedClass)3 SimpleClient (org.apache.cassandra.transport.SimpleClient)3 ByteBuf (io.netty.buffer.ByteBuf)2 OpenSslContext (io.netty.handler.ssl.OpenSslContext)2 ByteBuffer (java.nio.ByteBuffer)2 HashMap (java.util.HashMap)2 Message (org.apache.cassandra.transport.Message)2 ResultMessage (org.apache.cassandra.transport.messages.ResultMessage)2 Strings (com.google.common.base.Strings)1 ServerBootstrap (io.netty.bootstrap.ServerBootstrap)1 io.netty.channel (io.netty.channel)1 EpollServerSocketChannel (io.netty.channel.epoll.EpollServerSocketChannel)1 NioServerSocketChannel (io.netty.channel.socket.nio.NioServerSocketChannel)1 ByteToMessageDecoder (io.netty.handler.codec.ByteToMessageDecoder)1 LogLevel (io.netty.handler.logging.LogLevel)1