Mir
authority.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2015-2016 Canonical Ltd.
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 or 3 as
6  * published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
17  * Brandon Schaefer <brandon.schaefer@canonical.com>
18  */
19 
20 #ifndef MIR_COOKIE_AUTHORITY_H_
21 #define MIR_COOKIE_AUTHORITY_H_
22 
23 #include <memory>
24 #include <stdexcept>
25 #include <vector>
26 
27 #include "mir/cookie/cookie.h"
28 
29 namespace mir
30 {
31 namespace cookie
32 {
33 using Secret = std::vector<uint8_t>;
34 
35 struct SecurityCheckError : std::runtime_error
36 {
38 };
39 
51 class Authority
52 {
53 public:
61  static size_t optimal_secret_size();
62 
70  static std::unique_ptr<Authority> create_from(Secret const& secret);
71 
78  static std::unique_ptr<Authority> create_saving(Secret& save_secret);
79 
85  static std::unique_ptr<Authority> create();
86 
87  Authority(Authority const& authority) = delete;
88  Authority& operator=(Authority const& authority) = delete;
89  virtual ~Authority() noexcept = default;
90 
97  virtual std::unique_ptr<Cookie> make_cookie(uint64_t const& timestamp) = 0;
98 
105  virtual std::unique_ptr<Cookie> make_cookie(std::vector<uint8_t> const& raw_cookie) = 0;
106 
113  static unsigned const minimum_secret_size = 8;
114 protected:
115  Authority() = default;
116 };
117 
118 }
119 }
120 #endif // MIR_COOKIE_COOKIE_AUTHORITY_H_
AutoUnblockThread is a helper thread class that can gracefully shutdown at destruction time...
Definition: blob.h:26
Definition: authority.h:35
A source of moderately-difficult-to-spoof cookies.
Definition: authority.h:51
std::vector< uint8_t > Secret
Definition: authority.h:33

Copyright © 2012-2018 Canonical Ltd.
Generated on Thu Apr 5 15:26:05 UTC 2018