summaryrefslogtreecommitdiffabout
path: root/include
Unidiff
Diffstat (limited to 'include') (more/less context) (ignore whitespace changes)
-rw-r--r--include/Makefile.am8
-rw-r--r--include/opkele/.gitignore1
-rw-r--r--include/opkele/consumer.h6
-rw-r--r--include/opkele/curl.h24
-rw-r--r--include/opkele/debug.h17
-rw-r--r--include/opkele/discovery.h40
-rw-r--r--include/opkele/exception.h95
-rw-r--r--include/opkele/expat.h91
-rw-r--r--include/opkele/server.h4
-rw-r--r--include/opkele/tidy.h73
-rw-r--r--include/opkele/tr1-mem.h.in10
-rw-r--r--include/opkele/types.h92
-rw-r--r--include/opkele/uris.h18
13 files changed, 456 insertions, 23 deletions
diff --git a/include/Makefile.am b/include/Makefile.am
index b31786d..51dcea1 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -10,8 +10,12 @@ nobase_include_HEADERS = \
10 opkele/sreg.h \ 10 opkele/sreg.h \
11 opkele/extension_chain.h \ 11 opkele/extension_chain.h \
12 opkele/xconsumer.h \ 12 opkele/xconsumer.h \
13 opkele/xserver.h 13 opkele/xserver.h \
14 opkele/discovery.h \
15 opkele/uris.h \
16 opkele/tr1-mem.h
14EXTRA_DIST = \ 17EXTRA_DIST = \
15 opkele/data.h \ 18 opkele/data.h \
19 opkele/curl.h opkele/expat.h opkele/tidy.h \
16 opkele/util.h \ 20 opkele/util.h \
17 opkele/curl.h 21 opkele/debug.h
diff --git a/include/opkele/.gitignore b/include/opkele/.gitignore
index ffa24dc..dfc2d2c 100644
--- a/include/opkele/.gitignore
+++ b/include/opkele/.gitignore
@@ -1,2 +1,3 @@
1acconfig.h 1acconfig.h
2tr1-mem.h
2stamp-h2 3stamp-h2
diff --git a/include/opkele/consumer.h b/include/opkele/consumer.h
index c463787..3c1d318 100644
--- a/include/opkele/consumer.h
+++ b/include/opkele/consumer.h
@@ -31,7 +31,7 @@ namespace opkele {
31 * @param handle association handle 31 * @param handle association handle
32 * @param secret the secret associated with the server and handle 32 * @param secret the secret associated with the server and handle
33 * @param expires_in the number of seconds until the handle is expired 33 * @param expires_in the number of seconds until the handle is expired
34 * @return the auto_ptr<> for the newly allocated association_t object 34 * @return the assoc_t for the newly allocated association_t object
35 */ 35 */
36 virtual assoc_t store_assoc(const string& server,const string& handle,const secret_t& secret,int expires_in) = 0; 36 virtual assoc_t store_assoc(const string& server,const string& handle,const secret_t& secret,int expires_in) = 0;
37 /** 37 /**
@@ -73,7 +73,7 @@ namespace opkele {
73 * middle of negotiations. 73 * middle of negotiations.
74 * 74 *
75 * @param server the OpenID server 75 * @param server the OpenID server
76 * @return the auto_ptr<> for the newly allocated association_t object 76 * @return the assoc_t for the newly allocated association_t object
77 * @throw failed_lookup in case of absence of the handle 77 * @throw failed_lookup in case of absence of the handle
78 */ 78 */
79 virtual assoc_t find_assoc(const string& server); 79 virtual assoc_t find_assoc(const string& server);
@@ -93,7 +93,7 @@ namespace opkele {
93 /** 93 /**
94 * perform the associate request to OpenID server. 94 * perform the associate request to OpenID server.
95 * @param server the OpenID server 95 * @param server the OpenID server
96 * @return the auto_ptr<> for the newly allocated association_t 96 * @return the assoc_t for the newly allocated association_t
97 * object, representing established association 97 * object, representing established association
98 * @throw exception in case of error 98 * @throw exception in case of error
99 */ 99 */
diff --git a/include/opkele/curl.h b/include/opkele/curl.h
index 8020b63..5cf8e48 100644
--- a/include/opkele/curl.h
+++ b/include/opkele/curl.h
@@ -2,9 +2,13 @@
2#define __OPKELE_CURL_H 2#define __OPKELE_CURL_H
3 3
4#include <cassert> 4#include <cassert>
5#include <string>
6#include <algorithm>
5#include <curl/curl.h> 7#include <curl/curl.h>
6 8
7namespace opkele { 9namespace opkele {
10 using std::min;
11 using std::string;
8 12
9 namespace util { 13 namespace util {
10 14
@@ -41,6 +45,26 @@ namespace opkele {
41 CURLcode set_header(); 45 CURLcode set_header();
42 }; 46 };
43 47
48 template<int lim>
49 class curl_fetch_string_t : public curl_t {
50 public:
51 curl_fetch_string_t(CURL *c)
52 : curl_t(c) { }
53 ~curl_fetch_string_t() throw() { }
54
55 string response;
56
57 size_t write(void *p,size_t size,size_t nmemb) {
58 size_t bytes = size*nmemb;
59 size_t get = min(lim-response.length(),bytes);
60 response.append((const char *)p,get);
61 return get;
62 }
63 };
64
65 typedef curl_fetch_string_t<16384> curl_pick_t;
66
67
44 } 68 }
45 69
46} 70}
diff --git a/include/opkele/debug.h b/include/opkele/debug.h
new file mode 100644
index 0000000..a02f8d4
--- a/dev/null
+++ b/include/opkele/debug.h
@@ -0,0 +1,17 @@
1#ifndef __OPKELE_DEBUG_H
2#define __OPKELE_DEBUG_H
3
4#ifdef NDEBUG
5
6 #define D_(x) ((void)0)
7 #define DOUT_(x)((void)0)
8
9#else /* NDEBUG */
10
11 #define D_(x) x
12#include <iostream>
13 #define DOUT_(x)std::clog << x << std::endl
14
15#endif /* NDEBUG */
16
17#endif /* __OPKELE_DEBUG_H */
diff --git a/include/opkele/discovery.h b/include/opkele/discovery.h
new file mode 100644
index 0000000..af4aa29
--- a/dev/null
+++ b/include/opkele/discovery.h
@@ -0,0 +1,40 @@
1#ifndef __OPKELE_DISCOVERY_H
2#define __OPKELE_DISCOVERY_H
3
4#include <string>
5#include <opkele/types.h>
6
7namespace opkele {
8 using std::string;
9
10 struct idiscovery_t;
11
12 void idiscover(idiscovery_t& result,const string& identity);
13
14 struct idiscovery_t {
15 bool xri_identity;
16 string normalized_id;
17 string canonicalized_id;
18 xrd::XRD_t xrd;
19
20 idiscovery_t() { }
21 idiscovery_t(const string& i) {
22 idiscover(*this,i);
23 }
24 idiscovery_t(const char *i) {
25 idiscover(*this,i);
26 }
27
28 void clear() {
29 normalized_id.clear(); canonicalized_id.clear();
30 xrd.clear();
31 }
32
33 idiscovery_t& operator=(const string& i) {
34 idiscover(*this,i); return *this; }
35 idiscovery_t& operator=(const char *i) {
36 idiscover(*this,i); return *this; }
37 };
38}
39
40#endif /* __OPKELE_DISCOVERY_H */
diff --git a/include/opkele/exception.h b/include/opkele/exception.h
index 2ff44b7..a8c3339 100644
--- a/include/opkele/exception.h
+++ b/include/opkele/exception.h
@@ -24,9 +24,13 @@
24 */ 24 */
25# define OPKELE_CP_ CODEPOINT, 25# define OPKELE_CP_ CODEPOINT,
26/** 26/**
27 * open function-try-block
28 */
29# define OPKELE_FUNC_TRY try
30/**
27 * the simple rethrow of konforka-based exception 31 * the simple rethrow of konforka-based exception
28 */ 32 */
29# define OPKELE_RETHROW catch(konforka::exception& e) { e.see(CODEPOINT); throw } 33# define OPKELE_RETHROW catch(konforka::exception& e) { e.see(CODEPOINT); throw; }
30#else /* OPKELE_HAVE_KONFORKA */ 34#else /* OPKELE_HAVE_KONFORKA */
31# include <exception> 35# include <exception>
32# include <string> 36# include <string>
@@ -44,6 +48,10 @@
44 */ 48 */
45# define OPKELE_CP_ 49# define OPKELE_CP_
46/** 50/**
51 * the dummy define for the opening function-try-block
52 */
53# define OPKELE_FUNC_TRY
54/**
47 * the dummy define for the konforka-based rethrow of exception 55 * the dummy define for the konforka-based rethrow of exception
48 */ 56 */
49# define OPKELE_RETHROW 57# define OPKELE_RETHROW
@@ -69,13 +77,10 @@ namespace opkele {
69 public: 77 public:
70# ifdef OPKELE_HAVE_KONFORKA 78# ifdef OPKELE_HAVE_KONFORKA
71 explicit 79 explicit
72 exception(const string& fi,const string& fu,int l,const string& w) 80 exception(const string& fi,const string& fu,int l,const string& w);
73 : konforka::exception(fi,fu,l,w) { }
74# else /* OPKELE_HAVE_KONFORKA */ 81# else /* OPKELE_HAVE_KONFORKA */
75 string _what; 82 string _what;
76 explicit 83 explicit exception(const string& w);
77 exception(const string& w)
78 : _what(w) { }
79 virtual ~exception() throw(); 84 virtual ~exception() throw();
80 virtual const char * what() const throw(); 85 virtual const char * what() const throw();
81# endif /* OPKELE_HAVE_KONFORKA */ 86# endif /* OPKELE_HAVE_KONFORKA */
@@ -156,7 +161,7 @@ namespace opkele {
156 class id_res_setup : public id_res_failed { 161 class id_res_setup : public id_res_failed {
157 public: 162 public:
158 string setup_url; 163 string setup_url;
159 id_res_setup(OPKELE_E_PARS,const string& su) 164 id_res_setup(OPKELE_E_PARS,const string& su="")
160 : id_res_failed(OPKELE_E_CONS), setup_url(su) { } 165 : id_res_failed(OPKELE_E_CONS), setup_url(su) { }
161 ~id_res_setup() throw() { } 166 ~id_res_setup() throw() { }
162 }; 167 };
@@ -179,6 +184,42 @@ namespace opkele {
179 }; 184 };
180 185
181 /** 186 /**
187 * thown when the user cancelled authentication process.
188 */
189 class id_res_cancel : public id_res_failed {
190 public:
191 id_res_cancel(OPKELE_E_PARS)
192 : id_res_failed(OPKELE_E_CONS) { }
193 };
194
195 /**
196 * thrown in case of nonce reuse or otherwise imperfect nonce.
197 */
198 class id_res_bad_nonce : public id_res_failed {
199 public:
200 id_res_bad_nonce(OPKELE_E_PARS)
201 : id_res_failed(OPKELE_E_CONS) { }
202 };
203
204 /**
205 * thrown if return_to didn't pass verification
206 */
207 class id_res_bad_return_to : public id_res_failed {
208 public:
209 id_res_bad_return_to(OPKELE_E_PARS)
210 : id_res_failed(OPKELE_E_CONS) { }
211 };
212
213 /**
214 * thrown if OP isn't authorized to make an assertion
215 */
216 class id_res_unauthorized : public id_res_failed {
217 public:
218 id_res_unauthorized(OPKELE_E_PARS)
219 : id_res_failed(OPKELE_E_CONS) { }
220 };
221
222 /**
182 * openssl malfunction occured 223 * openssl malfunction occured
183 */ 224 */
184 class exception_openssl : public exception { 225 class exception_openssl : public exception {
@@ -212,6 +253,36 @@ namespace opkele {
212 }; 253 };
213 254
214 /** 255 /**
256 * htmltidy related error occured
257 */
258 class exception_tidy : public exception {
259 public:
260 int _rc;
261 exception_tidy(OPKELE_E_PARS);
262 exception_tidy(OPKELE_E_PARS,int r);
263 ~exception_tidy() throw() { }
264 };
265
266 /**
267 * exception thrown in case of failed discovery
268 */
269 class failed_discovery : public exception {
270 public:
271 failed_discovery(OPKELE_E_PARS)
272 : exception(OPKELE_E_CONS) { }
273 };
274
275 /**
276 * unsuccessfull xri resolution
277 */
278 class failed_xri_resolution : public failed_discovery {
279 public:
280 long _code;
281 failed_xri_resolution(OPKELE_E_PARS,long _c=-1)
282 : failed_discovery(OPKELE_E_CONS), _code(_c) { }
283 };
284
285 /**
215 * not implemented (think pure virtual) member function executed, signfies 286 * not implemented (think pure virtual) member function executed, signfies
216 * programmer error 287 * programmer error
217 */ 288 */
@@ -230,6 +301,16 @@ namespace opkele {
230 : exception(OPKELE_E_CONS) { } 301 : exception(OPKELE_E_CONS) { }
231 }; 302 };
232 303
304 /**
305 * thrown in case of unsupported parameter encountered (e.g. unsupported
306 * association type).
307 */
308 class unsupported : public exception {
309 public:
310 unsupported(OPKELE_E_PARS)
311 : exception(OPKELE_E_CONS) { }
312 };
313
233} 314}
234 315
235#endif /* __OPKELE_EXCEPTION_H */ 316#endif /* __OPKELE_EXCEPTION_H */
diff --git a/include/opkele/expat.h b/include/opkele/expat.h
new file mode 100644
index 0000000..60c41ac
--- a/dev/null
+++ b/include/opkele/expat.h
@@ -0,0 +1,91 @@
1#ifndef __OPKELE_EXPAT_H
2#define __OPKELE_EXPAT_H
3
4#include <cassert>
5#include <expat.h>
6
7namespace opkele {
8
9 namespace util {
10
11 class expat_t {
12 public:
13 XML_Parser _x;
14
15 expat_t() : _x(0) { }
16 expat_t(XML_Parser x) : _x(x) { }
17 virtual ~expat_t() throw();
18
19 expat_t& operator=(XML_Parser x);
20
21 operator const XML_Parser(void) const { return _x; }
22 operator XML_Parser(void) { return _x; }
23
24 inline bool parse(const char *s,int len,bool final=false) {
25 assert(_x);
26 return XML_Parse(_x,s,len,final);
27 }
28
29 virtual void start_element(const XML_Char *n,const XML_Char **a) { }
30 virtual void end_element(const XML_Char *n) { }
31 void set_element_handler();
32
33 virtual void character_data(const XML_Char *s,int l) { }
34 void set_character_data_handler();
35
36 virtual void processing_instruction(const XML_Char *t,const XML_Char *d) { }
37 void set_processing_instruction_handler();
38
39 virtual void comment(const XML_Char *d) { }
40 void set_comment_handler();
41
42 virtual void start_cdata_section() { }
43 virtual void end_cdata_section() { }
44 void set_cdata_section_handler();
45
46 virtual void default_handler(const XML_Char *s,int l) { }
47 void set_default_handler();
48 void set_default_handler_expand();
49
50 virtual void start_namespace_decl(const XML_Char *p,const XML_Char *u) { }
51 virtual void end_namespace_decl(const XML_Char *p) { }
52 void set_namespace_decl_handler();
53
54 inline enum XML_Error get_error_code() {
55 assert(_x); return XML_GetErrorCode(_x); }
56 static inline const XML_LChar *error_string(XML_Error c) {
57 return XML_ErrorString(c); }
58
59 inline long get_current_byte_index() {
60 assert(_x); return XML_GetCurrentByteIndex(_x); }
61 inline int get_current_line_number() {
62 assert(_x); return XML_GetCurrentLineNumber(_x); }
63 inline int get_current_column_number() {
64 assert(_x); return XML_GetCurrentColumnNumber(_x); }
65
66 inline void set_user_data() {
67 assert(_x); XML_SetUserData(_x,this); }
68
69 inline bool set_base(const XML_Char *b) {
70 assert(_x); return XML_SetBase(_x,b); }
71 inline const XML_Char *get_base() {
72 assert(_x); return XML_GetBase(_x); }
73
74 inline int get_specified_attribute_count() {
75 assert(_x); return XML_GetSpecifiedAttributeCount(_x); }
76
77 inline bool set_param_entity_parsing(enum XML_ParamEntityParsing c) {
78 assert(_x); return XML_SetParamEntityParsing(_x,c); }
79
80 inline static XML_Parser parser_create(const XML_Char *e=0) {
81 return XML_ParserCreate(e); }
82 inline static XML_Parser parser_create_ns(const XML_Char *e=0,XML_Char s='\t') {
83 return XML_ParserCreateNS(e,s); }
84
85 };
86
87 }
88
89}
90
91#endif /* __OPKELE_EXPAT_H */
diff --git a/include/opkele/server.h b/include/opkele/server.h
index dd7fc41..3c25646 100644
--- a/include/opkele/server.h
+++ b/include/opkele/server.h
@@ -25,7 +25,7 @@ namespace opkele {
25 * store. 25 * store.
26 * @param mode the mode of request being processed to base the 26 * @param mode the mode of request being processed to base the
27 * statelessness of the association upon 27 * statelessness of the association upon
28 * @return the auto_ptr<> for the newly allocated association_t object 28 * @return the assoc_t for the newly allocated association_t object
29 */ 29 */
30 virtual assoc_t alloc_assoc(mode_t mode) = 0; 30 virtual assoc_t alloc_assoc(mode_t mode) = 0;
31 /** 31 /**
@@ -33,7 +33,7 @@ namespace opkele {
33 * the reqal implementation to provide persistent assocations 33 * the reqal implementation to provide persistent assocations
34 * store. 34 * store.
35 * @param h association handle 35 * @param h association handle
36 * @return the auto_ptr<> for the newly allocated association_t object 36 * @return the assoc_t for the newly allocated association_t object
37 * @throw failed_lookup in case of failure 37 * @throw failed_lookup in case of failure
38 */ 38 */
39 virtual assoc_t retrieve_assoc(const string& h) = 0; 39 virtual assoc_t retrieve_assoc(const string& h) = 0;
diff --git a/include/opkele/tidy.h b/include/opkele/tidy.h
new file mode 100644
index 0000000..888e7d4
--- a/dev/null
+++ b/include/opkele/tidy.h
@@ -0,0 +1,73 @@
1#ifndef __OPKELE_TIDY_H
2#define __OPKELE_TIDY_H
3
4#include <cassert>
5#include <tidy.h>
6#include <buffio.h>
7
8namespace opkele {
9 namespace util {
10
11 class tidy_buf_t {
12 public:
13 TidyBuffer _x;
14
15 tidy_buf_t() { tidyBufInit(&_x); }
16 virtual ~tidy_buf_t() throw() {
17 tidyBufFree(&_x); }
18
19 inline operator const TidyBuffer&(void) const { return _x; }
20 inline operator TidyBuffer&(void) { return _x; }
21
22 inline operator const char*(void) const { return (const char*)_x.bp; }
23 inline operator char*(void) { return (char*)_x.bp; }
24
25 inline const char *c_str() const {
26 return (const char*)_x.bp; }
27 inline size_t size() const {
28 return _x.size; }
29 };
30
31 class tidy_doc_t {
32 public:
33 TidyDoc _x;
34
35 tidy_doc_t() : _x(0) { }
36 tidy_doc_t(TidyDoc x) : _x(x) { }
37 virtual ~tidy_doc_t() throw() {
38 if(_x) tidyRelease(_x); }
39
40 tidy_doc_t& operator=(TidyDoc x) {
41 if(_x) tidyRelease(_x);
42 _x = x;
43 return *this;
44 }
45
46 operator const TidyDoc(void) const { return _x; }
47 operator TidyDoc(void) { return _x; }
48
49 inline bool opt_set(TidyOptionId o,bool v) {
50 assert(_x);
51 return tidyOptSetBool(_x,o,v?yes:no); }
52 inline bool opt_set(TidyOptionId o,int v) {
53 assert(_x);
54 return tidyOptSetInt(_x,o,v); }
55
56 inline int parse_string(const string& s) {
57 assert(_x);
58 return tidyParseString(_x,s.c_str()); }
59 inline int clean_and_repair() {
60 assert(_x);
61 return tidyCleanAndRepair(_x); }
62 inline int save_buffer(TidyBuffer& ob) {
63 assert(_x);
64 return tidySaveBuffer(_x,&ob); }
65
66 static inline TidyDoc create() {
67 return tidyCreate(); }
68 };
69
70 }
71}
72
73#endif /* __OPKELE_TIDY_H */
diff --git a/include/opkele/tr1-mem.h.in b/include/opkele/tr1-mem.h.in
new file mode 100644
index 0000000..e9ccf0b
--- a/dev/null
+++ b/include/opkele/tr1-mem.h.in
@@ -0,0 +1,10 @@
1#ifndef __OPKELE_TR1_MEM_H
2#define __OPKELE_TR1_MEM_H
3
4#include <@OPKELE_TR1_MEM_HEADER@>
5
6namespace opkele {
7 namespace tr1mem = @OPKELE_TR1_MEM_NS@;
8}
9
10#endif /* __OPKELE_TR1_MEM_H */
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
@@ -10,14 +10,16 @@
10#include <vector> 10#include <vector>
11#include <string> 11#include <string>
12#include <map> 12#include <map>
13#include <memory> 13#include <set>
14#include <opkele/tr1-mem.h>
14 15
15namespace opkele { 16namespace opkele {
16 using std::vector; 17 using std::vector;
17 using std::string; 18 using std::string;
18 using std::map; 19 using std::map;
19 using std::ostream; 20 using std::ostream;
20 using std::auto_ptr; 21 using std::multimap;
22 using std::set;
21 23
22 /** 24 /**
23 * the OpenID operation mode 25 * the OpenID operation mode
@@ -37,16 +39,16 @@ namespace opkele {
37 39
38 /** 40 /**
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 /**
51 * plainly encode to base64 representation 53 * plainly encode to base64 representation
52 * @param rv reference to the return value 54 * @param rv reference to the return value
@@ -105,9 +107,9 @@ namespace opkele {
105 }; 107 };
106 108
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
112 /** 114 /**
113 * request/response parameters map 115 * request/response parameters map
@@ -158,6 +160,14 @@ namespace opkele {
158 * @return the ready-to-use location 160 * @return the ready-to-use location
159 */ 161 */
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 };
162 172
163 /** 173 /**
@@ -167,6 +177,70 @@ namespace opkele {
167 */ 177 */
168 ostream& operator << (ostream& o,const params_t& p); 178 ostream& operator << (ostream& o,const params_t& p);
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}
171 245
172#endif /* __OPKELE_TYPES_H */ 246#endif /* __OPKELE_TYPES_H */
diff --git a/include/opkele/uris.h b/include/opkele/uris.h
new file mode 100644
index 0000000..56c2d6d
--- a/dev/null
+++ b/include/opkele/uris.h
@@ -0,0 +1,18 @@
1#ifndef __OPKELE_URIS_H
2#define __OPKELE_URIS_H
3
4 #define NSURI_XRDS "xri://$xrds"
5 #define NSURI_XRD "xri://$xrd*($v*2.0)"
6 #define NSURI_OPENID10 "http://openid.net/xmlns/1.0"
7
8 #define OIURI_OPENID20 "http://specs.openid.net/auth/2.0"
9 #define OIURI_SREG11 "http://openid.net/extensions/sreg/1.1"
10
11 #define STURI_OPENID10 "http://openid.net/signon/1.0"
12 #define STURI_OPENID11 "http://openid.net/signon/1.1"
13 #define STURI_OPENID20 "http://specs.openid.net/auth/2.0/signon"
14 #define STURI_OPENID20_OP"http://specs.openid.net/auth/2.0/server"
15
16 #define IDURI_SELECT20 "http://specs.openid.net/auth/2.0/identifier_select"
17
18#endif /* __OPKELE_URIS_H */