This is an automated email from the ASF dual-hosted git repository.

xyz pushed a commit to branch branch-2.8
in repository https://gitbox.apache.org/repos/asf/pulsar.git


The following commit(s) were added to refs/heads/branch-2.8 by this push:
     new 7bceca1  [python] Support CryptoKeyReader for Reader API in python 
clients (#11447)
7bceca1 is described below

commit 7bceca1f5f7de13fa909cb0e483ebf8bd6966d39
Author: Sanjiv Raj <[email protected]>
AuthorDate: Fri Aug 20 19:39:31 2021 -0500

    [python] Support CryptoKeyReader for Reader API in python clients (#11447)
    
    The Reader API in the python client does not support reading an encrypted 
message.
    This PR adds the same and leverages existing  C++ Reader API which supports 
the same.
    
    * Updated `pulsar.Client.create_reader` to accept  `crypto_key_reader` 
argument
    * Update existing unit test for Python encryption.
    
    (cherry picked from commit f7de12fa52e43f886404968691968b514831dac)
    
    Solved conflicts by modifing following files:
    - pulsar-client-cpp/python/pulsar_test.py
    - pulsar-client-cpp/python/src/config.cc
---
 pulsar-client-cpp/python/pulsar/__init__.py | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/pulsar-client-cpp/python/pulsar/__init__.py 
b/pulsar-client-cpp/python/pulsar/__init__.py
index 18891c7..96a9f6c 100644
--- a/pulsar-client-cpp/python/pulsar/__init__.py
+++ b/pulsar-client-cpp/python/pulsar/__init__.py
@@ -766,7 +766,8 @@ class Client:
                       receiver_queue_size=1000,
                       reader_name=None,
                       subscription_role_prefix=None,
-                      is_read_compacted=False
+                      is_read_compacted=False,
+                      crypto_key_reader=None
                       ):
         """
         Create a reader on a particular topic
@@ -816,6 +817,9 @@ class Client:
           Sets the subscription role prefix.
         * `is_read_compacted`:
           Selects whether to read the compacted version of the topic
+        * crypto_key_reader:
+           Symmetric encryption class implementation, configuring public key 
encryption messages for the producer
+           and private key decryption messages for the consumer
         """
         _check_type(str, topic, 'topic')
         _check_type(_pulsar.MessageId, start_message_id, 'start_message_id')
@@ -824,6 +828,7 @@ class Client:
         _check_type_or_none(str, reader_name, 'reader_name')
         _check_type_or_none(str, subscription_role_prefix, 
'subscription_role_prefix')
         _check_type(bool, is_read_compacted, 'is_read_compacted')
+        _check_type_or_none(CryptoKeyReader, crypto_key_reader, 
'crypto_key_reader')
 
         conf = _pulsar.ReaderConfiguration()
         if reader_listener:
@@ -835,6 +840,8 @@ class Client:
             conf.subscription_role_prefix(subscription_role_prefix)
         conf.schema(schema.schema_info())
         conf.read_compacted(is_read_compacted)
+        if crypto_key_reader:
+            conf.crypto_key_reader(crypto_key_reader.cryptoKeyReader)
 
         c = Reader()
         c._reader = self._client.create_reader(topic, start_message_id, conf)

Reply via email to