summaryrefslogtreecommitdiffabout
path: root/lib
Unidiff
Diffstat (limited to 'lib') (more/less context) (ignore whitespace changes)
-rw-r--r--lib/Makefile.am3
-rw-r--r--lib/consumer.cc16
-rw-r--r--lib/extension.cc15
-rw-r--r--lib/server.cc14
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 = \
23 consumer.cc \ 23 consumer.cc \
24 exception.cc 24 exception.cc \
25 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 {
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;
@@ -155,2 +155,3 @@ namespace opkele {
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);
@@ -158,3 +159,3 @@ namespace opkele {
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"))
@@ -163,2 +164,3 @@ namespace opkele {
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 {
@@ -182,2 +184,3 @@ namespace opkele {
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)
@@ -221,2 +224,3 @@ namespace opkele {
221 } 224 }
225 if(ext) ext->id_res_hook(pin,ps,identity);
222 } 226 }
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 @@
1#include <opkele/exception.h>
2#include <opkele/extension.h>
3
4namespace opkele {
5
6 void extension_t::checkid_hook(params_t& p,const string& identity) {
7 throw not_implemented(OPKELE_CP_ "Consumer checkid_hook not implemented");
8 }
9 void id_res_hook(const params_t& p,const params_t& sp,const string& identity) {
10 throw not_implemented(OPKELE_CP_ "Consumer id_res_hook not implemented");
11 }
12 void checkid_hook(const params_t& pin,params_t& pout) {
13 throw not_implemented(OPKELE_CP_ "Server checkid_hook not implemented");
14 }
15}
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 {
69 69
70 void server_t::checkid_immediate(const params_t& pin,string& return_to,params_t& pout) { 70 void server_t::checkid_immediate(const params_t& pin,string& return_to,params_t& pout,extension_t *ext) {
71 checkid_(mode_checkid_immediate,pin,return_to,pout); 71 checkid_(mode_checkid_immediate,pin,return_to,pout,ext);
72 } 72 }
73 73
74 void server_t::checkid_setup(const params_t& pin,string& return_to,params_t& pout) { 74 void server_t::checkid_setup(const params_t& pin,string& return_to,params_t& pout,extension_t *ext) {
75 checkid_(mode_checkid_setup,pin,return_to,pout); 75 checkid_(mode_checkid_setup,pin,return_to,pout,ext);
76 } 76 }
77 77
78 void server_t::checkid_(mode_t mode,const params_t& pin,string& return_to,params_t& pout) { 78 void server_t::checkid_(mode_t mode,const params_t& pin,string& return_to,params_t& pout,extension_t *ext) {
79 if(mode!=mode_checkid_immediate && mode!=mode_checkid_setup) 79 if(mode!=mode_checkid_immediate && mode!=mode_checkid_setup)
@@ -108,3 +108,5 @@ namespace opkele {
108 pout["exipres_in"] = "120"; 108 pout["exipres_in"] = "120";
109 pout.sign(assoc->secret(),pout["sig"],pout["signed"]="mode,identity,return_to"); 109 pout["signed"]="mode,identity,return_to";
110 if(ext) ext->checkid_hook(pin,pout);
111 pout.sign(assoc->secret(),pout["sig"],pout["signed"]);
110 } 112 }