fineract-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From my...@apache.org
Subject [fineract-cn-cassandra] 02/05: added authentication provider
Date Mon, 22 Jan 2018 15:10:03 GMT
This is an automated email from the ASF dual-hosted git repository.

myrle pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract-cn-cassandra.git

commit eaac3dff0f285cc44d25d8e30242a13cf7113b44
Author: mgeiss <mgeiss@mifos.org>
AuthorDate: Thu Apr 20 18:21:09 2017 +0200

    added authentication provider
---
 .../core/cassandra/core/CassandraSessionProvider.java      | 14 ++++++++++++--
 .../core/cassandra/util/CassandraConnectorConstants.java   |  3 +++
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/src/main/java/io/mifos/core/cassandra/core/CassandraSessionProvider.java b/src/main/java/io/mifos/core/cassandra/core/CassandraSessionProvider.java
index 7ce7850..5cf8d05 100644
--- a/src/main/java/io/mifos/core/cassandra/core/CassandraSessionProvider.java
+++ b/src/main/java/io/mifos/core/cassandra/core/CassandraSessionProvider.java
@@ -15,7 +15,9 @@
  */
 package io.mifos.core.cassandra.core;
 
+import com.datastax.driver.core.AuthProvider;
 import com.datastax.driver.core.Cluster;
+import com.datastax.driver.core.PlainTextAuthProvider;
 import com.datastax.driver.core.Session;
 import com.datastax.driver.core.exceptions.InvalidQueryException;
 import com.datastax.driver.mapping.Mapper;
@@ -154,8 +156,16 @@ public class CassandraSessionProvider {
   private Cluster getCluster(@Nonnull final String clusterName, @Nonnull final String contactPoints)
{
     CodecRegistry.register(new LocalDateTimeCodec());
 
-    final Cluster.Builder clusterBuilder = Cluster.builder()
-        .withClusterName(clusterName);
+    final Cluster.Builder clusterBuilder = Cluster.builder().withClusterName(clusterName);
+
+    if (this.env.containsProperty(CassandraConnectorConstants.CLUSTER_USER_PROP)) {
+      final String user = this.env.getProperty(CassandraConnectorConstants.CLUSTER_USER_PROP);
+      final String pwd = this.env.getProperty(CassandraConnectorConstants.CLUSTER_PASSWORD_PROP);
+
+      final AuthProvider authProvider = new PlainTextAuthProvider(user, pwd);
+      clusterBuilder.withAuthProvider(authProvider);
+    }
+
     ContactPointUtils.process(clusterBuilder, contactPoints);
     return clusterBuilder.build();
   }
diff --git a/src/main/java/io/mifos/core/cassandra/util/CassandraConnectorConstants.java b/src/main/java/io/mifos/core/cassandra/util/CassandraConnectorConstants.java
index 2e6cc6d..66419ff 100644
--- a/src/main/java/io/mifos/core/cassandra/util/CassandraConnectorConstants.java
+++ b/src/main/java/io/mifos/core/cassandra/util/CassandraConnectorConstants.java
@@ -22,6 +22,9 @@ public interface CassandraConnectorConstants {
   String CLUSTER_NAME_PROP = "cassandra.clusterName";
   String CLUSTER_NAME_PROP_DEFAULT = "staging_cluster";
 
+  String CLUSTER_USER_PROP = "cassandra.cluster.user";
+  String CLUSTER_PASSWORD_PROP = "cassandra.cluster.pwd";
+
   String CONTACT_POINTS_PROP = "cassandra.contactPoints";
   String CONTACT_POINTS_PROP_DEFAULT = "127.0.0.1:9042,127.0.0.2:9042,127.0.0.3:9042";
 

-- 
To stop receiving notification emails like this one, please contact
myrle@apache.org.

Mime
View raw message