summaryrefslogtreecommitdiffabout
path: root/include/opkele/types.h
authorMichael Krelin <hacker@klever.net>2007-12-09 17:22:06 (UTC)
committer Michael Krelin <hacker@klever.net>2007-12-09 22:08:24 (UTC)
commitc34adc6e274c3dbb63af99ca566000e7d218244c (patch) (unidiff)
tree705624c208deb4eaf8d07c119a883e6f4f35236e /include/opkele/types.h
parent60fdaff7888b455b4d07eadc905cefd20f1ddd3c (diff)
downloadlibopkele-c34adc6e274c3dbb63af99ca566000e7d218244c.zip
libopkele-c34adc6e274c3dbb63af99ca566000e7d218244c.tar.gz
libopkele-c34adc6e274c3dbb63af99ca566000e7d218244c.tar.bz2
reworked identity resolution and service discovery
The discovery, which does both XRDS-based (Yadis, XRI, for XRI, using proxy) and HTML-based search, now returns results in opkele:idiscovery_t structure. It uses expat-based parser idigger_t, which itself is not exposed via any header files, but hidden in lib/discovery.cc, the discovery testing program is renamed from openid_resolve to idiscover. Signed-off-by: Michael Krelin <hacker@klever.net>
Diffstat (limited to 'include/opkele/types.h') (more/less context) (ignore whitespace changes)
-rw-r--r--include/opkele/types.h63
1 files changed, 63 insertions, 0 deletions
diff --git a/include/opkele/types.h b/include/opkele/types.h
index f732a1e..520618d 100644
--- a/include/opkele/types.h
+++ b/include/opkele/types.h
@@ -11,6 +11,7 @@
11#include <string> 11#include <string>
12#include <map> 12#include <map>
13#include <memory> 13#include <memory>
14#include <set>
14 15
15namespace opkele { 16namespace opkele {
16 using std::vector; 17 using std::vector;
@@ -18,6 +19,8 @@ namespace opkele {
18 using std::map; 19 using std::map;
19 using std::ostream; 20 using std::ostream;
20 using std::auto_ptr; 21 using std::auto_ptr;
22 using std::multimap;
23 using std::set;
21 24
22 /** 25 /**
23 * the OpenID operation mode 26 * the OpenID operation mode
@@ -167,6 +170,66 @@ namespace opkele {
167 */ 170 */
168 ostream& operator << (ostream& o,const params_t& p); 171 ostream& operator << (ostream& o,const params_t& p);
169 172
173 namespace xrd {
174
175 struct priority_compare {
176 inline bool operator()(long a,long b) const {
177 return (a<0) ? false : (b<0) ? false : (a<b);
178 }
179 };
180
181 template <typename _DT>
182 class priority_map : public multimap<long,_DT,priority_compare> {
183 typedef multimap<long,_DT,priority_compare> map_type;
184 public:
185
186 inline _DT& add(long priority,const _DT& d) {
187 return insert(typename map_type::value_type(priority,d))->second;
188 }
189 };
190
191 typedef priority_map<string> canonical_ids_t;
192 typedef priority_map<string> local_ids_t;
193 typedef set<string> types_t;
194 typedef priority_map<string> uris_t;
195
196 class service_t {
197 public:
198 types_t types;
199 uris_t uris;
200 local_ids_t local_ids;
201
202 void clear() {
203 types.clear();
204 uris.clear(); local_ids.clear();
205 }
206 };
207 typedef priority_map<service_t> services_t;
208
209 class XRD_t {
210 public:
211 time_t expires;
212
213 canonical_ids_t canonical_ids;
214 local_ids_t local_ids;
215 services_t services;
216
217 void clear() {
218 expires = 0;
219 canonical_ids.clear(); local_ids.clear();
220 services.clear();
221 }
222 bool empty() const {
223 return
224 canonical_ids.empty()
225 && local_ids.empty()
226 && services.empty();
227 }
228
229 };
230
231 }
232
170} 233}
171 234
172#endif /* __OPKELE_TYPES_H */ 235#endif /* __OPKELE_TYPES_H */