summaryrefslogtreecommitdiffabout
path: root/include/opkele/types.h
Unidiff
Diffstat (limited to 'include/opkele/types.h') (more/less context) (show whitespace changes)
-rw-r--r--include/opkele/types.h92
1 files changed, 83 insertions, 9 deletions
diff --git a/include/opkele/types.h b/include/opkele/types.h
index f732a1e..de44a5c 100644
--- a/include/opkele/types.h
+++ b/include/opkele/types.h
@@ -12,3 +12,4 @@
12#include <map> 12#include <map>
13#include <memory> 13#include <set>
14#include <opkele/tr1-mem.h>
14 15
@@ -19,3 +20,4 @@ namespace opkele {
19 using std::ostream; 20 using std::ostream;
20 using std::auto_ptr; 21 using std::multimap;
22 using std::set;
21 23
@@ -39,12 +41,12 @@ namespace opkele {
39 * xor the secret and hmac together and encode, using base64 41 * xor the secret and hmac together and encode, using base64
40 * @param key_sha1 pointer to the sha1 digest 42 * @param key_d pointer to the message digest
41 * @param rv reference to the return value 43 * @param rv reference to the return value
42 */ 44 */
43 void enxor_to_base64(const unsigned char *key_sha1,string& rv) const; 45 void enxor_to_base64(const unsigned char *key_d,string& rv) const;
44 /** 46 /**
45 * decode base64-encoded secret and xor it with the sha1 digest 47 * decode base64-encoded secret and xor it with the message digest
46 * @param key_sha1 pointer to the message digest 48 * @param key_d pointer to the message digest
47 * @param b64 base64-encoded secret value 49 * @param b64 base64-encoded secret value
48 */ 50 */
49 void enxor_from_base64(const unsigned char *key_sha1,const string& b64); 51 void enxor_from_base64(const unsigned char *key_d,const string& b64);
50 /** 52 /**
@@ -107,5 +109,5 @@ namespace opkele {
107 /** 109 /**
108 * the auto_ptr<> for association_t object type 110 * the shared_ptr<> for association_t object type
109 */ 111 */
110 typedef auto_ptr<association_t> assoc_t; 112 typedef tr1mem::shared_ptr<association_t> assoc_t;
111 113
@@ -160,2 +162,10 @@ namespace opkele {
160 string append_query(const string& url,const char *prefix = "openid.") const; 162 string append_query(const string& url,const char *prefix = "openid.") const;
163
164 /**
165 * make up a query string suitable for use in GET and POST
166 * requests.
167 * @param prefix string to prened to parameter names
168 * @return query string
169 */
170 string query_string(const char *prefix = "openid.") const;
161 }; 171 };
@@ -169,2 +179,66 @@ namespace opkele {
169 179
180 namespace xrd {
181
182 struct priority_compare {
183 inline bool operator()(long a,long b) const {
184 return (a<0) ? false : (b<0) ? true : (a<b);
185 }
186 };
187
188 template <typename _DT>
189 class priority_map : public multimap<long,_DT,priority_compare> {
190 typedef multimap<long,_DT,priority_compare> map_type;
191 public:
192
193 inline _DT& add(long priority,const _DT& d) {
194 return insert(typename map_type::value_type(priority,d))->second;
195 }
196 };
197
198 typedef priority_map<string> canonical_ids_t;
199 typedef priority_map<string> local_ids_t;
200 typedef set<string> types_t;
201 typedef priority_map<string> uris_t;
202
203 class service_t {
204 public:
205 types_t types;
206 uris_t uris;
207 local_ids_t local_ids;
208 string provider_id;
209
210 void clear() {
211 types.clear();
212 uris.clear(); local_ids.clear();
213 provider_id.clear();
214 }
215 };
216 typedef priority_map<service_t> services_t;
217
218 class XRD_t {
219 public:
220 time_t expires;
221
222 canonical_ids_t canonical_ids;
223 local_ids_t local_ids;
224 services_t services;
225 string provider_id;
226
227 void clear() {
228 expires = 0;
229 canonical_ids.clear(); local_ids.clear();
230 services.clear();
231 provider_id.clear();
232 }
233 bool empty() const {
234 return
235 canonical_ids.empty()
236 && local_ids.empty()
237 && services.empty();
238 }
239
240 };
241
242 }
243
170} 244}