client-cpp  0.10.0
HttpDataProcessor.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2014-2016 CyberVision, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef HTTPDATAPROCESSOR_HPP_
18 #define HTTPDATAPROCESSOR_HPP_
19 
20 #include "kaa/KaaDefaults.hpp"
21 
22 #include <vector>
23 #include <memory>
24 #include <cstdint>
25 
26 #include <boost/noncopyable.hpp>
27 
28 #include <botan/base64.h>
29 
36 
37 
38 namespace kaa {
39 
40 class HttpDataProcessor : boost::noncopyable {
41 public:
43  const PrivateKey& privKey,
44  const PublicKey& remoteKey,
45  IKaaClientContext &context) :
46  encDec_(new RsaEncoderDecoder(pubKey, privKey, remoteKey, context)), context_(context) { }
47  HttpDataProcessor(IKaaClientContext &context): context_(context) { }
48 
49  std::shared_ptr<IHttpRequest> createOperationRequest(const HttpUrl& url, const std::vector<std::uint8_t>& data);
50  std::string retrieveOperationResponse(const IHttpResponse& response);
51 
52  std::shared_ptr<IHttpRequest> createBootstrapRequest(const HttpUrl& url, const std::vector<std::uint8_t>& data);
53  std::string retrieveBootstrapResponse(const IHttpResponse& response);
54 
55  void setEncoderDecoder(std::shared_ptr<IEncoderDecoder> encoderDecoder) { encDec_ = encoderDecoder; }
56 
57 private:
58  std::shared_ptr<IHttpRequest> createHttpRequest(const HttpUrl& url, const std::vector<std::uint8_t>& data, bool sign);
59 
60  void verifyResponse(const IHttpResponse& response);
61 
62 private:
63  std::shared_ptr<IEncoderDecoder> encDec_;
64  IKaaClientContext &context_;
65 };
66 
67 typedef std::shared_ptr<HttpDataProcessor> HttpDataProcessorPtr;
68 
69 }
70 
71 #endif /* HTTPDATAPROCESSOR_HPP_ */
Botan::secure_vector< std::uint8_t > PublicKey
std::string retrieveBootstrapResponse(const IHttpResponse &response)
std::shared_ptr< IHttpRequest > createBootstrapRequest(const HttpUrl &url, const std::vector< std::uint8_t > &data)
std::shared_ptr< IHttpRequest > createOperationRequest(const HttpUrl &url, const std::vector< std::uint8_t > &data)
void setEncoderDecoder(std::shared_ptr< IEncoderDecoder > encoderDecoder)
HttpDataProcessor(IKaaClientContext &context)
HttpDataProcessor(const PublicKey &pubKey, const PrivateKey &privKey, const PublicKey &remoteKey, IKaaClientContext &context)
std::string PrivateKey
std::shared_ptr< HttpDataProcessor > HttpDataProcessorPtr
std::string retrieveOperationResponse(const IHttpResponse &response)