summaryrefslogtreecommitdiffabout
authorMichael Krelin <hacker@klever.net>2008-03-03 17:06:17 (UTC)
committer Michael Krelin <hacker@klever.net>2008-03-03 17:06:17 (UTC)
commit374985b5317d559b561d7f557034661e314f5605 (patch) (unidiff)
treea29c5c415cb046330d8e046c0ad9b7b94bc76593
parentc28479399ef0fedeb6bf14ec665bb4c427654356 (diff)
downloadlibopkele-374985b5317d559b561d7f557034661e314f5605.zip
libopkele-374985b5317d559b561d7f557034661e314f5605.tar.gz
libopkele-374985b5317d559b561d7f557034661e314f5605.tar.bz2
removed basic_message::fields_t typedef
Signed-off-by: Michael Krelin <hacker@klever.net>
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--include/opkele/types.h1
1 files changed, 0 insertions, 1 deletions
diff --git a/include/opkele/types.h b/include/opkele/types.h
index 64f165c..bf50e2b 100644
--- a/include/opkele/types.h
+++ b/include/opkele/types.h
@@ -1,248 +1,247 @@
1#ifndef __OPKELE_TYPES_H 1#ifndef __OPKELE_TYPES_H
2#define __OPKELE_TYPES_H 2#define __OPKELE_TYPES_H
3 3
4/** 4/**
5 * @file 5 * @file
6 * @brief various types declarations 6 * @brief various types declarations
7 */ 7 */
8 8
9#include <cstring> 9#include <cstring>
10#include <ostream> 10#include <ostream>
11#include <vector> 11#include <vector>
12#include <string> 12#include <string>
13#include <map> 13#include <map>
14#include <set> 14#include <set>
15#include <list> 15#include <list>
16#include <opkele/iterator.h> 16#include <opkele/iterator.h>
17#include <opkele/tr1-mem.h> 17#include <opkele/tr1-mem.h>
18 18
19namespace opkele { 19namespace opkele {
20 using std::vector; 20 using std::vector;
21 using std::string; 21 using std::string;
22 using std::map; 22 using std::map;
23 using std::ostream; 23 using std::ostream;
24 using std::multimap; 24 using std::multimap;
25 using std::set; 25 using std::set;
26 using std::list; 26 using std::list;
27 using std::iterator; 27 using std::iterator;
28 using std::forward_iterator_tag; 28 using std::forward_iterator_tag;
29 29
30 /** 30 /**
31 * the OpenID operation mode 31 * the OpenID operation mode
32 */ 32 */
33 typedef enum _mode_t { 33 typedef enum _mode_t {
34 mode_unknown = 0, 34 mode_unknown = 0,
35 mode_associate, 35 mode_associate,
36 mode_checkid_immediate, 36 mode_checkid_immediate,
37 mode_checkid_setup, 37 mode_checkid_setup,
38 mode_check_association 38 mode_check_association
39 } mode_t; 39 } mode_t;
40 40
41 /** 41 /**
42 * the association secret container 42 * the association secret container
43 */ 43 */
44 class secret_t : public vector<unsigned char> { 44 class secret_t : public vector<unsigned char> {
45 public: 45 public:
46 46
47 /** 47 /**
48 * xor the secret and hmac together and encode, using base64 48 * xor the secret and hmac together and encode, using base64
49 * @param key_d pointer to the message digest 49 * @param key_d pointer to the message digest
50 * @param rv reference to the return value 50 * @param rv reference to the return value
51 */ 51 */
52 void enxor_to_base64(const unsigned char *key_d,string& rv) const; 52 void enxor_to_base64(const unsigned char *key_d,string& rv) const;
53 /** 53 /**
54 * decode base64-encoded secret and xor it with the message digest 54 * decode base64-encoded secret and xor it with the message digest
55 * @param key_d pointer to the message digest 55 * @param key_d pointer to the message digest
56 * @param b64 base64-encoded secret value 56 * @param b64 base64-encoded secret value
57 */ 57 */
58 void enxor_from_base64(const unsigned char *key_d,const string& b64); 58 void enxor_from_base64(const unsigned char *key_d,const string& b64);
59 /** 59 /**
60 * plainly encode to base64 representation 60 * plainly encode to base64 representation
61 * @param rv reference to the return value 61 * @param rv reference to the return value
62 */ 62 */
63 void to_base64(string& rv) const; 63 void to_base64(string& rv) const;
64 /** 64 /**
65 * decode cleartext secret from base64 65 * decode cleartext secret from base64
66 * @param b64 base64-encoded representation of the secret value 66 * @param b64 base64-encoded representation of the secret value
67 */ 67 */
68 void from_base64(const string& b64); 68 void from_base64(const string& b64);
69 }; 69 };
70 70
71 /** 71 /**
72 * Interface to the association. 72 * Interface to the association.
73 */ 73 */
74 class association_t { 74 class association_t {
75 public: 75 public:
76 76
77 virtual ~association_t() { } 77 virtual ~association_t() { }
78 78
79 /** 79 /**
80 * retrieve the server with which association was established. 80 * retrieve the server with which association was established.
81 * @return server name 81 * @return server name
82 */ 82 */
83 virtual string server() const = 0; 83 virtual string server() const = 0;
84 /** 84 /**
85 * retrieve the association handle. 85 * retrieve the association handle.
86 * @return handle 86 * @return handle
87 */ 87 */
88 virtual string handle() const = 0; 88 virtual string handle() const = 0;
89 /** 89 /**
90 * retrieve the association type. 90 * retrieve the association type.
91 * @return association type 91 * @return association type
92 */ 92 */
93 virtual string assoc_type() const = 0; 93 virtual string assoc_type() const = 0;
94 /** 94 /**
95 * retrieve the association secret. 95 * retrieve the association secret.
96 * @return association secret 96 * @return association secret
97 */ 97 */
98 virtual secret_t secret() const = 0; 98 virtual secret_t secret() const = 0;
99 /** 99 /**
100 * retrieve the number of seconds the association expires in. 100 * retrieve the number of seconds the association expires in.
101 * @return seconds till expiration 101 * @return seconds till expiration
102 */ 102 */
103 virtual int expires_in() const = 0; 103 virtual int expires_in() const = 0;
104 /** 104 /**
105 * check whether the association is stateless. 105 * check whether the association is stateless.
106 * @return true if stateless 106 * @return true if stateless
107 */ 107 */
108 virtual bool stateless() const = 0; 108 virtual bool stateless() const = 0;
109 /** 109 /**
110 * check whether the association is expired. 110 * check whether the association is expired.
111 * @return true if expired 111 * @return true if expired
112 */ 112 */
113 virtual bool is_expired() const = 0; 113 virtual bool is_expired() const = 0;
114 }; 114 };
115 115
116 /** 116 /**
117 * the shared_ptr<> for association_t object type 117 * the shared_ptr<> for association_t object type
118 */ 118 */
119 typedef tr1mem::shared_ptr<association_t> assoc_t; 119 typedef tr1mem::shared_ptr<association_t> assoc_t;
120 120
121 class basic_message { 121 class basic_message {
122 public: 122 public:
123 typedef list<string> fields_t;
124 typedef util::forward_iterator_proxy< 123 typedef util::forward_iterator_proxy<
125 string,const string&,const string* 124 string,const string&,const string*
126 > fields_iterator; 125 > fields_iterator;
127 126
128 basic_message() { } 127 basic_message() { }
129 virtual ~basic_message() { } 128 virtual ~basic_message() { }
130 basic_message(const basic_message& x); 129 basic_message(const basic_message& x);
131 void copy_to(basic_message& x) const; 130 void copy_to(basic_message& x) const;
132 void append_to(basic_message& x) const; 131 void append_to(basic_message& x) const;
133 132
134 virtual bool has_field(const string& n) const = 0; 133 virtual bool has_field(const string& n) const = 0;
135 virtual const string& get_field(const string& n) const = 0; 134 virtual const string& get_field(const string& n) const = 0;
136 135
137 virtual fields_iterator fields_begin() const = 0; 136 virtual fields_iterator fields_begin() const = 0;
138 virtual fields_iterator fields_end() const = 0; 137 virtual fields_iterator fields_end() const = 0;
139 138
140 virtual string append_query(const string& url,const char *pfx=0) const; 139 virtual string append_query(const string& url,const char *pfx=0) const;
141 virtual string query_string(const char *pfx=0) const; 140 virtual string query_string(const char *pfx=0) const;
142 141
143 virtual void reset_fields(); 142 virtual void reset_fields();
144 virtual void set_field(const string& n,const string& v); 143 virtual void set_field(const string& n,const string& v);
145 virtual void reset_field(const string& n); 144 virtual void reset_field(const string& n);
146 145
147 }; 146 };
148 147
149 class basic_openid_message : public basic_message { 148 class basic_openid_message : public basic_message {
150 public: 149 public:
151 typedef list<string> fields_t; 150 typedef list<string> fields_t;
152 typedef util::forward_iterator_proxy< 151 typedef util::forward_iterator_proxy<
153 string,const string&,const string* 152 string,const string&,const string*
154 > fields_iterator; 153 > fields_iterator;
155 154
156 basic_openid_message() { } 155 basic_openid_message() { }
157 basic_openid_message(const basic_openid_message& x); 156 basic_openid_message(const basic_openid_message& x);
158 157
159 virtual bool has_ns(const string& uri) const; 158 virtual bool has_ns(const string& uri) const;
160 virtual string get_ns(const string& uri) const; 159 virtual string get_ns(const string& uri) const;
161 160
162 virtual string append_query(const string& url,const char *pfx="openid.") const { 161 virtual string append_query(const string& url,const char *pfx="openid.") const {
163 return basic_message::append_query(url,pfx); } 162 return basic_message::append_query(url,pfx); }
164 virtual string query_string(const char *pfx="openid.") const { 163 virtual string query_string(const char *pfx="openid.") const {
165 return basic_message::query_string(pfx); } 164 return basic_message::query_string(pfx); }
166 165
167 virtual void from_keyvalues(const string& kv); 166 virtual void from_keyvalues(const string& kv);
168 virtual void to_keyvalues(ostream& o) const; 167 virtual void to_keyvalues(ostream& o) const;
169 168
170 virtual void to_htmlhiddens(ostream& o,const char* pfx=0) const; 169 virtual void to_htmlhiddens(ostream& o,const char* pfx=0) const;
171 170
172 void add_to_signed(const string& fields); 171 void add_to_signed(const string& fields);
173 string find_ns(const string& uri,const char *pfx) const; 172 string find_ns(const string& uri,const char *pfx) const;
174 string allocate_ns(const string& uri,const char *pfx); 173 string allocate_ns(const string& uri,const char *pfx);
175 }; 174 };
176 175
177 class openid_message_t : public basic_openid_message, public map<string,string> { 176 class openid_message_t : public basic_openid_message, public map<string,string> {
178 public: 177 public:
179 openid_message_t() { } 178 openid_message_t() { }
180 openid_message_t(const basic_openid_message& x) 179 openid_message_t(const basic_openid_message& x)
181 : basic_openid_message(x) { } 180 : basic_openid_message(x) { }
182 181
183 bool has_field(const string& n) const; 182 bool has_field(const string& n) const;
184 const string& get_field(const string& n) const; 183 const string& get_field(const string& n) const;
185 virtual fields_iterator fields_begin() const; 184 virtual fields_iterator fields_begin() const;
186 virtual fields_iterator fields_end() const; 185 virtual fields_iterator fields_end() const;
187 186
188 void reset_fields(); 187 void reset_fields();
189 void set_field(const string& n,const string& v); 188 void set_field(const string& n,const string& v);
190 void reset_field(const string& n); 189 void reset_field(const string& n);
191 }; 190 };
192 191
193 /** 192 /**
194 * request/response parameters map 193 * request/response parameters map
195 */ 194 */
196 class params_t : public openid_message_t { 195 class params_t : public openid_message_t {
197 public: 196 public:
198 197
199 /** 198 /**
200 * check whether the parameter is present. 199 * check whether the parameter is present.
201 * @param n the parameter name 200 * @param n the parameter name
202 * @return true if yes 201 * @return true if yes
203 */ 202 */
204 bool has_param(const string& n) const { 203 bool has_param(const string& n) const {
205 return has_field(n); } 204 return has_field(n); }
206 /** 205 /**
207 * retrieve the parameter (const version) 206 * retrieve the parameter (const version)
208 * @param n the parameter name 207 * @param n the parameter name
209 * @return the parameter value 208 * @return the parameter value
210 * @throw failed_lookup if there is no such parameter 209 * @throw failed_lookup if there is no such parameter
211 */ 210 */
212 const string& get_param(const string& n) const { 211 const string& get_param(const string& n) const {
213 return get_field(n); } 212 return get_field(n); }
214 213
215 /** 214 /**
216 * parse the OpenID key/value data. 215 * parse the OpenID key/value data.
217 * @param kv the OpenID key/value data 216 * @param kv the OpenID key/value data
218 */ 217 */
219 void parse_keyvalues(const string& kv) { 218 void parse_keyvalues(const string& kv) {
220 from_keyvalues(kv); } 219 from_keyvalues(kv); }
221 220
222 string append_query(const string& url,const char *prefix="openid.") const; 221 string append_query(const string& url,const char *prefix="openid.") const;
223 222
224 }; 223 };
225 224
226 struct openid_endpoint_t { 225 struct openid_endpoint_t {
227 string uri; 226 string uri;
228 string claimed_id; 227 string claimed_id;
229 string local_id; 228 string local_id;
230 229
231 openid_endpoint_t() { } 230 openid_endpoint_t() { }
232 openid_endpoint_t(const string& u,const string& cid,const string& lid) 231 openid_endpoint_t(const string& u,const string& cid,const string& lid)
233 : uri(u), claimed_id(cid), local_id(lid) { } 232 : uri(u), claimed_id(cid), local_id(lid) { }
234 233
235 bool operator==(const openid_endpoint_t& x) const { 234 bool operator==(const openid_endpoint_t& x) const {
236 return uri==x.uri && local_id==x.local_id; } 235 return uri==x.uri && local_id==x.local_id; }
237 bool operator<(const openid_endpoint_t& x) const { 236 bool operator<(const openid_endpoint_t& x) const {
238 int c; 237 int c;
239 return (c=strcmp(uri.c_str(),x.uri.c_str())) 238 return (c=strcmp(uri.c_str(),x.uri.c_str()))
240 ? (c<0) : (strcmp(local_id.c_str(),x.local_id.c_str())<0); } 239 ? (c<0) : (strcmp(local_id.c_str(),x.local_id.c_str())<0); }
241 }; 240 };
242 241
243 typedef util::output_iterator_proxy<openid_endpoint_t> 242 typedef util::output_iterator_proxy<openid_endpoint_t>
244 openid_endpoint_output_iterator; 243 openid_endpoint_output_iterator;
245 244
246} 245}
247 246
248#endif /* __OPKELE_TYPES_H */ 247#endif /* __OPKELE_TYPES_H */