client-cpp  0.6.1
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 
32 #include "kaa/gen/BootstrapGen.hpp"
33 #include "kaa/gen/EndpointGen.hpp"
34 
35 #include <vector>
36 #include <memory>
37 #include <cstdint>
38 #include <boost/noncopyable.hpp>
39 #include <botan/base64.h>
40 
41 namespace kaa {
42 
43 class HttpDataProcessor : boost::noncopyable {
44 public:
45  HttpDataProcessor(const Botan::MemoryVector<std::uint8_t>& pubKey,
46  const std::string& privKey,
47  const Botan::MemoryVector<std::uint8_t>& remoteKey) :
48  encDec_(new RsaEncoderDecoder(pubKey, privKey, remoteKey)) { }
49  HttpDataProcessor() { }
50  ~HttpDataProcessor() { }
51 
52  std::shared_ptr<IHttpRequest> createOperationRequest(const HttpUrl& url, const std::vector<std::uint8_t>& data);
53  std::string retrieveOperationResponse(const IHttpResponse& response);
54 
55  std::shared_ptr<IHttpRequest> createBootstrapRequest(const HttpUrl& url, const std::vector<std::uint8_t>& data);
56  std::string retrieveBootstrapResponse(const IHttpResponse& response);
57 
58  void setEncoderDecoder(std::shared_ptr<IEncoderDecoder> encoderDecoder) { encDec_ = encoderDecoder; }
59 
60 private:
61  void verifyResponse(const IHttpResponse& response);
62 
63 private:
64  std::shared_ptr<IEncoderDecoder> encDec_;
65 
66 };
67 
68 typedef std::shared_ptr<HttpDataProcessor> HttpDataProcessorPtr;
69 
70 }
71 
72 #endif
73 
74 #endif /* HTTPDATAPROCESSOR_HPP_ */