RobertIndie commented on code in PR #526: URL: https://github.com/apache/pulsar-client-cpp/pull/526#discussion_r2597865680
########## include/pulsar/EncryptionContext.h: ########## @@ -0,0 +1,114 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +#pragma once + +#include <cstdint> +#include <string> +#include <unordered_map> +#include <vector> + +#include "CompressionType.h" +#include "defines.h" + +namespace pulsar { + +namespace proto { +class MessageMetadata; +} + +struct PULSAR_PUBLIC EncryptionKey { + std::string key; + std::string value; + std::unordered_map<std::string, std::string> metadata; + + EncryptionKey(const std::string& key, const std::string& value, + const decltype(EncryptionKey::metadata)& metadata) + : key(key), value(value), metadata(metadata) {} +}; + +/** + * It contains encryption and compression information in it using which application can decrypt consumed + * message with encrypted-payload. + */ +class PULSAR_PUBLIC EncryptionContext { + public: + using KeysType = std::vector<EncryptionKey>; + + /** + * @return the map of encryption keys used for the message + */ + const KeysType& keys() const noexcept { return keys_; } + + /** + * @return the encryption parameter used for the message + */ + const std::string& param() const noexcept { return param_; } + + /** + * @return the encryption algorithm used for the message + */ + const std::string& algorithm() const noexcept { return algorithm_; } + + /** + * @return the compression type used for the message + */ + CompressionType compressionType() const noexcept { return compressionType_; } + + /** + * @return the uncompressed message size if the message is compressed, 0 otherwise + */ + uint32_t uncompressedMessageSize() const noexcept { return uncompressedMessageSize_; } + + /** + * @return the batch size if the message is part of a batch, -1 otherwise + */ + int32_t batchSize() const noexcept { return batchSize_; } + + /** + * When the `ConsumerConfiguration#getCryptoFailureAction` is set to `CONSUME`, the message will still be + * returned even if the decryption failed, in this case, the message payload is still not decrypted but + * users have no way to know that. This method is provided to let users know whether the decryption + * failed. + * + * @return whether the decryption failed + */ Review Comment: ```suggestion /** * When the `ConsumerConfiguration#getCryptoFailureAction` is set to `CONSUME`, the message will still be * returned even if the decryption failed. This method is provided to let users know whether the decryption * failed. * * @return whether the decryption failed */ ``` Users now have a way to know this through the changes in this PR. We don't need to provide such context of this PR to the field doc. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
