geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jinmeil...@apache.org
Subject [43/50] [abbrv] incubator-geode git commit: GEODE-1571: fix precheckin failures
Date Fri, 08 Jul 2016 15:52:03 GMT
GEODE-1571: fix precheckin failures


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

Branch: refs/heads/develop
Commit: db456f64621420a69635869204739e2618ad5e6d
Parents: e4d79df
Author: Jinmei Liao <jiliao@pivotal.io>
Authored: Thu Jul 7 10:55:22 2016 -0700
Committer: Jinmei Liao <jiliao@pivotal.io>
Committed: Thu Jul 7 11:11:11 2016 -0700

----------------------------------------------------------------------
 .../cache/tier/sockets/BaseCommandQuery.java    | 34 +++++++++-----------
 .../cache/tier/sockets/CacheClientProxy.java    | 25 +++++++-------
 .../internal/cache/tier/sockets/HandShake.java  |  3 +-
 .../internal/security/GeodeSecurityUtil.java    | 11 +++++++
 .../cli/functions/DataCommandFunction.java      | 21 ++++++------
 ...tedClientContainsKeyAuthDistributedTest.java |  1 -
 ...urityNoShowValue1PostProcessorDUnitTest.java |  2 +-
 7 files changed, 53 insertions(+), 44 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/db456f64/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/BaseCommandQuery.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/BaseCommandQuery.java
b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/BaseCommandQuery.java
index 3f79873..0e32fb8 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/BaseCommandQuery.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/BaseCommandQuery.java
@@ -158,26 +158,24 @@ public abstract class BaseCommandQuery extends BaseCommand {
         SelectResults selectResults = (SelectResults)result;
 
         // post process, iterate through the result for post processing
-        List list = selectResults.asList();
-        for(Iterator<Object> valItr = list.iterator(); valItr.hasNext();){
-          Object value = valItr.next();
-          Object newValue = value;
-          if(value instanceof CqEntry){
-            CqEntry cqEntry = (CqEntry)value;
-            Object cqNewValue = GeodeSecurityUtil.postProcess(null, cqEntry.getKey(), cqEntry.getValue());
-            if(!cqEntry.getValue().equals(cqNewValue)){
-              selectResults.remove(value);
-              if(cqNewValue!=null){
+        if(GeodeSecurityUtil.needPostProcess()) {
+          List list = selectResults.asList();
+          for (Iterator<Object> valItr = list.iterator(); valItr.hasNext(); ) {
+            Object value = valItr.next();
+            if (value == null)
+              continue;
+
+            if (value instanceof CqEntry) {
+              CqEntry cqEntry = (CqEntry) value;
+              Object cqNewValue = GeodeSecurityUtil.postProcess(null, cqEntry.getKey(), cqEntry.getValue());
+              if (!cqEntry.getValue().equals(cqNewValue)) {
+                selectResults.remove(value);
                 selectResults.add(new CqEntry(cqEntry.getKey(), cqNewValue));
               }
-            }
-          }
-          else {
-            newValue = GeodeSecurityUtil.postProcess(null, null, value);
-            if(!value.equals(newValue)){
-              selectResults.remove(value);
-              // only add the newValue back if it's not null
-              if(newValue!=null){
+            } else {
+              Object newValue = GeodeSecurityUtil.postProcess(null, null, value);
+              if (!value.equals(newValue)) {
+                selectResults.remove(value);
                 selectResults.add(newValue);
               }
             }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/db456f64/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/CacheClientProxy.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/CacheClientProxy.java
b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/CacheClientProxy.java
index 1609c39..2553458 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/CacheClientProxy.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/CacheClientProxy.java
@@ -1676,20 +1676,21 @@ public class CacheClientProxy implements ClientSession {
     this._statistics.incMessagesReceived();
 
     // post process
-    Object oldValue = clientMessage.getValue();
-    if(oldValue instanceof byte[]){
-      Object newValue = GeodeSecurityUtil.postProcess(clientMessage.getRegionName(), clientMessage.getKeyOfInterest(),
-          EntryEventImpl.deserialize((byte[])oldValue));
-      try {
-        clientMessage.setLatestValue(BlobHelper.serializeToBlob(newValue));
-      } catch (IOException e) {
-        throw new GemFireIOException("Exception serializing entry value", e);
+    if(GeodeSecurityUtil.needPostProcess()) {
+      Object oldValue = clientMessage.getValue();
+      if (clientMessage.valueIsObject()) {
+        Object newValue = GeodeSecurityUtil.postProcess(clientMessage.getRegionName(), clientMessage.getKeyOfInterest(),
EntryEventImpl
+          .deserialize((byte[]) oldValue));
+        try {
+          clientMessage.setLatestValue(BlobHelper.serializeToBlob(newValue));
+        } catch (IOException e) {
+          throw new GemFireIOException("Exception serializing entry value", e);
+        }
+      } else {
+        Object newValue = GeodeSecurityUtil.postProcess(clientMessage.getRegionName(), clientMessage.getKeyOfInterest(),
oldValue);
+        clientMessage.setLatestValue(newValue);
       }
     }
-    else{
-      Object newValue = GeodeSecurityUtil.postProcess(clientMessage.getRegionName(), clientMessage.getKeyOfInterest(),
oldValue);
-      clientMessage.setLatestValue(newValue);
-    }
 
     if (clientMessage.needsNoAuthorizationCheck() || postDeliverAuthCheckPassed(clientMessage))
{
       // If dispatcher is getting initialized, add the event to temporary queue.

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/db456f64/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/HandShake.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/HandShake.java
b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/HandShake.java
index 5bceff9..cf69d0c 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/HandShake.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/HandShake.java
@@ -1157,12 +1157,11 @@ public class HandShake implements ClientHandShake
     dhSKAlgo = config.getSecurityClientDHAlgo();
     dhPrivateKey = null;
     dhPublicKey = null;
-    String authenticator = config.getSecurityClientAuthenticator();
     // Initialize the keys when either the host is a client that has
     // non-blank setting for DH symmetric algo, or this is a server
     // that has authenticator defined.
     if ((dhSKAlgo != null && dhSKAlgo.length() > 0)
-        || (authenticator != null && authenticator.length() > 0)) {
+        || GeodeSecurityUtil.isSecurityRequired(config.getSecurityProps())) {
       KeyPairGenerator keyGen = KeyPairGenerator.getInstance("DH");
       DHParameterSpec dhSpec = new DHParameterSpec(dhP, dhG, dhL);
       keyGen.initialize(dhSpec);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/db456f64/geode-core/src/main/java/com/gemstone/gemfire/internal/security/GeodeSecurityUtil.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/security/GeodeSecurityUtil.java
b/geode-core/src/main/java/com/gemstone/gemfire/internal/security/GeodeSecurityUtil.java
index ff32f92..0661602 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/security/GeodeSecurityUtil.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/security/GeodeSecurityUtil.java
@@ -348,6 +348,16 @@ public class GeodeSecurityUtil {
     return;
   }
 
+  /**
+   * postProcess call already has this logic built in, you don't need to call this everytime
you call postProcess.
+   * But if your postProcess is pretty involved with preparations and you need to bypass
it entirely, call this first.
+   * @return
+   */
+  public static boolean needPostProcess(){
+    Subject subject = getSubject();
+    return (subject != null && postProcessor != null);
+  }
+
   public static Object postProcess(String regionPath, Object key, Object result){
     if(postProcessor == null)
       return result;
@@ -361,6 +371,7 @@ public class GeodeSecurityUtil {
     return postProcessor.processRegionValue((Principal)subject.getPrincipal(), regionName,
key,  result);
   }
 
+
   public static Object getObject(String factoryName) {
     if (StringUtils.isBlank(factoryName)) {
       return null;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/db456f64/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/functions/DataCommandFunction.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/functions/DataCommandFunction.java
b/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/functions/DataCommandFunction.java
index 854643e..ed119a5 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/functions/DataCommandFunction.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/functions/DataCommandFunction.java
@@ -935,16 +935,17 @@ public class DataCommandFunction extends FunctionAdapter implements
 InternalEnt
             dataResult.setInputQuery(query);
 
             // post process, iterate through the result for post processing
-            List<SelectResultRow> rows = dataResult.getSelectResult();
-            for(Iterator<SelectResultRow> itr = rows.iterator(); itr.hasNext();){
-              SelectResultRow row = itr.next();
-              Object newValue = GeodeSecurityUtil.postProcess(null, null, row.getValue());
-              // user is not supposed to see this row
-              if(newValue==null){
-                itr.remove();
-              }
-              else{
-                row.setValue(newValue);
+            if(GeodeSecurityUtil.needPostProcess()) {
+              List<SelectResultRow> rows = dataResult.getSelectResult();
+              for (Iterator<SelectResultRow> itr = rows.iterator(); itr.hasNext();
) {
+                SelectResultRow row = itr.next();
+                Object newValue = GeodeSecurityUtil.postProcess(null, null, row.getValue());
+                // user is not supposed to see this row
+                if (newValue == null) {
+                  itr.remove();
+                } else {
+                  row.setValue(newValue);
+                }
               }
             }
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/db456f64/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientContainsKeyAuthDistributedTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientContainsKeyAuthDistributedTest.java
b/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientContainsKeyAuthDistributedTest.java
index f5bbcd4..7aa958e 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientContainsKeyAuthDistributedTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientContainsKeyAuthDistributedTest.java
@@ -44,7 +44,6 @@ public class IntegratedClientContainsKeyAuthDistributedTest extends AbstractInte
       final Region region = cache.getRegion(REGION_NAME);
       region.containsKeyOnServer("key3");
       assertTrue(region.containsKeyOnServer("key1"));
-
     });
 
     ai1.join();

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/db456f64/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedSecurityNoShowValue1PostProcessorDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedSecurityNoShowValue1PostProcessorDUnitTest.java
b/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedSecurityNoShowValue1PostProcessorDUnitTest.java
index 0599e57..d6ac3aa 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedSecurityNoShowValue1PostProcessorDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedSecurityNoShowValue1PostProcessorDUnitTest.java
@@ -66,7 +66,7 @@ public class IntegratedSecurityNoShowValue1PostProcessorDUnitTest extends
Abstra
       String query = "select * from /AuthRegion";
       SelectResults result = region.query(query);
       System.out.println("query result: "+result);
-      assertEquals(4, result.size());
+      assertEquals(5, result.size());
       assertTrue(result.contains("value0"));
       assertFalse(result.contains("value1"));
       assertTrue(result.contains("value2"));


Mime
View raw message