• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java EncryptionOptions类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.cassandra.config.EncryptionOptions的典型用法代码示例。如果您正苦于以下问题:Java EncryptionOptions类的具体用法?Java EncryptionOptions怎么用?Java EncryptionOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



EncryptionOptions类属于org.apache.cassandra.config包,在下文中一共展示了EncryptionOptions类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: createConnection

import org.apache.cassandra.config.EncryptionOptions; //导入依赖的package包/类
public Socket createConnection(InetAddress peer) throws IOException
{
    // Connect to secure port for all peers if ServerEncryptionOptions is configured other than 'none'
    // When 'all', 'dc' and 'rack', server nodes always have SSL port open, and since thin client like sstableloader
    // does not know which node is in which dc/rack, connecting to SSL port is always the option.
    if (encryptionOptions != null && encryptionOptions.internode_encryption != EncryptionOptions.ServerEncryptionOptions.InternodeEncryption.none)
    {
        if (outboundBindAny)
            return SSLFactory.getSocket(encryptionOptions, peer, secureStoragePort);
        else
            return SSLFactory.getSocket(encryptionOptions, peer, secureStoragePort, FBUtilities.getLocalAddress(), 0);
    }
    else
    {
        Socket socket = SocketChannel.open(new InetSocketAddress(peer, storagePort)).socket();
        if (outboundBindAny && !socket.isBound())
            socket.bind(new InetSocketAddress(FBUtilities.getLocalAddress(), 0));
        return socket;
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:21,代码来源:BulkLoadConnectionFactory.java


示例2: getEncryptionOptions

import org.apache.cassandra.config.EncryptionOptions; //导入依赖的package包/类
public EncryptionOptions.ClientEncryptionOptions getEncryptionOptions()
{
    EncryptionOptions.ClientEncryptionOptions encOptions = new EncryptionOptions.ClientEncryptionOptions();
    if (options.trustStore.present())
    {
        encOptions.enabled = true;
        encOptions.truststore = options.trustStore.value();
        encOptions.truststore_password = options.trustStorePw.value();
        if (options.keyStore.present())
        {
            encOptions.keystore = options.keyStore.value();
            encOptions.keystore_password = options.keyStorePw.value();
        }
        else
        {
            // mandatory for SSLFactory.createSSLContext(), see CASSANDRA-9325
            encOptions.keystore = encOptions.truststore;
        }
        encOptions.algorithm = options.alg.value();
        encOptions.protocol = options.protocol.value();
        encOptions.cipher_suites = options.ciphers.value().split(",");
    }
    return encOptions;
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:25,代码来源:SettingsTransport.java


示例3: testServerSocketCiphers

import org.apache.cassandra.config.EncryptionOptions; //导入依赖的package包/类
@Test
public void testServerSocketCiphers() throws IOException
{
    ServerEncryptionOptions options = new EncryptionOptions.ServerEncryptionOptions();
    options.keystore = "test/conf/keystore.jks";
    options.keystore_password = "cassandra";
    options.truststore = options.keystore;
    options.truststore_password = options.keystore_password;
    options.cipher_suites = new String[] {
        "TLS_RSA_WITH_AES_128_CBC_SHA", "TLS_RSA_WITH_AES_256_CBC_SHA",
        "TLS_DHE_RSA_WITH_AES_128_CBC_SHA", "TLS_DHE_RSA_WITH_AES_256_CBC_SHA",
        "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA"
    };

    // enabled ciphers must be a subset of configured ciphers with identical order
    try (SSLServerSocket socket = SSLFactory.getServerSocket(options, InetAddress.getLocalHost(), 55123))
    {
        String[] enabled = socket.getEnabledCipherSuites();
        String[] wanted = Iterables.toArray(Iterables.filter(Lists.newArrayList(options.cipher_suites),
                                                             Predicates.in(Lists.newArrayList(enabled))),
                                            String.class);
        assertArrayEquals(wanted, enabled);
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:25,代码来源:SSLFactoryTest.java


示例4: run

import org.apache.cassandra.config.EncryptionOptions; //导入依赖的package包/类
private void run()
{
    // Configure the server.
    executionHandler = new ExecutionHandler(new RequestThreadPoolExecutor());
    factory = new NioServerSocketChannelFactory(Executors.newCachedThreadPool(), Executors.newCachedThreadPool());
    ServerBootstrap bootstrap = new ServerBootstrap(factory);

    bootstrap.setOption("child.tcpNoDelay", true);

    // Set up the event pipeline factory.
    final EncryptionOptions.ClientEncryptionOptions clientEnc = DatabaseDescriptor.getClientEncryptionOptions();
    if (clientEnc.enabled)
    {
        logger.info("Enabling encrypted CQL connections between client and server");
        bootstrap.setPipelineFactory(new SecurePipelineFactory(this, clientEnc));
    }
    else
    {
        bootstrap.setPipelineFactory(new PipelineFactory(this));
    }

    // Bind and start to accept incoming connections.
    logger.info("Starting listening for CQL clients on {}...", socket);
    Channel channel = bootstrap.bind(socket);
    connectionTracker.allChannels.add(channel);
}
 
开发者ID:dprguiuc,项目名称:Cassandra-Wasef,代码行数:27,代码来源:Server.java


示例5: getJavaDriverClient

import org.apache.cassandra.config.EncryptionOptions; //导入依赖的package包/类
public JavaDriverClient getJavaDriverClient()
{
    if (client != null)
        return client;

    try
    {
        synchronized (this)
        {
            String currentNode = node.randomNode();
            if (client != null)
                return client;

            EncryptionOptions.ClientEncryptionOptions encOptions = transport.getEncryptionOptions();
            JavaDriverClient c = new JavaDriverClient(currentNode, port.nativePort, encOptions);
            c.connect(mode.compression());
            c.execute("USE \"" + schema.keyspace + "\";", org.apache.cassandra.db.ConsistencyLevel.ONE);
            return client = c;
        }
    }
    catch (Exception e)
    {
        throw new RuntimeException(e);
    }
}
 
开发者ID:rajath26,项目名称:cassandra-trunk,代码行数:26,代码来源:StressSettings.java


示例6: createSSLContext

import org.apache.cassandra.config.EncryptionOptions; //导入依赖的package包/类
private static SSLContext createSSLContext(EncryptionOptions options) throws IOException {
    SSLContext ctx;
    try {
        ctx = SSLContext.getInstance(PROTOCOL);
        TrustManagerFactory tmf = null;
        KeyManagerFactory kmf = null;

        tmf = TrustManagerFactory.getInstance(ALGORITHM);
        KeyStore ts = KeyStore.getInstance(STORE_TYPE);
        ts.load(new FileInputStream(options.truststore), options.truststore_password.toCharArray());
        tmf.init(ts);

        kmf = KeyManagerFactory.getInstance(ALGORITHM);
        KeyStore ks = KeyStore.getInstance(STORE_TYPE);
        ks.load(new FileInputStream(options.keystore), options.keystore_password.toCharArray());
        kmf.init(ks, options.keystore_password.toCharArray());

        ctx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);

    } catch (Exception e) {
        throw new IOException("Error creating the initializing the SSL Context", e);
    }
    return ctx;
}
 
开发者ID:devdattakulkarni,项目名称:Cassandra-KVPM,代码行数:25,代码来源:SSLFactory.java


示例7: getServerSocket

import org.apache.cassandra.config.EncryptionOptions; //导入依赖的package包/类
public static SSLServerSocket getServerSocket(EncryptionOptions options, InetAddress address, int port) throws IOException
{
    SSLContext ctx = createSSLContext(options, true);
    SSLServerSocket serverSocket = (SSLServerSocket)ctx.getServerSocketFactory().createServerSocket();
    serverSocket.setReuseAddress(true);
    String[] suits = filterCipherSuites(serverSocket.getSupportedCipherSuites(), options.cipher_suites);
    serverSocket.setEnabledCipherSuites(suits);
    serverSocket.setNeedClientAuth(options.require_client_auth);
    serverSocket.setEnabledProtocols(ACCEPTED_PROTOCOLS);
    serverSocket.bind(new InetSocketAddress(address, port), 500);
    return serverSocket;
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:13,代码来源:SSLFactory.java


示例8: getSocket

import org.apache.cassandra.config.EncryptionOptions; //导入依赖的package包/类
/** Create a socket and connect */
public static SSLSocket getSocket(EncryptionOptions options, InetAddress address, int port, InetAddress localAddress, int localPort) throws IOException
{
    SSLContext ctx = createSSLContext(options, true);
    SSLSocket socket = (SSLSocket) ctx.getSocketFactory().createSocket(address, port, localAddress, localPort);
    String[] suits = filterCipherSuites(socket.getSupportedCipherSuites(), options.cipher_suites);
    socket.setEnabledCipherSuites(suits);
    socket.setEnabledProtocols(ACCEPTED_PROTOCOLS);
    return socket;
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:11,代码来源:SSLFactory.java


示例9: SecureInitializer

import org.apache.cassandra.config.EncryptionOptions; //导入依赖的package包/类
public SecureInitializer(Server server, EncryptionOptions encryptionOptions)
{
    super(server);
    this.encryptionOptions = encryptionOptions;
    try
    {
        this.sslContext = SSLFactory.createSSLContext(encryptionOptions, encryptionOptions.require_client_auth);
    }
    catch (IOException e)
    {
        throw new RuntimeException("Failed to setup secure pipeline", e);
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:14,代码来源:Server.java


示例10: BulkLoadConnectionFactory

import org.apache.cassandra.config.EncryptionOptions; //导入依赖的package包/类
public BulkLoadConnectionFactory(int storagePort, int secureStoragePort, EncryptionOptions.ServerEncryptionOptions encryptionOptions, boolean outboundBindAny)
{
    this.storagePort = storagePort;
    this.secureStoragePort = secureStoragePort;
    this.encryptionOptions = encryptionOptions;
    this.outboundBindAny = outboundBindAny;
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:8,代码来源:BulkLoadConnectionFactory.java


示例11: configureTransportFactory

import org.apache.cassandra.config.EncryptionOptions; //导入依赖的package包/类
private static void configureTransportFactory(ITransportFactory transportFactory, EncryptionOptions encOptions)
{
    Map<String, String> options = new HashMap<>();
    // If the supplied factory supports the same set of options as our SSL impl, set those
    if (transportFactory.supportedOptions().contains(SSLTransportFactory.TRUSTSTORE))
        options.put(SSLTransportFactory.TRUSTSTORE, encOptions.truststore);
    if (transportFactory.supportedOptions().contains(SSLTransportFactory.TRUSTSTORE_PASSWORD))
        options.put(SSLTransportFactory.TRUSTSTORE_PASSWORD, encOptions.truststore_password);
    if (transportFactory.supportedOptions().contains(SSLTransportFactory.PROTOCOL))
        options.put(SSLTransportFactory.PROTOCOL, encOptions.protocol);
    if (transportFactory.supportedOptions().contains(SSLTransportFactory.CIPHER_SUITES))
        options.put(SSLTransportFactory.CIPHER_SUITES, Joiner.on(',').join(encOptions.cipher_suites));

    if (transportFactory.supportedOptions().contains(SSLTransportFactory.KEYSTORE)
            && encOptions.require_client_auth)
        options.put(SSLTransportFactory.KEYSTORE, encOptions.keystore);
    if (transportFactory.supportedOptions().contains(SSLTransportFactory.KEYSTORE_PASSWORD)
            && encOptions.require_client_auth)
        options.put(SSLTransportFactory.KEYSTORE_PASSWORD, encOptions.keystore_password);

    // Now check if any of the factory's supported options are set as system properties
    for (String optionKey : transportFactory.supportedOptions())
        if (System.getProperty(optionKey) != null)
            options.put(optionKey, System.getProperty(optionKey));

    transportFactory.setOptions(options);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:28,代码来源:CliOptions.java


示例12: getJavaDriverClient

import org.apache.cassandra.config.EncryptionOptions; //导入依赖的package包/类
public JavaDriverClient getJavaDriverClient(boolean setKeyspace)
{
    if (client != null)
        return client;

    try
    {
        synchronized (this)
        {
            String currentNode = node.randomNode();
            if (client != null)
                return client;

            EncryptionOptions.ClientEncryptionOptions encOptions = transport.getEncryptionOptions();
            JavaDriverClient c = new JavaDriverClient(this, currentNode, port.nativePort, encOptions);
            c.connect(mode.compression());
            if (setKeyspace)
                c.execute("USE \"" + schema.keyspace + "\";", org.apache.cassandra.db.ConsistencyLevel.ONE);

            return client = c;
        }
    }
    catch (Exception e)
    {
        throw new RuntimeException(e);
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:28,代码来源:StressSettings.java


示例13: getEncryptionOptions

import org.apache.cassandra.config.EncryptionOptions; //导入依赖的package包/类
public EncryptionOptions.ClientEncryptionOptions getEncryptionOptions()
{
    EncryptionOptions.ClientEncryptionOptions encOptions = new EncryptionOptions.ClientEncryptionOptions();
    if (options.trustStore.present())
    {
        encOptions.enabled = true;
        encOptions.truststore = options.trustStore.value();
        encOptions.truststore_password = options.trustStorePw.value();
        encOptions.algorithm = options.alg.value();
        encOptions.protocol = options.protocol.value();
        encOptions.cipher_suites = options.ciphers.value().split(",");
    }
    return encOptions;
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:15,代码来源:SettingsTransport.java


示例14: JavaDriverClient

import org.apache.cassandra.config.EncryptionOptions; //导入依赖的package包/类
public JavaDriverClient(StressSettings settings, String host, int port, EncryptionOptions.ClientEncryptionOptions encryptionOptions)
{
    this.host = host;
    this.port = port;
    this.username = settings.mode.username;
    this.password = settings.mode.password;
    this.authProvider = settings.mode.authProvider;
    this.encryptionOptions = encryptionOptions;
    if (settings.node.isWhiteList)
        whitelist = new WhiteListPolicy(new DCAwareRoundRobinPolicy(), settings.node.resolveAll(settings.port.nativePort));
    else
        whitelist = null;
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:14,代码来源:JavaDriverClient.java


示例15: getServerSocket

import org.apache.cassandra.config.EncryptionOptions; //导入依赖的package包/类
public static SSLServerSocket getServerSocket(EncryptionOptions options, InetAddress address, int port) throws IOException
{
    SSLContext ctx = createSSLContext(options, true);
    SSLServerSocket serverSocket = (SSLServerSocket)ctx.getServerSocketFactory().createServerSocket();
    serverSocket.setReuseAddress(true);
    String[] suits = filterCipherSuites(serverSocket.getSupportedCipherSuites(), options.cipher_suites);
    serverSocket.setEnabledCipherSuites(suits);
    serverSocket.setNeedClientAuth(options.require_client_auth);
    serverSocket.bind(new InetSocketAddress(address, port), 100);
    return serverSocket;
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:12,代码来源:SSLFactory.java


示例16: getSocket

import org.apache.cassandra.config.EncryptionOptions; //导入依赖的package包/类
/** Create a socket and connect */
public static SSLSocket getSocket(EncryptionOptions options, InetAddress address, int port, InetAddress localAddress, int localPort) throws IOException
{
    SSLContext ctx = createSSLContext(options, true);
    SSLSocket socket = (SSLSocket) ctx.getSocketFactory().createSocket(address, port, localAddress, localPort);
    String[] suits = filterCipherSuites(socket.getSupportedCipherSuites(), options.cipher_suites);
    socket.setEnabledCipherSuites(suits);
    return socket;
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:10,代码来源:SSLFactory.java


示例17: createSSLContext

import org.apache.cassandra.config.EncryptionOptions; //导入依赖的package包/类
public static SSLContext createSSLContext(EncryptionOptions options, boolean buildTruststore) throws IOException
{
    FileInputStream tsf = null;
    FileInputStream ksf = null;
    SSLContext ctx;
    try
    {
        ctx = SSLContext.getInstance(options.protocol);
        TrustManager[] trustManagers = null;

        if(buildTruststore)
        {
            tsf = new FileInputStream(options.truststore);
            TrustManagerFactory tmf = TrustManagerFactory.getInstance(options.algorithm);
            KeyStore ts = KeyStore.getInstance(options.store_type);
            ts.load(tsf, options.truststore_password.toCharArray());
            tmf.init(ts);
            trustManagers = tmf.getTrustManagers();
        }

        ksf = new FileInputStream(options.keystore);
        KeyManagerFactory kmf = KeyManagerFactory.getInstance(options.algorithm);
        KeyStore ks = KeyStore.getInstance(options.store_type);
        ks.load(ksf, options.keystore_password.toCharArray());
        kmf.init(ks, options.keystore_password.toCharArray());

        ctx.init(kmf.getKeyManagers(), trustManagers, null);

    }
    catch (Exception e)
    {
        throw new IOException("Error creating the initializing the SSL Context", e);
    }
    finally
    {
        FileUtils.closeQuietly(tsf);
        FileUtils.closeQuietly(ksf);
    }
    return ctx;
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:41,代码来源:SSLFactory.java


示例18: run

import org.apache.cassandra.config.EncryptionOptions; //导入依赖的package包/类
private void run()
{
    // Check that a SaslAuthenticator can be provided by the configured
    // IAuthenticator. If not, don't start the server.
    IAuthenticator authenticator = DatabaseDescriptor.getAuthenticator();
    if (authenticator.requireAuthentication() && !(authenticator instanceof ISaslAwareAuthenticator))
    {
        logger.error("Not starting native transport as the configured IAuthenticator is not capable of SASL authentication");
        isRunning.compareAndSet(true, false);
        return;
    }

    // Configure the server.
    executionHandler = new ExecutionHandler(new RequestThreadPoolExecutor());
    factory = new NioServerSocketChannelFactory(Executors.newCachedThreadPool(), Executors.newCachedThreadPool());
    ServerBootstrap bootstrap = new ServerBootstrap(factory);

    bootstrap.setOption("child.tcpNoDelay", true);

    // Set up the event pipeline factory.
    final EncryptionOptions.ClientEncryptionOptions clientEnc = DatabaseDescriptor.getClientEncryptionOptions();
    if (clientEnc.enabled)
    {
        logger.info("Enabling encrypted CQL connections between client and server");
        bootstrap.setPipelineFactory(new SecurePipelineFactory(this, clientEnc));
    }
    else
    {
        bootstrap.setPipelineFactory(new PipelineFactory(this));
    }

    // Bind and start to accept incoming connections.
    logger.info("Starting listening for CQL clients on {}...", socket);
    Channel channel = bootstrap.bind(socket);
    connectionTracker.allChannels.add(channel);
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:37,代码来源:Server.java


示例19: SecurePipelineFactory

import org.apache.cassandra.config.EncryptionOptions; //导入依赖的package包/类
public SecurePipelineFactory(Server server, EncryptionOptions encryptionOptions)
{
    super(server);
    this.encryptionOptions = encryptionOptions;
    try
    {
        this.sslContext = SSLFactory.createSSLContext(encryptionOptions, false);
    }
    catch (IOException e)
    {
        throw new RuntimeException("Failed to setup secure pipeline", e);
    }
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:14,代码来源:Server.java


示例20: getServerSocket

import org.apache.cassandra.config.EncryptionOptions; //导入依赖的package包/类
public static SSLServerSocket getServerSocket(EncryptionOptions options, InetAddress address, int port) throws IOException
{
    SSLContext ctx = createSSLContext(options, true);
    SSLServerSocket serverSocket = (SSLServerSocket)ctx.getServerSocketFactory().createServerSocket();
    serverSocket.setReuseAddress(true);
    String[] suites = filterCipherSuites(serverSocket.getSupportedCipherSuites(), options.cipher_suites);
    serverSocket.setEnabledCipherSuites(suites);
    serverSocket.setNeedClientAuth(options.require_client_auth);
    serverSocket.setEnabledProtocols(ACCEPTED_PROTOCOLS);
    serverSocket.bind(new InetSocketAddress(address, port), 500);
    return serverSocket;
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:13,代码来源:SSLFactory.java



注:本文中的org.apache.cassandra.config.EncryptionOptions类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TrackerServer类代码示例发布时间:2022-05-22
下一篇:
Java CouchDbDocument类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap