1 /* fides.h - Light-weight, decentralised trust and authorisation management
2 Copyright (C) 2008-2009 Guus Sliepen <guus@tinc-vpn.org>
4 Fides is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of
7 the License, or (at your option) any later version.
9 Fides is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with this program; if not, see <http://www.gnu.org/licenses/>.
26 #include "certificate.h"
27 #include "publickey.h"
28 #include "privatekey.h"
35 std::string obsoletedir;
39 struct timeval latest;
44 class exception: public std::runtime_error {
46 exception(const std::string reason): runtime_error(reason) {}
52 std::map<std::string, publickey *> keys;
53 std::map<std::string, certificate *> certs;
55 void merge(certificate *cert);
56 void merge(publickey *key);
59 fides(const std::string &homedir = "");
62 bool is_firstrun() const;
64 std::string get_homedir() const;
66 void sign(const std::string &statement);
68 void allow(const std::string &statement, const publickey *key = 0);
69 void dontcare(const std::string &statement, const publickey *key = 0);
70 void deny(const std::string &statement, const publickey *key = 0);
71 bool is_allowed(const std::string &statement, const publickey *key = 0) const;
72 bool is_denied(const std::string &statement, const publickey *key = 0) const;
74 void auth_stats(const std::string &statement, int &self, int &trusted, int &all) const;
75 void trust(const publickey *key);
76 void dctrust(const publickey *key);
77 void distrust(const publickey *key);
78 bool is_trusted(const publickey *key) const;
79 bool is_distrusted(const publickey *key) const;
80 publickey *find_key(const std::string &fingerprint) const;
83 std::vector<const certificate *> find_certificates(const publickey *key, const std::string &statement) const;
84 std::vector<const certificate *> find_certificates(const std::string &statement) const;
85 std::vector<const certificate *> find_certificates(const publickey *key) const;
87 const certificate *import_certificate(const std::string &certificate);
88 std::string export_certificate(const certificate *) const;
90 const publickey *import_key(const std::string &key);
91 std::string export_key(const publickey *key) const;
93 void import_all(std::istream &in);
94 void export_all(std::ostream &out) const;
96 certificate *certificate_from_string(const std::string &certificate);
97 certificate *certificate_load(const std::string &filename);
98 void certificate_save(const certificate *cert, const std::string &filename) const;