diff --git a/VERSION b/VERSION index 1b2d9d2e8..48d02e145 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.36.1981 \ No newline at end of file +1.36.1982 \ No newline at end of file diff --git a/kms/CMakeLists.txt b/kms/CMakeLists.txt index 941dfb979..f887d85ba 100644 --- a/kms/CMakeLists.txt +++ b/kms/CMakeLists.txt @@ -21,6 +21,8 @@ set(kms_public_header include/alibabacloud/kms/KmsExport.h ) set(kms_public_header_model + include/alibabacloud/kms/model/AdvanceEncryptRequest.h + include/alibabacloud/kms/model/AdvanceEncryptResult.h include/alibabacloud/kms/model/AsymmetricDecryptRequest.h include/alibabacloud/kms/model/AsymmetricDecryptResult.h include/alibabacloud/kms/model/AsymmetricEncryptRequest.h @@ -208,6 +210,8 @@ set(kms_public_header_model set(kms_src src/KmsClient.cc + src/model/AdvanceEncryptRequest.cc + src/model/AdvanceEncryptResult.cc src/model/AsymmetricDecryptRequest.cc src/model/AsymmetricDecryptResult.cc src/model/AsymmetricEncryptRequest.cc diff --git a/kms/include/alibabacloud/kms/KmsClient.h b/kms/include/alibabacloud/kms/KmsClient.h index 8f628c985..ef96e1340 100644 --- a/kms/include/alibabacloud/kms/KmsClient.h +++ b/kms/include/alibabacloud/kms/KmsClient.h @@ -22,6 +22,8 @@ #include #include #include "KmsExport.h" +#include "model/AdvanceEncryptRequest.h" +#include "model/AdvanceEncryptResult.h" #include "model/AsymmetricDecryptRequest.h" #include "model/AsymmetricDecryptResult.h" #include "model/AsymmetricEncryptRequest.h" @@ -215,6 +217,9 @@ namespace AlibabaCloud class ALIBABACLOUD_KMS_EXPORT KmsClient : public RpcServiceClient { public: + typedef Outcome AdvanceEncryptOutcome; + typedef std::future AdvanceEncryptOutcomeCallable; + typedef std::function&)> AdvanceEncryptAsyncHandler; typedef Outcome AsymmetricDecryptOutcome; typedef std::future AsymmetricDecryptOutcomeCallable; typedef std::function&)> AsymmetricDecryptAsyncHandler; @@ -496,6 +501,9 @@ namespace AlibabaCloud KmsClient(const std::shared_ptr &credentialsProvider, const ClientConfiguration &configuration); KmsClient(const std::string &accessKeyId, const std::string &accessKeySecret, const ClientConfiguration &configuration); ~KmsClient(); + AdvanceEncryptOutcome advanceEncrypt(const Model::AdvanceEncryptRequest &request)const; + void advanceEncryptAsync(const Model::AdvanceEncryptRequest& request, const AdvanceEncryptAsyncHandler& handler, const std::shared_ptr& context = nullptr) const; + AdvanceEncryptOutcomeCallable advanceEncryptCallable(const Model::AdvanceEncryptRequest& request) const; AsymmetricDecryptOutcome asymmetricDecrypt(const Model::AsymmetricDecryptRequest &request)const; void asymmetricDecryptAsync(const Model::AsymmetricDecryptRequest& request, const AsymmetricDecryptAsyncHandler& handler, const std::shared_ptr& context = nullptr) const; AsymmetricDecryptOutcomeCallable asymmetricDecryptCallable(const Model::AsymmetricDecryptRequest& request) const; diff --git a/kms/include/alibabacloud/kms/model/AdvanceEncryptRequest.h b/kms/include/alibabacloud/kms/model/AdvanceEncryptRequest.h new file mode 100644 index 000000000..db9b6c4d1 --- /dev/null +++ b/kms/include/alibabacloud/kms/model/AdvanceEncryptRequest.h @@ -0,0 +1,57 @@ +/* + * Copyright 2009-2017 Alibaba Cloud All rights reserved. + * + * Licensed 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. + */ + +#ifndef ALIBABACLOUD_KMS_MODEL_ADVANCEENCRYPTREQUEST_H_ +#define ALIBABACLOUD_KMS_MODEL_ADVANCEENCRYPTREQUEST_H_ + +#include +#include +#include +#include +#include + +namespace AlibabaCloud { +namespace Kms { +namespace Model { +class ALIBABACLOUD_KMS_EXPORT AdvanceEncryptRequest : public RpcServiceRequest { +public: + AdvanceEncryptRequest(); + ~AdvanceEncryptRequest(); + std::string getPaddingMode() const; + void setPaddingMode(const std::string &paddingMode); + std::string getAad() const; + void setAad(const std::string &aad); + std::string getKeyId() const; + void setKeyId(const std::string &keyId); + std::string getPlaintext() const; + void setPlaintext(const std::string &plaintext); + std::string getIv() const; + void setIv(const std::string &iv); + std::string getAlgorithm() const; + void setAlgorithm(const std::string &algorithm); + +private: + std::string paddingMode_; + std::string aad_; + std::string keyId_; + std::string plaintext_; + std::string iv_; + std::string algorithm_; +}; +} // namespace Model +} // namespace Kms +} // namespace AlibabaCloud +#endif // !ALIBABACLOUD_KMS_MODEL_ADVANCEENCRYPTREQUEST_H_ diff --git a/kms/include/alibabacloud/kms/model/AdvanceEncryptResult.h b/kms/include/alibabacloud/kms/model/AdvanceEncryptResult.h new file mode 100644 index 000000000..db62e95ff --- /dev/null +++ b/kms/include/alibabacloud/kms/model/AdvanceEncryptResult.h @@ -0,0 +1,61 @@ +/* + * Copyright 2009-2017 Alibaba Cloud All rights reserved. + * + * Licensed 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. + */ + +#ifndef ALIBABACLOUD_KMS_MODEL_ADVANCEENCRYPTRESULT_H_ +#define ALIBABACLOUD_KMS_MODEL_ADVANCEENCRYPTRESULT_H_ + +#include +#include +#include +#include +#include + +namespace AlibabaCloud +{ + namespace Kms + { + namespace Model + { + class ALIBABACLOUD_KMS_EXPORT AdvanceEncryptResult : public ServiceResult + { + public: + + + AdvanceEncryptResult(); + explicit AdvanceEncryptResult(const std::string &payload); + ~AdvanceEncryptResult(); + std::string getPaddingMode()const; + std::string getCiphertextBlob()const; + std::string getKeyId()const; + std::string getKeyVersionId()const; + std::string getAlgorithm()const; + std::string getIv()const; + + protected: + void parse(const std::string &payload); + private: + std::string paddingMode_; + std::string ciphertextBlob_; + std::string keyId_; + std::string keyVersionId_; + std::string algorithm_; + std::string iv_; + + }; + } + } +} +#endif // !ALIBABACLOUD_KMS_MODEL_ADVANCEENCRYPTRESULT_H_ \ No newline at end of file diff --git a/kms/src/KmsClient.cc b/kms/src/KmsClient.cc index afed23d58..9db9a6fd4 100644 --- a/kms/src/KmsClient.cc +++ b/kms/src/KmsClient.cc @@ -51,6 +51,42 @@ KmsClient::KmsClient(const std::string & accessKeyId, const std::string & access KmsClient::~KmsClient() {} +KmsClient::AdvanceEncryptOutcome KmsClient::advanceEncrypt(const AdvanceEncryptRequest &request) const +{ + auto endpointOutcome = endpointProvider_->getEndpoint(); + if (!endpointOutcome.isSuccess()) + return AdvanceEncryptOutcome(endpointOutcome.error()); + + auto outcome = makeRequest(endpointOutcome.result(), request); + + if (outcome.isSuccess()) + return AdvanceEncryptOutcome(AdvanceEncryptResult(outcome.result())); + else + return AdvanceEncryptOutcome(outcome.error()); +} + +void KmsClient::advanceEncryptAsync(const AdvanceEncryptRequest& request, const AdvanceEncryptAsyncHandler& handler, const std::shared_ptr& context) const +{ + auto fn = [this, request, handler, context]() + { + handler(this, request, advanceEncrypt(request), context); + }; + + asyncExecute(new Runnable(fn)); +} + +KmsClient::AdvanceEncryptOutcomeCallable KmsClient::advanceEncryptCallable(const AdvanceEncryptRequest &request) const +{ + auto task = std::make_shared>( + [this, request]() + { + return this->advanceEncrypt(request); + }); + + asyncExecute(new Runnable([task]() { (*task)(); })); + return task->get_future(); +} + KmsClient::AsymmetricDecryptOutcome KmsClient::asymmetricDecrypt(const AsymmetricDecryptRequest &request) const { auto endpointOutcome = endpointProvider_->getEndpoint(); diff --git a/kms/src/model/AdvanceEncryptRequest.cc b/kms/src/model/AdvanceEncryptRequest.cc new file mode 100644 index 000000000..672a29147 --- /dev/null +++ b/kms/src/model/AdvanceEncryptRequest.cc @@ -0,0 +1,81 @@ +/* + * Copyright 2009-2017 Alibaba Cloud All rights reserved. + * + * Licensed 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. + */ + +#include + +using AlibabaCloud::Kms::Model::AdvanceEncryptRequest; + +AdvanceEncryptRequest::AdvanceEncryptRequest() + : RpcServiceRequest("kms", "2016-01-20", "AdvanceEncrypt") { + setMethod(HttpRequest::Method::Post); +} + +AdvanceEncryptRequest::~AdvanceEncryptRequest() {} + +std::string AdvanceEncryptRequest::getPaddingMode() const { + return paddingMode_; +} + +void AdvanceEncryptRequest::setPaddingMode(const std::string &paddingMode) { + paddingMode_ = paddingMode; + setParameter(std::string("PaddingMode"), paddingMode); +} + +std::string AdvanceEncryptRequest::getAad() const { + return aad_; +} + +void AdvanceEncryptRequest::setAad(const std::string &aad) { + aad_ = aad; + setParameter(std::string("Aad"), aad); +} + +std::string AdvanceEncryptRequest::getKeyId() const { + return keyId_; +} + +void AdvanceEncryptRequest::setKeyId(const std::string &keyId) { + keyId_ = keyId; + setParameter(std::string("KeyId"), keyId); +} + +std::string AdvanceEncryptRequest::getPlaintext() const { + return plaintext_; +} + +void AdvanceEncryptRequest::setPlaintext(const std::string &plaintext) { + plaintext_ = plaintext; + setParameter(std::string("Plaintext"), plaintext); +} + +std::string AdvanceEncryptRequest::getIv() const { + return iv_; +} + +void AdvanceEncryptRequest::setIv(const std::string &iv) { + iv_ = iv; + setParameter(std::string("Iv"), iv); +} + +std::string AdvanceEncryptRequest::getAlgorithm() const { + return algorithm_; +} + +void AdvanceEncryptRequest::setAlgorithm(const std::string &algorithm) { + algorithm_ = algorithm; + setParameter(std::string("Algorithm"), algorithm); +} + diff --git a/kms/src/model/AdvanceEncryptResult.cc b/kms/src/model/AdvanceEncryptResult.cc new file mode 100644 index 000000000..7576ed7f6 --- /dev/null +++ b/kms/src/model/AdvanceEncryptResult.cc @@ -0,0 +1,86 @@ +/* + * Copyright 2009-2017 Alibaba Cloud All rights reserved. + * + * Licensed 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. + */ + +#include +#include + +using namespace AlibabaCloud::Kms; +using namespace AlibabaCloud::Kms::Model; + +AdvanceEncryptResult::AdvanceEncryptResult() : + ServiceResult() +{} + +AdvanceEncryptResult::AdvanceEncryptResult(const std::string &payload) : + ServiceResult() +{ + parse(payload); +} + +AdvanceEncryptResult::~AdvanceEncryptResult() +{} + +void AdvanceEncryptResult::parse(const std::string &payload) +{ + Json::Reader reader; + Json::Value value; + reader.parse(payload, value); + setRequestId(value["RequestId"].asString()); + if(!value["CiphertextBlob"].isNull()) + ciphertextBlob_ = value["CiphertextBlob"].asString(); + if(!value["Algorithm"].isNull()) + algorithm_ = value["Algorithm"].asString(); + if(!value["KeyId"].isNull()) + keyId_ = value["KeyId"].asString(); + if(!value["KeyVersionId"].isNull()) + keyVersionId_ = value["KeyVersionId"].asString(); + if(!value["Iv"].isNull()) + iv_ = value["Iv"].asString(); + if(!value["PaddingMode"].isNull()) + paddingMode_ = value["PaddingMode"].asString(); + +} + +std::string AdvanceEncryptResult::getPaddingMode()const +{ + return paddingMode_; +} + +std::string AdvanceEncryptResult::getCiphertextBlob()const +{ + return ciphertextBlob_; +} + +std::string AdvanceEncryptResult::getKeyId()const +{ + return keyId_; +} + +std::string AdvanceEncryptResult::getKeyVersionId()const +{ + return keyVersionId_; +} + +std::string AdvanceEncryptResult::getAlgorithm()const +{ + return algorithm_; +} + +std::string AdvanceEncryptResult::getIv()const +{ + return iv_; +} +