monotone

monotone Mtn Source Tree

Root/cert.hh

1#ifndef __CERT_HH__
2#define __CERT_HH__
3
4// Copyright (C) 2002 Graydon Hoare <graydon@pobox.com>
5//
6// This program is made available under the GNU GPL version 2.0 or
7// greater. See the accompanying file COPYING for details.
8//
9// This program is distributed WITHOUT ANY WARRANTY; without even the
10// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11// PURPOSE.
12
13#include <map>
14#include <set>
15#include "vector.hh"
16
17#include "vocab.hh"
18#include "dates.hh"
19
20// Certs associate an opaque name/value pair with a revision ID, and
21// are accompanied by an RSA public-key signature attesting to the
22// association. Users can write as much extra meta-data as they like
23// about revisions, using certs, without needing anyone's special
24// permission.
25
26class app_state;
27
28struct cert
29{
30 cert();
31
32 // This is to make revision<cert> and manifest<cert> work.
33 explicit cert(std::string const & s);
34
35 cert(hexenc<id> const & ident,
36 cert_name const & name,
37 base64<cert_value> const & value,
38 rsa_keypair_id const & key);
39 cert(hexenc<id> const & ident,
40 cert_name const & name,
41 base64<cert_value> const & value,
42 rsa_keypair_id const & key,
43 base64<rsa_sha1_signature> const & sig);
44 hexenc<id> ident;
45 cert_name name;
46 base64<cert_value> value;
47 rsa_keypair_id key;
48 base64<rsa_sha1_signature> sig;
49 bool operator<(cert const & other) const;
50 bool operator==(cert const & other) const;
51};
52
53EXTERN template class revision<cert>;
54EXTERN template class manifest<cert>;
55
56
57// These 3 are for netio support.
58void read_cert(std::string const & in, cert & t);
59void write_cert(cert const & t, std::string & out);
60void cert_hash_code(cert const & t, hexenc<id> & out);
61
62typedef enum {cert_ok, cert_bad, cert_unknown} cert_status;
63
64void cert_signable_text(cert const & t,std::string & out);
65cert_status check_cert(app_state & app, cert const & t);
66bool priv_key_exists(app_state & app, rsa_keypair_id const & id);
67void load_key_pair(app_state & app,
68 rsa_keypair_id const & id,
69 keypair & kp);
70
71// Only used in cert.cc, and in revision.cc in what looks
72// like migration code.
73void make_simple_cert(hexenc<id> const & id,
74 cert_name const & nm,
75 cert_value const & cv,
76 app_state & app,
77 cert & c);
78
79void put_simple_revision_cert(revision_id const & id,
80 cert_name const & nm,
81 cert_value const & val,
82 app_state & app);
83
84void erase_bogus_certs(std::vector< revision<cert> > & certs,
85 app_state & app);
86
87void erase_bogus_certs(std::vector< manifest<cert> > & certs,
88 app_state & app);
89
90// Special certs -- system won't work without them.
91
92#define branch_cert_name cert_name("branch")
93
94void
95cert_revision_in_branch(revision_id const & ctx,
96 branch_name const & branchname,
97 app_state & app);
98
99
100// We also define some common cert types, to help establish useful
101// conventions. you should use these unless you have a compelling
102// reason not to.
103
104// N()'s out if there is no unique key for us to use
105void
106get_user_key(rsa_keypair_id & key, app_state & app);
107
108void
109guess_branch(revision_id const & id, app_state & app, branch_name & branchname);
110void
111guess_branch(revision_id const & id, app_state & app);
112
113#define date_cert_name cert_name("date")
114#define author_cert_name cert_name("author")
115#define tag_cert_name cert_name("tag")
116#define changelog_cert_name cert_name("changelog")
117#define comment_cert_name cert_name("comment")
118#define testresult_cert_name cert_name("testresult")
119#define suspend_cert_name cert_name("suspend")
120
121void
122cert_revision_suspended_in_branch(revision_id const & ctx,
123 branch_name const & branchname,
124 app_state & app);
125
126void
127cert_revision_date_time(revision_id const & m,
128 date_t const & t,
129 app_state & app);
130
131void
132cert_revision_author(revision_id const & m,
133 std::string const & author,
134 app_state & app);
135
136void
137cert_revision_author_default(revision_id const & m,
138 app_state & app);
139
140void
141cert_revision_tag(revision_id const & m,
142 std::string const & tagname,
143 app_state & app);
144
145void
146cert_revision_changelog(revision_id const & m,
147 utf8 const & changelog,
148 app_state & app);
149
150void
151cert_revision_comment(revision_id const & m,
152 utf8 const & comment,
153 app_state & app);
154
155void
156cert_revision_testresult(revision_id const & m,
157 std::string const & results,
158 app_state & app);
159
160
161// Local Variables:
162// mode: C++
163// fill-column: 76
164// c-file-style: "gnu"
165// indent-tabs-mode: nil
166// End:
167// vim: et:sw=2:sts=2:ts=2:cino=>2s,{s,\:s,+s,t0,g0,^-2,e-2,n-2,p2s,(0,=s:
168
169#endif // __CERT_HH__

Archive Download this file

Branches

Tags

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