author | Michael Krelin <hacker@klever.net> | 2007-01-11 00:57:06 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2007-01-11 00:57:06 (UTC) |
commit | 06eaf00c48fc563245b85c2be4b8b5a03ef2cfe9 (patch) (side-by-side diff) | |
tree | ef978c5d86188d2fc4c7e98a921804d7bfeb5557 /lib | |
parent | 100199abfdf7a353f9ba2aa9618e0711213290d3 (diff) | |
download | libopkele-06eaf00c48fc563245b85c2be4b8b5a03ef2cfe9.zip libopkele-06eaf00c48fc563245b85c2be4b8b5a03ef2cfe9.tar.gz libopkele-06eaf00c48fc563245b85c2be4b8b5a03ef2cfe9.tar.bz2 |
introduced extension hooks framework
-rw-r--r-- | lib/Makefile.am | 3 | ||||
-rw-r--r-- | lib/consumer.cc | 16 | ||||
-rw-r--r-- | lib/extension.cc | 15 | ||||
-rw-r--r-- | lib/server.cc | 14 |
4 files changed, 35 insertions, 13 deletions
diff --git a/lib/Makefile.am b/lib/Makefile.am index 6f3f9f3..69c749e 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -23,2 +23,3 @@ libopkele_la_SOURCES = \ consumer.cc \ - exception.cc + exception.cc \ + extension.cc diff --git a/lib/consumer.cc b/lib/consumer.cc index bb6358c..10c2fa0 100644 --- a/lib/consumer.cc +++ b/lib/consumer.cc @@ -125,9 +125,9 @@ namespace opkele { - string consumer_t::checkid_immediate(const string& identity,const string& return_to,const string& trust_root) { - return checkid_(mode_checkid_immediate,identity,return_to,trust_root); + string consumer_t::checkid_immediate(const string& identity,const string& return_to,const string& trust_root,extension_t *ext) { + return checkid_(mode_checkid_immediate,identity,return_to,trust_root,ext); } - string consumer_t::checkid_setup(const string& identity,const string& return_to,const string& trust_root) { - return checkid_(mode_checkid_setup,identity,return_to,trust_root); + string consumer_t::checkid_setup(const string& identity,const string& return_to,const string& trust_root,extension_t *ext) { + return checkid_(mode_checkid_setup,identity,return_to,trust_root,ext); } - string consumer_t::checkid_(mode_t mode,const string& identity,const string& return_to,const string& trust_root) { + string consumer_t::checkid_(mode_t mode,const string& identity,const string& return_to,const string& trust_root,extension_t *ext) { params_t p; @@ -155,2 +155,3 @@ namespace opkele { }catch(exception& e) { } + if(ext) ext->checkid_hook(p,identity); return p.append_query(server); @@ -158,3 +159,3 @@ namespace opkele { - void consumer_t::id_res(const params_t& pin,const string& identity) { + void consumer_t::id_res(const params_t& pin,const string& identity,extension_t *ext) { if(pin.has_param("openid.user_setup_url")) @@ -163,2 +164,3 @@ namespace opkele { retrieve_links(identity.empty()?pin.get_param("openid.identity"):canonicalize(identity),server,delegate); + params_t ps; try { @@ -182,2 +184,3 @@ namespace opkele { kv += '\n'; + if(ext) ps[f.substr(sizeof("openid."))] = pin.get_param(f); if(co==string::npos) @@ -221,2 +224,3 @@ namespace opkele { } + if(ext) ext->id_res_hook(pin,ps,identity); } diff --git a/lib/extension.cc b/lib/extension.cc new file mode 100644 index 0000000..bd2195d --- a/dev/null +++ b/lib/extension.cc @@ -0,0 +1,15 @@ +#include <opkele/exception.h> +#include <opkele/extension.h> + +namespace opkele { + + void extension_t::checkid_hook(params_t& p,const string& identity) { + throw not_implemented(OPKELE_CP_ "Consumer checkid_hook not implemented"); + } + void id_res_hook(const params_t& p,const params_t& sp,const string& identity) { + throw not_implemented(OPKELE_CP_ "Consumer id_res_hook not implemented"); + } + void checkid_hook(const params_t& pin,params_t& pout) { + throw not_implemented(OPKELE_CP_ "Server checkid_hook not implemented"); + } +} diff --git a/lib/server.cc b/lib/server.cc index 5eee1f3..8c29abb 100644 --- a/lib/server.cc +++ b/lib/server.cc @@ -69,11 +69,11 @@ namespace opkele { - void server_t::checkid_immediate(const params_t& pin,string& return_to,params_t& pout) { - checkid_(mode_checkid_immediate,pin,return_to,pout); + void server_t::checkid_immediate(const params_t& pin,string& return_to,params_t& pout,extension_t *ext) { + checkid_(mode_checkid_immediate,pin,return_to,pout,ext); } - void server_t::checkid_setup(const params_t& pin,string& return_to,params_t& pout) { - checkid_(mode_checkid_setup,pin,return_to,pout); + void server_t::checkid_setup(const params_t& pin,string& return_to,params_t& pout,extension_t *ext) { + checkid_(mode_checkid_setup,pin,return_to,pout,ext); } - void server_t::checkid_(mode_t mode,const params_t& pin,string& return_to,params_t& pout) { + void server_t::checkid_(mode_t mode,const params_t& pin,string& return_to,params_t& pout,extension_t *ext) { if(mode!=mode_checkid_immediate && mode!=mode_checkid_setup) @@ -108,3 +108,5 @@ namespace opkele { pout["exipres_in"] = "120"; - pout.sign(assoc->secret(),pout["sig"],pout["signed"]="mode,identity,return_to"); + pout["signed"]="mode,identity,return_to"; + if(ext) ext->checkid_hook(pin,pout); + pout.sign(assoc->secret(),pout["sig"],pout["signed"]); } |