本文整理汇总了Java中com.datastax.driver.core.SSLOptions类的典型用法代码示例。如果您正苦于以下问题:Java SSLOptions类的具体用法?Java SSLOptions怎么用?Java SSLOptions使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SSLOptions类属于com.datastax.driver.core包,在下文中一共展示了SSLOptions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createSSLOptions
import com.datastax.driver.core.SSLOptions; //导入依赖的package包/类
private SSLOptions createSSLOptions()
throws KeyStoreException, FileNotFoundException, IOException, NoSuchAlgorithmException,
KeyManagementException, CertificateException, UnrecoverableKeyException {
TrustManagerFactory tmf = null;
KeyStore tks = KeyStore.getInstance("JKS");
tks.load((InputStream) new FileInputStream(new File(truststorePath)),
truststorePwd.toCharArray());
tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
tmf.init(tks);
KeyManagerFactory kmf = null;
if (null != keystorePath) {
KeyStore kks = KeyStore.getInstance("JKS");
kks.load((InputStream) new FileInputStream(new File(keystorePath)),
keystorePwd.toCharArray());
kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
kmf.init(kks, keystorePwd.toCharArray());
}
SSLContext sslContext = SSLContext.getInstance("TLS");
sslContext.init(kmf != null? kmf.getKeyManagers() : null,
tmf != null ? tmf.getTrustManagers() : null,
new SecureRandom());
return JdkSSLOptions.builder().withSSLContext(sslContext).build(); //SSLOptions.DEFAULT_SSL_CIPHER_SUITES);
}
示例2: connect
import com.datastax.driver.core.SSLOptions; //导入依赖的package包/类
private void connect(String seeds) {
if (getWithSSL()) {
LOGGER.info("SSL mode enabled");
try {
SSLOptions sslOptions = new SSLOptions(SSLContext.getDefault(), CIPHERS);
builder = Cluster.builder().withSSL(sslOptions);
} catch (NoSuchAlgorithmException e) {
LOGGER.error("Unable to setup SSL Options for Cassandra");
}
}
String[] contactPoints = seeds.split(",");
for (String contactPoint : contactPoints) {
LOGGER.info("Adding Cassandra contact point " + contactPoint);
builder.addContactPoints(contactPoint);
}
cluster = builder.build();
Metadata metadata = cluster.getMetadata();
for (Host host : metadata.getAllHosts()) {
LOGGER.info("Datacenter "+ host.getDatacenter() + "Host " + host.getAddress() + "Rack " + host.getRack());
session = cluster.connect();
}
}
开发者ID:emc-cloudfoundry,项目名称:cassandra-cf-service-boshrelease,代码行数:27,代码来源:CassandraAdminService.java
示例3: createSSLOptions
import com.datastax.driver.core.SSLOptions; //导入依赖的package包/类
private SSLOptions createSSLOptions()
throws KeyStoreException, FileNotFoundException, IOException, NoSuchAlgorithmException,
KeyManagementException, CertificateException, UnrecoverableKeyException {
TrustManagerFactory tmf = null;
KeyStore tks = KeyStore.getInstance("JKS");
tks.load((InputStream) new FileInputStream(new File(truststorePath)),
truststorePwd.toCharArray());
tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
tmf.init(tks);
KeyManagerFactory kmf = null;
if (null != keystorePath) {
KeyStore kks = KeyStore.getInstance("JKS");
kks.load((InputStream) new FileInputStream(new File(keystorePath)),
keystorePwd.toCharArray());
kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
kmf.init(kks, keystorePwd.toCharArray());
}
SSLContext sslContext = SSLContext.getInstance("TLS");
sslContext.init(kmf != null? kmf.getKeyManagers() : null,
tmf != null ? tmf.getTrustManagers() : null,
new SecureRandom());
return RemoteEndpointAwareJdkSSLOptions.builder().withSSLContext(sslContext).build();
}
示例4: createSSLOptions
import com.datastax.driver.core.SSLOptions; //导入依赖的package包/类
private SSLOptions createSSLOptions()
throws KeyStoreException, FileNotFoundException, IOException, NoSuchAlgorithmException,
KeyManagementException, CertificateException, UnrecoverableKeyException {
TrustManagerFactory tmf = null;
KeyStore tks = KeyStore.getInstance("JKS");
tks.load((InputStream) new FileInputStream(new File(truststorePath)),
truststorePwd.toCharArray());
tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
tmf.init(tks);
KeyManagerFactory kmf = null;
if (null != keystorePath) {
KeyStore kks = KeyStore.getInstance("JKS");
kks.load((InputStream) new FileInputStream(new File(keystorePath)),
keystorePwd.toCharArray());
kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
kmf.init(kks, keystorePwd.toCharArray());
}
SSLContext sslContext = SSLContext.getInstance("TLS");
sslContext.init(kmf != null? kmf.getKeyManagers() : null,
tmf != null ? tmf.getTrustManagers() : null,
new SecureRandom());
return RemoteEndpointAwareJdkSSLOptions.builder().withSSLContext(sslContext).build();
}
示例5: buildSSLOptions
import com.datastax.driver.core.SSLOptions; //导入依赖的package包/类
private static SSLOptions buildSSLOptions(EncryptionOptions.ClientEncryptionOptions clientEncryptionOptions)
{
if (!clientEncryptionOptions.enabled)
return null;
SSLContext sslContext;
try
{
sslContext = SSLFactory.createSSLContext(clientEncryptionOptions, true);
}
catch (IOException e)
{
throw new RuntimeException("Could not create SSL Context.", e);
}
return JdkSSLOptions.builder()
.withSSLContext(sslContext)
.withCipherSuites(clientEncryptionOptions.cipher_suites)
.build();
}
示例6: createSession
import com.datastax.driver.core.SSLOptions; //导入依赖的package包/类
private Session createSession() {
Cluster.Builder clusterBuilder = new Cluster.Builder();
String nodes = System.getProperty("hawkular.metrics.cassandra.nodes", "hawkular-cassandra");
Arrays.stream(nodes.split(",")).forEach(clusterBuilder::addContactPoint);
if (System.getProperty("hawkular.metrics.cassandra.use-ssl") != null && !System.getProperty("hawkular.metrics.cassandra.use-ssl").equals("false")) {
SSLOptions sslOptions = null;
try {
String[] defaultCipherSuites = {"TLS_RSA_WITH_AES_128_CBC_SHA", "TLS_RSA_WITH_AES_256_CBC_SHA"};
sslOptions = JdkSSLOptions.builder().withSSLContext(SSLContext.getDefault())
.withCipherSuites(defaultCipherSuites).build();
clusterBuilder.withSSL(sslOptions);
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException("SSL support is required but is not available in the JVM.", e);
}
}
Cluster cluster = clusterBuilder.build();
cluster.init();
Session session = cluster.connect();
return session;
}
示例7: getSSLOptions
import com.datastax.driver.core.SSLOptions; //导入依赖的package包/类
private SSLOptions getSSLOptions() {
SSLContext sslContext = null;
try {
sslContext = getSSLContext(getParamString("truststore"),
getParamString("truststorepassword"),
getParamString("keystore"),
getParamString("keystorepassword"));
} catch (Exception e) {
throw new RuntimeException("Unable to build SSLContext", e);
}
List<String> cipherSuites = getParamList("dbtls_cipher_suites");
if (cipherSuites == null) {
cipherSuites = new ArrayList<>();
}
return new SSLOptions(sslContext, cipherSuites.toArray(new String[]{}));
}
示例8: newSession
import com.datastax.driver.core.SSLOptions; //导入依赖的package包/类
@Override
public CassandraSession newSession(CassandraSinkConnectorConfig config) {
Cluster.Builder clusterBuilder = Cluster.builder()
.withPort(config.port)
.addContactPoints(config.contactPoints)
.withProtocolVersion(ProtocolVersion.NEWEST_SUPPORTED);
if (config.securityEnabled) {
clusterBuilder.withCredentials(config.username, config.password);
}
if (config.sslEnabled) {
final SslContextBuilder sslContextBuilder = SslContextBuilder.forClient();
sslContextBuilder.sslProvider(config.sslProvider);
final SslContext context;
try {
context = sslContextBuilder.build();
} catch (SSLException e) {
throw new ConnectException(e);
}
final SSLOptions sslOptions = new RemoteEndpointAwareNettySSLOptions(context);
clusterBuilder.withSSL(sslOptions);
}
clusterBuilder.withCompression(config.compression);
Cluster cluster = clusterBuilder.build();
log.info("Creating session");
final Session session = cluster.newSession();
return new CassandraSessionImpl(config, cluster, session);
}
示例9: getInputCluster
import com.datastax.driver.core.SSLOptions; //导入依赖的package包/类
public static Cluster getInputCluster(String[] hosts, Configuration conf)
{
int port = getInputNativePort(conf);
Optional<AuthProvider> authProvider = getAuthProvider(conf);
Optional<SSLOptions> sslOptions = getSSLOptions(conf);
Optional<Integer> protocolVersion = getProtocolVersion(conf);
LoadBalancingPolicy loadBalancingPolicy = getReadLoadBalancingPolicy(conf, hosts);
SocketOptions socketOptions = getReadSocketOptions(conf);
QueryOptions queryOptions = getReadQueryOptions(conf);
PoolingOptions poolingOptions = getReadPoolingOptions(conf);
Cluster.Builder builder = Cluster.builder()
.addContactPoints(hosts)
.withPort(port)
.withCompression(ProtocolOptions.Compression.NONE);
if (authProvider.isPresent())
builder.withAuthProvider(authProvider.get());
if (sslOptions.isPresent())
builder.withSSL(sslOptions.get());
if (protocolVersion.isPresent()) {
builder.withProtocolVersion(protocolVersion.get());
}
builder.withLoadBalancingPolicy(loadBalancingPolicy)
.withSocketOptions(socketOptions)
.withQueryOptions(queryOptions)
.withPoolingOptions(poolingOptions);
return builder.build();
}
示例10: getSSLOptions
import com.datastax.driver.core.SSLOptions; //导入依赖的package包/类
private static Optional<SSLOptions> getSSLOptions(Configuration conf)
{
Optional<String> truststorePath = getInputNativeSSLTruststorePath(conf);
Optional<String> keystorePath = getInputNativeSSLKeystorePath(conf);
Optional<String> truststorePassword = getInputNativeSSLTruststorePassword(conf);
Optional<String> keystorePassword = getInputNativeSSLKeystorePassword(conf);
Optional<String> cipherSuites = getInputNativeSSLCipherSuites(conf);
if (truststorePath.isPresent() && keystorePath.isPresent() && truststorePassword.isPresent() && keystorePassword.isPresent())
{
SSLContext context;
try
{
context = getSSLContext(truststorePath.get(), truststorePassword.get(), keystorePath.get(), keystorePassword.get());
}
catch (UnrecoverableKeyException | KeyManagementException |
NoSuchAlgorithmException | KeyStoreException | CertificateException | IOException e)
{
throw new RuntimeException(e);
}
String[] css = SSLOptions.DEFAULT_SSL_CIPHER_SUITES;
if (cipherSuites.isPresent())
css = cipherSuites.get().split(",");
return Optional.of(new SSLOptions(context,css));
}
return Optional.absent();
}
示例11: setSslOptions
import com.datastax.driver.core.SSLOptions; //导入依赖的package包/类
/**
* Sets SSL options.
*
* @param options SSL options.
*/
@SuppressWarnings("UnusedDeclaration")
public void setSslOptions(SSLOptions options) {
sslOptions = options;
invalidate();
}
示例12: readExternal
import com.datastax.driver.core.SSLOptions; //导入依赖的package包/类
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
fetchSize = (Integer)in.readObject();
readConsistency = (ConsistencyLevel)in.readObject();
writeConsistency = (ConsistencyLevel)in.readObject();
user = U.readString(in);
pwd = U.readString(in);
port = (Integer)in.readObject();
contactPoints = (List<InetAddress>)in.readObject();
contactPointsWithPorts = (List<InetSocketAddress>)in.readObject();
maxSchemaAgreementWaitSeconds = (Integer)in.readObject();
protoVer = (Integer)in.readObject();
compression = U.readString(in);
useSSL = (Boolean)in.readObject();
collectMetrix = (Boolean)in.readObject();
jmxReporting = (Boolean)in.readObject();
creds = (Credentials)in.readObject();
loadBalancingPlc = (LoadBalancingPolicy)readObject(in);
reconnectionPlc = (ReconnectionPolicy)readObject(in);
addrTranslator = (AddressTranslator)readObject(in);
speculativeExecutionPlc = (SpeculativeExecutionPolicy)readObject(in);
authProvider = (AuthProvider)readObject(in);
sslOptions = (SSLOptions)readObject(in);
poolingOptions = (PoolingOptions)readObject(in);
sockOptions = (SocketOptions)readObject(in);
nettyOptions = (NettyOptions)readObject(in);
}
示例13: getCluster
import com.datastax.driver.core.SSLOptions; //导入依赖的package包/类
public static Cluster getCluster(String[] hosts, Configuration conf, int port)
{
Optional<AuthProvider> authProvider = getAuthProvider(conf);
Optional<SSLOptions> sslOptions = getSSLOptions(conf);
Optional<Integer> protocolVersion = getProtocolVersion(conf);
LoadBalancingPolicy loadBalancingPolicy = getReadLoadBalancingPolicy(hosts);
SocketOptions socketOptions = getReadSocketOptions(conf);
QueryOptions queryOptions = getReadQueryOptions(conf);
PoolingOptions poolingOptions = getReadPoolingOptions(conf);
Cluster.Builder builder = Cluster.builder()
.addContactPoints(hosts)
.withPort(port)
.withCompression(ProtocolOptions.Compression.NONE);
if (authProvider.isPresent())
builder.withAuthProvider(authProvider.get());
if (sslOptions.isPresent())
builder.withSSL(sslOptions.get());
if (protocolVersion.isPresent()) {
builder.withProtocolVersion(ProtocolVersion.fromInt(protocolVersion.get()));
}
builder.withLoadBalancingPolicy(loadBalancingPolicy)
.withSocketOptions(socketOptions)
.withQueryOptions(queryOptions)
.withPoolingOptions(poolingOptions);
return builder.build();
}
示例14: getSSLOptions
import com.datastax.driver.core.SSLOptions; //导入依赖的package包/类
public static Optional<SSLOptions> getSSLOptions(Configuration conf)
{
Optional<String> truststorePath = getInputNativeSSLTruststorePath(conf);
Optional<String> keystorePath = getInputNativeSSLKeystorePath(conf);
Optional<String> truststorePassword = getInputNativeSSLTruststorePassword(conf);
Optional<String> keystorePassword = getInputNativeSSLKeystorePassword(conf);
Optional<String> cipherSuites = getInputNativeSSLCipherSuites(conf);
if (truststorePath.isPresent())
{
SSLContext context;
try
{
context = getSSLContext(truststorePath, truststorePassword, keystorePath, keystorePassword);
}
catch (UnrecoverableKeyException | KeyManagementException |
NoSuchAlgorithmException | KeyStoreException | CertificateException | IOException e)
{
throw new RuntimeException(e);
}
String[] css = null;
if (cipherSuites.isPresent())
css = cipherSuites.get().split(",");
return Optional.of(JdkSSLOptions.builder()
.withSSLContext(context)
.withCipherSuites(css)
.build());
}
return Optional.absent();
}
示例15: ExternalClient
import com.datastax.driver.core.SSLOptions; //导入依赖的package包/类
public ExternalClient(Set<InetAddress> hosts,
int port,
AuthProvider authProvider,
int storagePort,
int sslStoragePort,
EncryptionOptions.ServerEncryptionOptions serverEncryptionOptions,
SSLOptions sslOptions)
{
super(hosts, port, authProvider, sslOptions);
this.storagePort = storagePort;
this.sslStoragePort = sslStoragePort;
this.serverEncOptions = serverEncryptionOptions;
}