client-cpp  0.6.1
ServerInfo.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 SERVERINFO_HPP_
18 #define SERVERINFO_HPP_
19 
20 #include <string>
21 #include <cstdint>
22 
23 #include <botan/botan.h>
24 #include <botan/base64.h>
25 
26 #include "kaa/http/HttpUrl.hpp"
27 
28 namespace kaa {
29 
30 class ServerInfo {
31 public:
32  ServerInfo() { }
33  ServerInfo(const std::string& host, const Botan::MemoryVector<std::uint8_t>& publicKey)
34  : host_(host), publicKey_(publicKey) { }
35  ServerInfo(const std::string& host, const std::string& publicKey)
36  : host_(host), publicKey_(Botan::base64_decode(publicKey)) { }
37  ~ServerInfo() { };
38 
39  bool isValid() const { return !host_.empty(); }
40 
41  const std::string& getHost() const { return host_; }
42  const Botan::MemoryVector<std::uint8_t>& getPublicKey() const { return publicKey_; }
43 
44  HttpUrl getUrl() const { return HttpUrl(host_); }
45 
46 private:
47  std::string host_;
48  Botan::MemoryVector<std::uint8_t> publicKey_;
49 };
50 
51 }
52 
53 
54 #endif /* SERVERINFO_HPP_ */
HttpUrl getUrl() const
Definition: ServerInfo.hpp:44
const Botan::MemoryVector< std::uint8_t > & getPublicKey() const
Definition: ServerInfo.hpp:42
ServerInfo(const std::string &host, const std::string &publicKey)
Definition: ServerInfo.hpp:35
bool isValid() const
Definition: ServerInfo.hpp:39
ServerInfo(const std::string &host, const Botan::MemoryVector< std::uint8_t > &publicKey)
Definition: ServerInfo.hpp:33
const std::string & getHost() const
Definition: ServerInfo.hpp:41