monotone

monotone Mtn Source Tree

Root/cert.hh

1#ifndef __CERT_HH__
2#define __CERT_HH__
3
4// copyright (C) 2002, 2003 graydon hoare <graydon@pobox.com>
5// all rights reserved.
6// licensed to the public under the terms of the GNU GPL (>= 2)
7// see the file COPYING for details
8
9#include "vocab.hh"
10
11#include <set>
12#include <map>
13#include <vector>
14#include <time.h>
15#include <boost/date_time/posix_time/posix_time.hpp>
16
17// certs associate an opaque name/value pair with a particular identifier in
18// the system (eg. a manifest or file id) and are accompanied by an RSA
19// public-key signature attesting to the association. users can write as
20// much extra meta-data as they like about files or manifests, using certs,
21// without needing anyone's special permission.
22
23struct app_state;
24struct packet_consumer;
25
26struct cert
27{
28 cert();
29 cert(hexenc<id> const & ident,
30 cert_name const & name,
31 base64<cert_value> const & value,
32 rsa_keypair_id const & key);
33 cert(hexenc<id> const & ident,
34 cert_name const & name,
35 base64<cert_value> const & value,
36 rsa_keypair_id const & key,
37 base64<rsa_sha1_signature> const & sig);
38 hexenc<id> ident;
39 cert_name name;
40 base64<cert_value> value;
41 rsa_keypair_id key;
42 base64<rsa_sha1_signature> sig;
43 bool operator<(cert const & other) const;
44 bool operator==(cert const & other) const;
45};
46
47
48// these 3 are for netio support
49void read_cert(std::string const & in, cert & t);
50void write_cert(cert const & t, std::string & out);
51void cert_hash_code(cert const & t, hexenc<id> & out);
52
53typedef enum {cert_ok, cert_bad, cert_unknown} cert_status;
54
55void cert_signable_text(cert const & t,std::string & out);
56cert_status check_cert(app_state & app, cert const & t);
57bool priv_key_exists(app_state & app, rsa_keypair_id const & id);
58void load_key_pair(app_state & app,
59 rsa_keypair_id const & id,
60 keypair & kp);
61void calculate_cert(app_state & app, cert & t);
62void make_simple_cert(hexenc<id> const & id,
63 cert_name const & nm,
64 cert_value const & cv,
65 app_state & app,
66 cert & c);
67
68void erase_bogus_certs(std::vector< revision<cert> > & certs,
69 app_state & app);
70
71void erase_bogus_certs(std::vector< manifest<cert> > & certs,
72 app_state & app);
73
74// special certs -- system won't work without them
75
76extern std::string const branch_cert_name;
77
78void
79cert_revision_in_branch(revision_id const & ctx,
80 cert_value const & branchname,
81 app_state & app,
82 packet_consumer & pc);
83
84void
85get_branch_heads(cert_value const & branchname,
86 app_state & app,
87 std::set<revision_id> & heads);
88
89// we also define some common cert types, to help establish useful
90// conventions. you should use these unless you have a compelling
91// reason not to.
92
93// N()'s out if there is no unique key for us to use
94void
95get_user_key(rsa_keypair_id & key, app_state & app);
96
97void
98guess_branch(revision_id const & id,
99 app_state & app,
100 cert_value & branchname);
101
102extern std::string const date_cert_name;
103extern std::string const author_cert_name;
104extern std::string const tag_cert_name;
105extern std::string const changelog_cert_name;
106extern std::string const comment_cert_name;
107extern std::string const testresult_cert_name;
108
109void
110cert_revision_date_now(revision_id const & m,
111 app_state & app,
112 packet_consumer & pc);
113
114void
115cert_revision_date_time(revision_id const & m,
116 boost::posix_time::ptime t,
117 app_state & app,
118 packet_consumer & pc);
119
120void
121cert_revision_date_time(revision_id const & m,
122 time_t time,
123 app_state & app,
124 packet_consumer & pc);
125
126void
127cert_revision_author(revision_id const & m,
128 std::string const & author,
129 app_state & app,
130 packet_consumer & pc);
131
132void
133cert_revision_author_default(revision_id const & m,
134 app_state & app,
135 packet_consumer & pc);
136
137void
138cert_revision_tag(revision_id const & m,
139 std::string const & tagname,
140 app_state & app,
141 packet_consumer & pc);
142
143void
144cert_revision_changelog(revision_id const & m,
145 std::string const & changelog,
146 app_state & app,
147 packet_consumer & pc);
148
149void
150cert_revision_comment(revision_id const & m,
151 std::string const & comment,
152 app_state & app,
153 packet_consumer & pc);
154
155void
156cert_revision_testresult(revision_id const & m,
157 std::string const & results,
158 app_state & app,
159 packet_consumer & pc);
160
161
162#endif // __CERT_HH__

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status