gora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djkevi...@apache.org
Subject gora git commit: Add support for connecting to authenticated servers in aerospike module
Date Wed, 09 Aug 2017 14:52:12 GMT
Repository: gora
Updated Branches:
  refs/heads/master 170b62aea -> b26691806


Add support for connecting to authenticated servers in aerospike module


Project: http://git-wip-us.apache.org/repos/asf/gora/repo
Commit: http://git-wip-us.apache.org/repos/asf/gora/commit/b2669180
Tree: http://git-wip-us.apache.org/repos/asf/gora/tree/b2669180
Diff: http://git-wip-us.apache.org/repos/asf/gora/diff/b2669180

Branch: refs/heads/master
Commit: b26691806891840645059fa5e3a6c86f167f32cb
Parents: 170b62a
Author: nishadi <ndimeshi@gmail.com>
Authored: Mon Aug 7 21:32:49 2017 +0530
Committer: nishadi <ndimeshi@gmail.com>
Committed: Wed Aug 9 17:44:13 2017 +0530

----------------------------------------------------------------------
 .../gora/aerospike/store/AerospikeParameters.java   | 16 +++++++++++-----
 .../apache/gora/aerospike/store/AerospikeStore.java |  8 ++++++++
 gora-tutorial/conf/gora.properties                  |  6 ++++++
 3 files changed, 25 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/gora/blob/b2669180/gora-aerospike/src/main/java/org/apache/gora/aerospike/store/AerospikeParameters.java
----------------------------------------------------------------------
diff --git a/gora-aerospike/src/main/java/org/apache/gora/aerospike/store/AerospikeParameters.java
b/gora-aerospike/src/main/java/org/apache/gora/aerospike/store/AerospikeParameters.java
index 4fe61cd..e4aab26 100644
--- a/gora-aerospike/src/main/java/org/apache/gora/aerospike/store/AerospikeParameters.java
+++ b/gora-aerospike/src/main/java/org/apache/gora/aerospike/store/AerospikeParameters.java
@@ -33,7 +33,7 @@ public class AerospikeParameters {
 
   private int port;
 
-  private String user;
+  private String username;
 
   private String password;
 
@@ -46,6 +46,10 @@ public class AerospikeParameters {
 
   private static final String AS_SERVER_PORT = "gora.aerospikestore.server.port";
 
+  private static final String AS_SERVER_USERNAME = "gora.aerospikestore.server.username";
+
+  private static final String AS_SERVER_PASSWORD = "gora.aerospikestore.server.password";
+
   // Default property values
   private static final String DEFAULT_SERVER_IP = "localhost";
 
@@ -63,6 +67,8 @@ public class AerospikeParameters {
     this.aerospikeMapping = aerospikeMapping;
     this.host = properties.getProperty(AS_SERVER_IP, DEFAULT_SERVER_IP);
     this.port = Integer.parseInt(properties.getProperty(AS_SERVER_PORT, DEFAULT_SERVER_PORT));
+    this.username = properties.getProperty(AS_SERVER_USERNAME, null);
+    this.password = properties.getProperty(AS_SERVER_PASSWORD, null);
   }
 
   public String getHost() {
@@ -81,12 +87,12 @@ public class AerospikeParameters {
     this.port = port;
   }
 
-  public String getUser() {
-    return user;
+  public String getUsername() {
+    return username;
   }
 
-  public void setUser(String user) {
-    this.user = user;
+  public void setUsername(String username) {
+    this.username = username;
   }
 
   public String getPassword() {

http://git-wip-us.apache.org/repos/asf/gora/blob/b2669180/gora-aerospike/src/main/java/org/apache/gora/aerospike/store/AerospikeStore.java
----------------------------------------------------------------------
diff --git a/gora-aerospike/src/main/java/org/apache/gora/aerospike/store/AerospikeStore.java
b/gora-aerospike/src/main/java/org/apache/gora/aerospike/store/AerospikeStore.java
index 8bd8d9f..6775167 100644
--- a/gora-aerospike/src/main/java/org/apache/gora/aerospike/store/AerospikeStore.java
+++ b/gora-aerospike/src/main/java/org/apache/gora/aerospike/store/AerospikeStore.java
@@ -95,6 +95,14 @@ public class AerospikeStore<K, T extends PersistentBase> extends
DataStoreBase<K
     policy.readPolicyDefault.sendKey = true;
     policy.writePolicyDefault.sendKey = true;
 
+    // Set the credentials for servers with restricted access
+    if (aerospikeParameters.getUsername() != null) {
+      policy.user = aerospikeParameters.getUsername();
+    }
+    if (aerospikeParameters.getPassword() != null) {
+      policy.password = aerospikeParameters.getPassword();
+    }
+
     aerospikeClient = new AerospikeClient(policy, aerospikeParameters.getHost(),
             aerospikeParameters.getPort());
     aerospikeParameters.setServerSpecificParameters(aerospikeClient);

http://git-wip-us.apache.org/repos/asf/gora/blob/b2669180/gora-tutorial/conf/gora.properties
----------------------------------------------------------------------
diff --git a/gora-tutorial/conf/gora.properties b/gora-tutorial/conf/gora.properties
index 439755e..be8421e 100644
--- a/gora-tutorial/conf/gora.properties
+++ b/gora-tutorial/conf/gora.properties
@@ -60,3 +60,9 @@ gora.datastore.jcache.provider=com.hazelcast.cache.impl.HazelcastServerCachingPr
 #gora.datastore.jcache.provider=com.hazelcast.client.cache.impl.HazelcastClientCachingProvider
 #gora.datastore.jcache.hazelcast.config=hazelcast-client.xml
 gora.datastore.jcache.hazelcast.config=hazelcast.xml
+
+##Aerospike dataStore properties
+#gora.aerospikestore.server.ip=localhost
+#gora.aerospikestore.server.port=3000
+#gora.aerospikestore.server.username=
+#gora.aerospikestore.server.password=


Mime
View raw message