You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2018/02/05 21:31:48 UTC

[GitHub] merlimat closed pull request #1177: Update logCtx passed to MessageCrypto, removed unused variable

merlimat closed pull request #1177: Update logCtx passed to MessageCrypto, removed unused variable
URL: https://github.com/apache/incubator-pulsar/pull/1177
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/pulsar-client-cpp/lib/MessageCrypto.cc b/pulsar-client-cpp/lib/MessageCrypto.cc
index 5e3bd3cbc..26f1b484e 100644
--- a/pulsar-client-cpp/lib/MessageCrypto.cc
+++ b/pulsar-client-cpp/lib/MessageCrypto.cc
@@ -193,7 +193,6 @@ bool MessageCrypto::encrypt(std::set<std::string>& encKeys, const CryptoKeyReade
     if (!encKeys.size()) {
         return false;
     }
-    SharedBuffer emptyBuffer;
 
     Lock lock(mutex_);
 
diff --git a/pulsar-client/src/main/java/org/apache/pulsar/client/api/ProducerConfiguration.java b/pulsar-client/src/main/java/org/apache/pulsar/client/api/ProducerConfiguration.java
index 678e3d56d..9bde4c80e 100644
--- a/pulsar-client/src/main/java/org/apache/pulsar/client/api/ProducerConfiguration.java
+++ b/pulsar-client/src/main/java/org/apache/pulsar/client/api/ProducerConfiguration.java
@@ -344,7 +344,7 @@ public ProducerConfiguration setCryptoKeyReader(CryptoKeyReader cryptoKeyReader)
      *
      */
     public boolean isEncryptionEnabled() {
-        return (this.encryptionKeys != null) && !this.encryptionKeys.isEmpty();
+        return (this.encryptionKeys != null) && !this.encryptionKeys.isEmpty() && (this.cryptoKeyReader != null);
     }
 
     /**
diff --git a/pulsar-client/src/main/java/org/apache/pulsar/client/impl/MessageCrypto.java b/pulsar-client/src/main/java/org/apache/pulsar/client/impl/MessageCrypto.java
index 7df8bb2aa..38d6a5850 100644
--- a/pulsar-client/src/main/java/org/apache/pulsar/client/impl/MessageCrypto.java
+++ b/pulsar-client/src/main/java/org/apache/pulsar/client/impl/MessageCrypto.java
@@ -129,6 +129,7 @@
 
     public MessageCrypto(String logCtx, boolean keyGenNeeded) {
 
+        this.logCtx = logCtx;
         encryptedDataKeyMap = new ConcurrentHashMap<String, EncryptionKeyInfo>();
         dataKeyCache = CacheBuilder.newBuilder().expireAfterAccess(4, TimeUnit.HOURS)
                 .build(new CacheLoader<ByteBuffer, SecretKey>() {
@@ -471,7 +472,7 @@ private boolean decryptDataKey(String keyName, byte[] encryptedDataKey, List<Key
             return false;
         }
 
-        // Generate a data key to encrypt messages
+        // Decrypt data key to decrypt messages
         Cipher dataKeyCipher = null;
         byte[] dataKeyValue = null;
         byte[] keyDigest = null;


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services