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