summaryrefslogtreecommitdiffabout
path: root/lib/consumer.cc
authorMichael Krelin <hacker@klever.net>2007-01-11 00:57:06 (UTC)
committer Michael Krelin <hacker@klever.net>2007-01-11 00:57:06 (UTC)
commit06eaf00c48fc563245b85c2be4b8b5a03ef2cfe9 (patch) (unidiff)
treeef978c5d86188d2fc4c7e98a921804d7bfeb5557 /lib/consumer.cc
parent100199abfdf7a353f9ba2aa9618e0711213290d3 (diff)
downloadlibopkele-06eaf00c48fc563245b85c2be4b8b5a03ef2cfe9.zip
libopkele-06eaf00c48fc563245b85c2be4b8b5a03ef2cfe9.tar.gz
libopkele-06eaf00c48fc563245b85c2be4b8b5a03ef2cfe9.tar.bz2
introduced extension hooks framework
Diffstat (limited to 'lib/consumer.cc') (more/less context) (ignore whitespace changes)
-rw-r--r--lib/consumer.cc16
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/consumer.cc b/lib/consumer.cc
index bb6358c..10c2fa0 100644
--- a/lib/consumer.cc
+++ b/lib/consumer.cc
@@ -123,13 +123,13 @@ namespace opkele {
123 return store_assoc(server,p.get_param("assoc_handle"),secret,expires_in); 123 return store_assoc(server,p.get_param("assoc_handle"),secret,expires_in);
124 } 124 }
125 125
126 string consumer_t::checkid_immediate(const string& identity,const string& return_to,const string& trust_root) { 126 string consumer_t::checkid_immediate(const string& identity,const string& return_to,const string& trust_root,extension_t *ext) {
127 return checkid_(mode_checkid_immediate,identity,return_to,trust_root); 127 return checkid_(mode_checkid_immediate,identity,return_to,trust_root,ext);
128 } 128 }
129 string consumer_t::checkid_setup(const string& identity,const string& return_to,const string& trust_root) { 129 string consumer_t::checkid_setup(const string& identity,const string& return_to,const string& trust_root,extension_t *ext) {
130 return checkid_(mode_checkid_setup,identity,return_to,trust_root); 130 return checkid_(mode_checkid_setup,identity,return_to,trust_root,ext);
131 } 131 }
132 string consumer_t::checkid_(mode_t mode,const string& identity,const string& return_to,const string& trust_root) { 132 string consumer_t::checkid_(mode_t mode,const string& identity,const string& return_to,const string& trust_root,extension_t *ext) {
133 params_t p; 133 params_t p;
134 if(mode==mode_checkid_immediate) 134 if(mode==mode_checkid_immediate)
135 p["mode"]="checkid_immediate"; 135 p["mode"]="checkid_immediate";
@@ -153,14 +153,16 @@ namespace opkele {
153 p["assoc_handle"] = ah; 153 p["assoc_handle"] = ah;
154 } 154 }
155 }catch(exception& e) { } 155 }catch(exception& e) { }
156 if(ext) ext->checkid_hook(p,identity);
156 return p.append_query(server); 157 return p.append_query(server);
157 } 158 }
158 159
159 void consumer_t::id_res(const params_t& pin,const string& identity) { 160 void consumer_t::id_res(const params_t& pin,const string& identity,extension_t *ext) {
160 if(pin.has_param("openid.user_setup_url")) 161 if(pin.has_param("openid.user_setup_url"))
161 throw id_res_setup(OPKELE_CP_ "assertion failed, setup url provided",pin.get_param("openid.user_setup_url")); 162 throw id_res_setup(OPKELE_CP_ "assertion failed, setup url provided",pin.get_param("openid.user_setup_url"));
162 string server,delegate; 163 string server,delegate;
163 retrieve_links(identity.empty()?pin.get_param("openid.identity"):canonicalize(identity),server,delegate); 164 retrieve_links(identity.empty()?pin.get_param("openid.identity"):canonicalize(identity),server,delegate);
165 params_t ps;
164 try { 166 try {
165 assoc_t assoc = retrieve_assoc(server,pin.get_param("openid.assoc_handle")); 167 assoc_t assoc = retrieve_assoc(server,pin.get_param("openid.assoc_handle"));
166 const string& sigenc = pin.get_param("openid.sig"); 168 const string& sigenc = pin.get_param("openid.sig");
@@ -180,6 +182,7 @@ namespace opkele {
180 f.insert(0,"openid."); 182 f.insert(0,"openid.");
181 kv += pin.get_param(f); 183 kv += pin.get_param(f);
182 kv += '\n'; 184 kv += '\n';
185 if(ext) ps[f.substr(sizeof("openid."))] = pin.get_param(f);
183 if(co==string::npos) 186 if(co==string::npos)
184 break; 187 break;
185 p = co+1; 188 p = co+1;
@@ -219,6 +222,7 @@ namespace opkele {
219 throw id_res_failed(OPKELE_CP_ "failed to check_authentication()"); 222 throw id_res_failed(OPKELE_CP_ "failed to check_authentication()");
220 } 223 }
221 } 224 }
225 if(ext) ext->id_res_hook(pin,ps,identity);
222 } 226 }
223 227
224 void consumer_t::check_authentication(const string& server,const params_t& p) { 228 void consumer_t::check_authentication(const string& server,const params_t& p) {