if(e == string::npos)
throw exception("Invalid certificate");
string fingerprint = hexdecode(data.substr(0, e));
- publickey *signer = find_key(fingerprint);
+ const publickey *signer = find_key(fingerprint);
if(!signer)
throw exception("Unknown public key");
b = e + 1;
fides::~fides() {
cerr << "Fides exitting\n";
- for(map<string, certificate *>::iterator i = certs.begin(); i != certs.end(); ++i)
+ for(map<string, certificate *>::const_iterator i = certs.begin(); i != certs.end(); ++i)
delete i->second;
- for(map<string, publickey *>::iterator i = keys.begin(); i != keys.end(); ++i)
+ for(map<string, publickey *>::const_iterator i = keys.begin(); i != keys.end(); ++i)
if(i->second != &mykey)
delete i->second;
}
return 0;
}
-vector<fides::certificate *> fides::find_certificates(const publickey *signer, const string ®ex) const {
- vector<certificate *> found;
+vector<const fides::certificate *> fides::find_certificates(const publickey *signer, const string ®ex) const {
+ vector<const certificate *> found;
map<string, certificate *>::const_iterator i;
regexp regexp(regex);
for(i = certs.begin(); i != certs.end(); ++i) {
return found;
}
-vector<fides::certificate *> fides::find_certificates(const string ®ex) const {
- vector<certificate *> found;
+vector<const fides::certificate *> fides::find_certificates(const string ®ex) const {
+ vector<const certificate *> found;
map<string, certificate *>::const_iterator i;
regexp regexp(regex);
for(i = certs.begin(); i != certs.end(); ++i)
return found;
}
-vector<fides::certificate *> fides::find_certificates(const publickey *signer) const {
- vector<certificate *> found;
+vector<const fides::certificate *> fides::find_certificates(const publickey *signer) const {
+ vector<const certificate *> found;
map<string, certificate *>::const_iterator i;
for(i = certs.begin(); i != certs.end(); ++i)
if(i->second->signer == signer)
void fides::update_trust() {
// clear trust on all keys
- for(map<string, publickey *>::iterator i = keys.begin(); i != keys.end(); ++i)
+ for(map<string, publickey *>::const_iterator i = keys.begin(); i != keys.end(); ++i)
i->second->trust = 0;
// Start by checking all trust certificates from ourself.
// find all non-zero trust certificates of this key
- vector<certificate *> matches = find_certificates(*i, "^t[+-] ");
+ vector<const certificate *> matches = find_certificates(*i, "^t[+-] ");
// update trust value of those keys
// TODO: move these regexps to the class?
regexp authexp("^a[+0-] ");
regexp trustexp("^t[+0-] ");
- vector<certificate *> others;
+ vector<const certificate *> others;
// Is this an authorisation cert?
if(authexp.match(cert->statement)) {
void fides::auth_stats(const string &statement, int &self, int &trusted, int &all) const {
self = trusted = all = 0;
- vector<certificate *> matches = find_certificates(string("^a[+0-] ") + statement + '$');
+ vector<const certificate *> matches = find_certificates(string("^a[+0-] ") + statement + '$');
for(size_t i = 0; i < matches.size(); ++i) {
char code = matches[i]->statement[1];
int diff = 0;
privatekey mykey;
std::map<std::string, publickey *> keys;
std::map<std::string, certificate *> certs;
- std::set<publickey *> trustedkeys;
void merge(certificate *cert);
void merge(publickey *key);
publickey *find_key(const std::string &fingerprint) const;
void update_trust();
- std::vector<certificate *> find_certificates(const publickey *key, const std::string &statement) const;
- std::vector<certificate *> find_certificates(const std::string &statement) const;
- std::vector<certificate *> find_certificates(const publickey *key) const;
+ std::vector<const certificate *> find_certificates(const publickey *key, const std::string &statement) const;
+ std::vector<const certificate *> find_certificates(const std::string &statement) const;
+ std::vector<const certificate *> find_certificates(const publickey *key) const;
- certificate *import_certificate(const std::string &certificate);
+ const certificate *import_certificate(const std::string &certificate);
std::string export_certificate(const certificate *) const;
- publickey *import_key(const std::string &key);
+ const publickey *import_key(const std::string &key);
std::string export_key(const publickey *key) const;
void import_all(std::istream &in);