client-cpp  0.6.3
HttpDataProcessor.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2014 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 #if defined(KAA_DEFAULT_BOOTSTRAP_HTTP_CHANNEL) || \
23  defined(KAA_DEFAULT_OPERATION_HTTP_CHANNEL) || \
24  defined(KAA_DEFAULT_LONG_POLL_CHANNEL)
25 
26 #include <vector>
27 #include <memory>
28 #include <cstdint>
29 
30 #include <boost/noncopyable.hpp>
31 
32 #include <botan/base64.h>
33 
39 
40 
41 namespace kaa {
42 
43 class HttpDataProcessor : boost::noncopyable {
44 public:
45  HttpDataProcessor(const PublicKey& pubKey,
46  const PrivateKey& privKey,
47  const PublicKey& remoteKey) :
48  encDec_(new RsaEncoderDecoder(pubKey, privKey, remoteKey)) { }
49  HttpDataProcessor() { }
50 
51  std::shared_ptr<IHttpRequest> createOperationRequest(const HttpUrl& url, const std::vector<std::uint8_t>& data);
52  std::string retrieveOperationResponse(const IHttpResponse& response);
53 
54  std::shared_ptr<IHttpRequest> createBootstrapRequest(const HttpUrl& url, const std::vector<std::uint8_t>& data);
55  std::string retrieveBootstrapResponse(const IHttpResponse& response);
56 
57  void setEncoderDecoder(std::shared_ptr<IEncoderDecoder> encoderDecoder) { encDec_ = encoderDecoder; }
58 
59 private:
60  std::shared_ptr<IHttpRequest> createHttpRequest(const HttpUrl& url, const std::vector<std::uint8_t>& data, bool sign);
61 
62  void verifyResponse(const IHttpResponse& response);
63 
64 private:
65  std::shared_ptr<IEncoderDecoder> encDec_;
66 
67 };
68 
69 typedef std::shared_ptr<HttpDataProcessor> HttpDataProcessorPtr;
70 
71 }
72 
73 #endif
74 
75 #endif /* HTTPDATAPROCESSOR_HPP_ */
std::string PrivateKey
Botan::MemoryVector< std::uint8_t > PublicKey