client-cpp  0.7.0
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 #include <vector>
23 #include <memory>
24 #include <cstdint>
25 
26 #include <boost/noncopyable.hpp>
27 
28 #include <botan/base64.h>
29 
35 
36 
37 namespace kaa {
38 
39 class HttpDataProcessor : boost::noncopyable {
40 public:
42  const PrivateKey& privKey,
43  const PublicKey& remoteKey) :
44  encDec_(new RsaEncoderDecoder(pubKey, privKey, remoteKey)) { }
46 
47  std::shared_ptr<IHttpRequest> createOperationRequest(const HttpUrl& url, const std::vector<std::uint8_t>& data);
48  std::string retrieveOperationResponse(const IHttpResponse& response);
49 
50  std::shared_ptr<IHttpRequest> createBootstrapRequest(const HttpUrl& url, const std::vector<std::uint8_t>& data);
51  std::string retrieveBootstrapResponse(const IHttpResponse& response);
52 
53  void setEncoderDecoder(std::shared_ptr<IEncoderDecoder> encoderDecoder) { encDec_ = encoderDecoder; }
54 
55 private:
56  std::shared_ptr<IHttpRequest> createHttpRequest(const HttpUrl& url, const std::vector<std::uint8_t>& data, bool sign);
57 
58  void verifyResponse(const IHttpResponse& response);
59 
60 private:
61  std::shared_ptr<IEncoderDecoder> encDec_;
62 
63 };
64 
65 typedef std::shared_ptr<HttpDataProcessor> HttpDataProcessorPtr;
66 
67 }
68 
69 #endif /* HTTPDATAPROCESSOR_HPP_ */
std::string retrieveBootstrapResponse(const IHttpResponse &response)
HttpDataProcessor(const PublicKey &pubKey, const PrivateKey &privKey, const PublicKey &remoteKey)
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)
std::string PrivateKey
Botan::MemoryVector< std::uint8_t > PublicKey
std::shared_ptr< HttpDataProcessor > HttpDataProcessorPtr
std::string retrieveOperationResponse(const IHttpResponse &response)