summaryrefslogtreecommitdiffabout
authorMichael Krelin <hacker@klever.net>2008-02-03 15:28:30 (UTC)
committer Michael Krelin <hacker@klever.net>2008-02-03 15:28:30 (UTC)
commitd1c45af16b3bd31f65d03eec0fcd1c61b4d69fb0 (patch) (unidiff)
tree34fc1389a138a2c33ccfceb595379a16a0139768
parent5f742d37f78d626e0140632b28b072f892fd98c3 (diff)
downloadlibopkele-d1c45af16b3bd31f65d03eec0fcd1c61b4d69fb0.zip
libopkele-d1c45af16b3bd31f65d03eec0fcd1c61b4d69fb0.tar.gz
libopkele-d1c45af16b3bd31f65d03eec0fcd1c61b4d69fb0.tar.bz2
moved openid_endpoint_t to types.h
Signed-off-by: Michael Krelin <hacker@klever.net>
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--include/opkele/basic_rp.h18
-rw-r--r--include/opkele/types.h18
2 files changed, 18 insertions, 18 deletions
diff --git a/include/opkele/basic_rp.h b/include/opkele/basic_rp.h
index 3f17fd9..d5356aa 100644
--- a/include/opkele/basic_rp.h
+++ b/include/opkele/basic_rp.h
@@ -1,218 +1,200 @@
1#ifndef __OPKELE_BASIC_RP_H 1#ifndef __OPKELE_BASIC_RP_H
2#define __OPKELE_BASIC_RP_H 2#define __OPKELE_BASIC_RP_H
3 3
4#include <cstring>
5#include <string> 4#include <string>
6#include <opkele/types.h> 5#include <opkele/types.h>
7#include <opkele/extension.h> 6#include <opkele/extension.h>
8 7
9namespace opkele { 8namespace opkele {
10 using std::string; 9 using std::string;
11 10
12 struct openid_endpoint_t {
13 string uri;
14 string claimed_id;
15 string local_id;
16
17 openid_endpoint_t() { }
18 openid_endpoint_t(const string& u,const string& cid,const string& lid)
19 : uri(u), claimed_id(cid), local_id(lid) { }
20
21 bool operator==(const openid_endpoint_t& x) const {
22 return uri==x.uri && local_id==x.local_id; }
23 bool operator<(const openid_endpoint_t& x) const {
24 int c;
25 return (c=strcmp(uri.c_str(),x.uri.c_str()))
26 ? (c<0) : (strcmp(local_id.c_str(),x.local_id.c_str())<0); }
27 };
28
29 class basic_RP { 11 class basic_RP {
30 public: 12 public:
31 13
32 virtual ~basic_RP() { } 14 virtual ~basic_RP() { }
33 15
34 /** 16 /**
35 * @name Global persistent store API 17 * @name Global persistent store API
36 * These are functions related to the associations with OP storage 18 * These are functions related to the associations with OP storage
37 * and retrieval and nonce records. They provide an interface to 19 * and retrieval and nonce records. They provide an interface to
38 * the persistent storage which is shared by all sessions. If the 20 * the persistent storage which is shared by all sessions. If the
39 * implementor prefers the dumb mode instead, the function should 21 * implementor prefers the dumb mode instead, the function should
40 * throw dumb_RP exception instead. 22 * throw dumb_RP exception instead.
41 * @see opkele::dumb_RP 23 * @see opkele::dumb_RP
42 * @{ 24 * @{
43 */ 25 */
44 /** 26 /**
45 * Store association and return allocated association object. 27 * Store association and return allocated association object.
46 * @param OP OP endpoint 28 * @param OP OP endpoint
47 * @param handle association handle 29 * @param handle association handle
48 * @param type association type 30 * @param type association type
49 * @param secret association secret 31 * @param secret association secret
50 * @params expires_in the number of seconds association expires in 32 * @params expires_in the number of seconds association expires in
51 * @return the association object 33 * @return the association object
52 * @throw dumb_RP for dumb RP 34 * @throw dumb_RP for dumb RP
53 */ 35 */
54 virtual assoc_t store_assoc( 36 virtual assoc_t store_assoc(
55 const string& OP,const string& handle, 37 const string& OP,const string& handle,
56 const string& type,const secret_t& secret, 38 const string& type,const secret_t& secret,
57 int expires_in) = 0; 39 int expires_in) = 0;
58 /** 40 /**
59 * Find valid unexpired association with an OP. 41 * Find valid unexpired association with an OP.
60 * @param OP OP endpoint URL 42 * @param OP OP endpoint URL
61 * @return association found 43 * @return association found
62 * @throw failed_lookup if no association found 44 * @throw failed_lookup if no association found
63 * @throw dumb_RP for dumb RP 45 * @throw dumb_RP for dumb RP
64 */ 46 */
65 virtual assoc_t find_assoc( 47 virtual assoc_t find_assoc(
66 const string& OP) = 0; 48 const string& OP) = 0;
67 /** 49 /**
68 * Retrieve valid association handle for an OP by handle. 50 * Retrieve valid association handle for an OP by handle.
69 * @param OP OP endpoint URL 51 * @param OP OP endpoint URL
70 * @param handle association handle 52 * @param handle association handle
71 * @return association found 53 * @return association found
72 * @throw failed_lookup if no association found 54 * @throw failed_lookup if no association found
73 * @throw dumb_RP for dumb RP 55 * @throw dumb_RP for dumb RP
74 */ 56 */
75 virtual assoc_t retrieve_assoc( 57 virtual assoc_t retrieve_assoc(
76 const string& OP,const string& handle) = 0; 58 const string& OP,const string& handle) = 0;
77 /** 59 /**
78 * Invalidate association with OP 60 * Invalidate association with OP
79 * @param OP OP endpoint URL 61 * @param OP OP endpoint URL
80 * @param handle association handle 62 * @param handle association handle
81 * @throw dumb_RP for dumb RP 63 * @throw dumb_RP for dumb RP
82 */ 64 */
83 virtual void invalidate_assoc(const string& OP,const string& handle) = 0; 65 virtual void invalidate_assoc(const string& OP,const string& handle) = 0;
84 66
85 /** 67 /**
86 * Check the nonce validity. That is, check that we haven't 68 * Check the nonce validity. That is, check that we haven't
87 * accepted request with this nonce from this OP, yet. May involve 69 * accepted request with this nonce from this OP, yet. May involve
88 * cutting off by the timestamp and checking the rest against the 70 * cutting off by the timestamp and checking the rest against the
89 * store of seen nonces. 71 * store of seen nonces.
90 * @param OP OP endpoint URL 72 * @param OP OP endpoint URL
91 * @param nonce nonce value 73 * @param nonce nonce value
92 * @throw id_res_bad_nonce if the nonce is not to be accepted, i.e. 74 * @throw id_res_bad_nonce if the nonce is not to be accepted, i.e.
93 * either too old or seen. 75 * either too old or seen.
94 */ 76 */
95 virtual void check_nonce(const string& OP,const string& nonce) = 0; 77 virtual void check_nonce(const string& OP,const string& nonce) = 0;
96 /** 78 /**
97 * @} 79 * @}
98 */ 80 */
99 81
100 /** 82 /**
101 * @name Session persistent store API 83 * @name Session persistent store API
102 * @{ 84 * @{
103 */ 85 */
104 /** 86 /**
105 * Retrieve OpenID endpoint being currently used for 87 * Retrieve OpenID endpoint being currently used for
106 * authentication. If there is no endpoint available, throw a 88 * authentication. If there is no endpoint available, throw a
107 * no_endpoint exception. 89 * no_endpoint exception.
108 * @return reference to the service endpoint object 90 * @return reference to the service endpoint object
109 * @see next_endpoint 91 * @see next_endpoint
110 * @throw no_endpoint if no endpoint available 92 * @throw no_endpoint if no endpoint available
111 */ 93 */
112 virtual const openid_endpoint_t& get_endpoint() const = 0; 94 virtual const openid_endpoint_t& get_endpoint() const = 0;
113 /** 95 /**
114 * Advance to the next endpoint to try. 96 * Advance to the next endpoint to try.
115 * @see get_endpoint() 97 * @see get_endpoint()
116 * @throw no_endpoint if there are no more endpoints 98 * @throw no_endpoint if there are no more endpoints
117 */ 99 */
118 virtual void next_endpoint() = 0; 100 virtual void next_endpoint() = 0;
119 /** 101 /**
120 * @} 102 * @}
121 */ 103 */
122 104
123 /** 105 /**
124 * @name Site particulars API 106 * @name Site particulars API
125 * @{ 107 * @{
126 */ 108 */
127 /** 109 /**
128 * Return an absolute URL of the page being processed, includining 110 * Return an absolute URL of the page being processed, includining
129 * query parameters. It is used to validate return_to URL on 111 * query parameters. It is used to validate return_to URL on
130 * positive assertions. 112 * positive assertions.
131 * @return fully qualified url of the page being processed. 113 * @return fully qualified url of the page being processed.
132 */ 114 */
133 virtual const string get_this_url() const = 0; 115 virtual const string get_this_url() const = 0;
134 /** 116 /**
135 * @} 117 * @}
136 */ 118 */
137 119
138 /** 120 /**
139 * @name OpenID actions 121 * @name OpenID actions
140 * @{ 122 * @{
141 */ 123 */
142 /** 124 /**
143 * Initiates authentication session, doing discovery, normalization 125 * Initiates authentication session, doing discovery, normalization
144 * and whatever implementor wants to do at this point. 126 * and whatever implementor wants to do at this point.
145 * @param usi User-supplied identity 127 * @param usi User-supplied identity
146 */ 128 */
147 virtual void initiate(const string& usi) = 0; 129 virtual void initiate(const string& usi) = 0;
148 /** 130 /**
149 * Prepare checkid_request. 131 * Prepare checkid_request.
150 * @param rv reference to the openid message to prepare 132 * @param rv reference to the openid message to prepare
151 * @param mode checkid_setup or checkid_immediate 133 * @param mode checkid_setup or checkid_immediate
152 * @param return_to the URL OP should redirect to after completion 134 * @param return_to the URL OP should redirect to after completion
153 * @param realm authentication realm to pass to OP 135 * @param realm authentication realm to pass to OP
154 * @param ext pointer to extension to use in request preparation 136 * @param ext pointer to extension to use in request preparation
155 * @return reference to the openid message 137 * @return reference to the openid message
156 */ 138 */
157 basic_openid_message& checkid_( 139 basic_openid_message& checkid_(
158 basic_openid_message& rv, 140 basic_openid_message& rv,
159 mode_t mode, 141 mode_t mode,
160 const string& return_to,const string& realm, 142 const string& return_to,const string& realm,
161 extension_t *ext=0); 143 extension_t *ext=0);
162 /** 144 /**
163 * Verify assertion at the end of round-trip. 145 * Verify assertion at the end of round-trip.
164 * @param om incoming openid message 146 * @param om incoming openid message
165 * @param ext pointer to extention to use in parsing assertion 147 * @param ext pointer to extention to use in parsing assertion
166 * @throw id_res_setup if checkid_immediate request could not be 148 * @throw id_res_setup if checkid_immediate request could not be
167 * completed 149 * completed
168 * @throw id_res_cancel if authentication request was canceled 150 * @throw id_res_cancel if authentication request was canceled
169 * @throw id_res_mismatch in case of signature mismatch 151 * @throw id_res_mismatch in case of signature mismatch
170 * @throw id_res_bad_return_to if return_to url seems to be 152 * @throw id_res_bad_return_to if return_to url seems to be
171 * tampered with 153 * tampered with
172 * @throw id_res_unauthorized if OP is not authorized to make 154 * @throw id_res_unauthorized if OP is not authorized to make
173 * assertions regarding the identity 155 * assertions regarding the identity
174 */ 156 */
175 void id_res(const basic_openid_message& om,extension_t *ext=0); 157 void id_res(const basic_openid_message& om,extension_t *ext=0);
176 158
177 /** 159 /**
178 * Establish association with OP 160 * Establish association with OP
179 * @param OP OP to establish association with 161 * @param OP OP to establish association with
180 * @throw dumb_RP if for a dumb RP 162 * @throw dumb_RP if for a dumb RP
181 */ 163 */
182 virtual assoc_t associate(const string& OP); 164 virtual assoc_t associate(const string& OP);
183 /** 165 /**
184 * Check authentication with OP and invalidate handle if requested 166 * Check authentication with OP and invalidate handle if requested
185 * and confirmed 167 * and confirmed
186 * @param OP OP to check with 168 * @param OP OP to check with
187 * @param om message to check 169 * @param om message to check
188 * @throw failed_check_authentication if OP fails to confirm 170 * @throw failed_check_authentication if OP fails to confirm
189 * authenticity of the assertion 171 * authenticity of the assertion
190 */ 172 */
191 void check_authentication(const string& OP,const basic_openid_message& om); 173 void check_authentication(const string& OP,const basic_openid_message& om);
192 /** 174 /**
193 * @} 175 * @}
194 */ 176 */
195 177
196 /** 178 /**
197 * @name Miscellanea 179 * @name Miscellanea
198 * @{ 180 * @{
199 */ 181 */
200 /** 182 /**
201 * Verify OP authority. Return normally if OP is authorized to make 183 * Verify OP authority. Return normally if OP is authorized to make
202 * an assertion, throw an exception otherwise. 184 * an assertion, throw an exception otherwise.
203 * @param OP OP endpoint 185 * @param OP OP endpoint
204 * @param claimed_id claimed identity 186 * @param claimed_id claimed identity
205 * @param identity OP-Local identifier 187 * @param identity OP-Local identifier
206 * @throw id_res_unauthorized if OP is not authorized to make 188 * @throw id_res_unauthorized if OP is not authorized to make
207 * assertion regarding this identity. 189 * assertion regarding this identity.
208 */ 190 */
209 virtual void verify_OP(const string& OP, 191 virtual void verify_OP(const string& OP,
210 const string& claimed_id,const string& identity) const = 0; 192 const string& claimed_id,const string& identity) const = 0;
211 /** 193 /**
212 * @} 194 * @}
213 */ 195 */
214 }; 196 };
215 197
216} 198}
217 199
218#endif /* __OPKELE_BASIC_RP_H */ 200#endif /* __OPKELE_BASIC_RP_H */
diff --git a/include/opkele/types.h b/include/opkele/types.h
index 5d39a5c..6ab51ef 100644
--- a/include/opkele/types.h
+++ b/include/opkele/types.h
@@ -1,211 +1,229 @@
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 <ostream> 10#include <ostream>
10#include <vector> 11#include <vector>
11#include <string> 12#include <string>
12#include <map> 13#include <map>
13#include <set> 14#include <set>
14#include <list> 15#include <list>
15#include <opkele/iterator.h> 16#include <opkele/iterator.h>
16#include <opkele/tr1-mem.h> 17#include <opkele/tr1-mem.h>
17 18
18namespace opkele { 19namespace opkele {
19 using std::vector; 20 using std::vector;
20 using std::string; 21 using std::string;
21 using std::map; 22 using std::map;
22 using std::ostream; 23 using std::ostream;
23 using std::multimap; 24 using std::multimap;
24 using std::set; 25 using std::set;
25 using std::list; 26 using std::list;
26 using std::iterator; 27 using std::iterator;
27 using std::forward_iterator_tag; 28 using std::forward_iterator_tag;
28 29
29 /** 30 /**
30 * the OpenID operation mode 31 * the OpenID operation mode
31 */ 32 */
32 typedef enum _mode_t { 33 typedef enum _mode_t {
33 mode_unknown = 0, 34 mode_unknown = 0,
34 mode_associate, 35 mode_associate,
35 mode_checkid_immediate, 36 mode_checkid_immediate,
36 mode_checkid_setup, 37 mode_checkid_setup,
37 mode_check_association 38 mode_check_association
38 } mode_t; 39 } mode_t;
39 40
40 /** 41 /**
41 * the association secret container 42 * the association secret container
42 */ 43 */
43 class secret_t : public vector<unsigned char> { 44 class secret_t : public vector<unsigned char> {
44 public: 45 public:
45 46
46 /** 47 /**
47 * xor the secret and hmac together and encode, using base64 48 * xor the secret and hmac together and encode, using base64
48 * @param key_d pointer to the message digest 49 * @param key_d pointer to the message digest
49 * @param rv reference to the return value 50 * @param rv reference to the return value
50 */ 51 */
51 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;
52 /** 53 /**
53 * decode base64-encoded secret and xor it with the message digest 54 * decode base64-encoded secret and xor it with the message digest
54 * @param key_d pointer to the message digest 55 * @param key_d pointer to the message digest
55 * @param b64 base64-encoded secret value 56 * @param b64 base64-encoded secret value
56 */ 57 */
57 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);
58 /** 59 /**
59 * plainly encode to base64 representation 60 * plainly encode to base64 representation
60 * @param rv reference to the return value 61 * @param rv reference to the return value
61 */ 62 */
62 void to_base64(string& rv) const; 63 void to_base64(string& rv) const;
63 /** 64 /**
64 * decode cleartext secret from base64 65 * decode cleartext secret from base64
65 * @param b64 base64-encoded representation of the secret value 66 * @param b64 base64-encoded representation of the secret value
66 */ 67 */
67 void from_base64(const string& b64); 68 void from_base64(const string& b64);
68 }; 69 };
69 70
70 /** 71 /**
71 * Interface to the association. 72 * Interface to the association.
72 */ 73 */
73 class association_t { 74 class association_t {
74 public: 75 public:
75 76
76 virtual ~association_t() { } 77 virtual ~association_t() { }
77 78
78 /** 79 /**
79 * retrieve the server with which association was established. 80 * retrieve the server with which association was established.
80 * @return server name 81 * @return server name
81 */ 82 */
82 virtual string server() const = 0; 83 virtual string server() const = 0;
83 /** 84 /**
84 * retrieve the association handle. 85 * retrieve the association handle.
85 * @return handle 86 * @return handle
86 */ 87 */
87 virtual string handle() const = 0; 88 virtual string handle() const = 0;
88 /** 89 /**
89 * retrieve the association type. 90 * retrieve the association type.
90 * @return association type 91 * @return association type
91 */ 92 */
92 virtual string assoc_type() const = 0; 93 virtual string assoc_type() const = 0;
93 /** 94 /**
94 * retrieve the association secret. 95 * retrieve the association secret.
95 * @return association secret 96 * @return association secret
96 */ 97 */
97 virtual secret_t secret() const = 0; 98 virtual secret_t secret() const = 0;
98 /** 99 /**
99 * retrieve the number of seconds the association expires in. 100 * retrieve the number of seconds the association expires in.
100 * @return seconds till expiration 101 * @return seconds till expiration
101 */ 102 */
102 virtual int expires_in() const = 0; 103 virtual int expires_in() const = 0;
103 /** 104 /**
104 * check whether the association is stateless. 105 * check whether the association is stateless.
105 * @return true if stateless 106 * @return true if stateless
106 */ 107 */
107 virtual bool stateless() const = 0; 108 virtual bool stateless() const = 0;
108 /** 109 /**
109 * check whether the association is expired. 110 * check whether the association is expired.
110 * @return true if expired 111 * @return true if expired
111 */ 112 */
112 virtual bool is_expired() const = 0; 113 virtual bool is_expired() const = 0;
113 }; 114 };
114 115
115 /** 116 /**
116 * the shared_ptr<> for association_t object type 117 * the shared_ptr<> for association_t object type
117 */ 118 */
118 typedef tr1mem::shared_ptr<association_t> assoc_t; 119 typedef tr1mem::shared_ptr<association_t> assoc_t;
119 120
120 class basic_openid_message { 121 class basic_openid_message {
121 public: 122 public:
122 typedef list<string> fields_t; 123 typedef list<string> fields_t;
123 typedef util::forward_iterator_proxy< 124 typedef util::forward_iterator_proxy<
124 string,const string&,const string* 125 string,const string&,const string*
125 > fields_iterator; 126 > fields_iterator;
126 127
127 basic_openid_message() { } 128 basic_openid_message() { }
128 basic_openid_message(const basic_openid_message& x); 129 basic_openid_message(const basic_openid_message& x);
129 void copy_to(basic_openid_message& x) const; 130 void copy_to(basic_openid_message& x) const;
130 131
131 virtual bool has_field(const string& n) const = 0; 132 virtual bool has_field(const string& n) const = 0;
132 virtual const string& get_field(const string& n) const = 0; 133 virtual const string& get_field(const string& n) const = 0;
133 134
134 virtual bool has_ns(const string& uri) const; 135 virtual bool has_ns(const string& uri) const;
135 virtual string get_ns(const string& uri) const; 136 virtual string get_ns(const string& uri) const;
136 137
137 virtual fields_iterator fields_begin() const = 0; 138 virtual fields_iterator fields_begin() const = 0;
138 virtual fields_iterator fields_end() const = 0; 139 virtual fields_iterator fields_end() const = 0;
139 140
140 virtual string append_query(const string& url) const; 141 virtual string append_query(const string& url) const;
141 virtual string query_string() const; 142 virtual string query_string() const;
142 143
143 144
144 virtual void reset_fields(); 145 virtual void reset_fields();
145 virtual void set_field(const string& n,const string& v); 146 virtual void set_field(const string& n,const string& v);
146 virtual void reset_field(const string& n); 147 virtual void reset_field(const string& n);
147 148
148 virtual void from_keyvalues(const string& kv); 149 virtual void from_keyvalues(const string& kv);
149 virtual void to_keyvalues(ostream& o) const; 150 virtual void to_keyvalues(ostream& o) const;
150 151
151 virtual void to_htmlhiddens(ostream& o) const; 152 virtual void to_htmlhiddens(ostream& o) const;
152 153
153 void add_to_signed(const string& fields); 154 void add_to_signed(const string& fields);
154 string find_ns(const string& uri,const char *pfx) const; 155 string find_ns(const string& uri,const char *pfx) const;
155 string allocate_ns(const string& uri,const char *pfx); 156 string allocate_ns(const string& uri,const char *pfx);
156 }; 157 };
157 158
158 class openid_message_t : public basic_openid_message, public map<string,string> { 159 class openid_message_t : public basic_openid_message, public map<string,string> {
159 public: 160 public:
160 openid_message_t() { } 161 openid_message_t() { }
161 openid_message_t(const basic_openid_message& x) 162 openid_message_t(const basic_openid_message& x)
162 : basic_openid_message(x) { } 163 : basic_openid_message(x) { }
163 164
164 void copy_to(basic_openid_message& x) const; 165 void copy_to(basic_openid_message& x) const;
165 166
166 bool has_field(const string& n) const; 167 bool has_field(const string& n) const;
167 const string& get_field(const string& n) const; 168 const string& get_field(const string& n) const;
168 virtual fields_iterator fields_begin() const; 169 virtual fields_iterator fields_begin() const;
169 virtual fields_iterator fields_end() const; 170 virtual fields_iterator fields_end() const;
170 171
171 void reset_fields(); 172 void reset_fields();
172 void set_field(const string& n,const string& v); 173 void set_field(const string& n,const string& v);
173 void reset_field(const string& n); 174 void reset_field(const string& n);
174 }; 175 };
175 176
176 /** 177 /**
177 * request/response parameters map 178 * request/response parameters map
178 */ 179 */
179 class params_t : public openid_message_t { 180 class params_t : public openid_message_t {
180 public: 181 public:
181 182
182 /** 183 /**
183 * check whether the parameter is present. 184 * check whether the parameter is present.
184 * @param n the parameter name 185 * @param n the parameter name
185 * @return true if yes 186 * @return true if yes
186 */ 187 */
187 bool has_param(const string& n) const { 188 bool has_param(const string& n) const {
188 return has_field(n); } 189 return has_field(n); }
189 /** 190 /**
190 * retrieve the parameter (const version) 191 * retrieve the parameter (const version)
191 * @param n the parameter name 192 * @param n the parameter name
192 * @return the parameter value 193 * @return the parameter value
193 * @throw failed_lookup if there is no such parameter 194 * @throw failed_lookup if there is no such parameter
194 */ 195 */
195 const string& get_param(const string& n) const { 196 const string& get_param(const string& n) const {
196 return get_field(n); } 197 return get_field(n); }
197 198
198 /** 199 /**
199 * parse the OpenID key/value data. 200 * parse the OpenID key/value data.
200 * @param kv the OpenID key/value data 201 * @param kv the OpenID key/value data
201 */ 202 */
202 void parse_keyvalues(const string& kv) { 203 void parse_keyvalues(const string& kv) {
203 from_keyvalues(kv); } 204 from_keyvalues(kv); }
204 205
205 string append_query(const string& url,const char *prefix="openid.") const; 206 string append_query(const string& url,const char *prefix="openid.") const;
206 207
207 }; 208 };
208 209
210 struct openid_endpoint_t {
211 string uri;
212 string claimed_id;
213 string local_id;
214
215 openid_endpoint_t() { }
216 openid_endpoint_t(const string& u,const string& cid,const string& lid)
217 : uri(u), claimed_id(cid), local_id(lid) { }
218
219 bool operator==(const openid_endpoint_t& x) const {
220 return uri==x.uri && local_id==x.local_id; }
221 bool operator<(const openid_endpoint_t& x) const {
222 int c;
223 return (c=strcmp(uri.c_str(),x.uri.c_str()))
224 ? (c<0) : (strcmp(local_id.c_str(),x.local_id.c_str())<0); }
225 };
226
209} 227}
210 228
211#endif /* __OPKELE_TYPES_H */ 229#endif /* __OPKELE_TYPES_H */