author | Michael Krelin <hacker@klever.net> | 2008-02-04 22:39:59 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2008-02-04 22:39:59 (UTC) |
commit | 9163a26ec8839a31df888920418280a62ebc5595 (patch) (unidiff) | |
tree | 55339b4ecf0a3f24817eb5cc1b0b24f831ac895b /lib/sreg.cc | |
parent | c0eeee1cfd41d0f5f6ff6ac3d6fe021421376a69 (diff) | |
download | libopkele-9163a26ec8839a31df888920418280a62ebc5595.zip libopkele-9163a26ec8839a31df888920418280a62ebc5595.tar.gz libopkele-9163a26ec8839a31df888920418280a62ebc5595.tar.bz2 |
reworked extensions framework
* changed {checkid,id_res}_hook to {rp,op}_{checkid,id_res}_hook
* deprecated older hooks, although implemented it in sreg and chain extensions
* added extension processing to basic_op
* added sreg to test OP
Signed-off-by: Michael Krelin <hacker@klever.net>
-rw-r--r-- | lib/sreg.cc | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/lib/sreg.cc b/lib/sreg.cc index 7e2d588..b40cd45 100644 --- a/lib/sreg.cc +++ b/lib/sreg.cc | |||
@@ -28,7 +28,7 @@ namespace opkele { | |||
28 | return fd.fieldname==fn; | 28 | return fd.fieldname==fn; |
29 | } | 29 | } |
30 | 30 | ||
31 | void sreg_t::checkid_hook(basic_openid_message& om) { | 31 | void sreg_t::rp_checkid_hook(basic_openid_message& om) { |
32 | string fr, fo; | 32 | string fr, fo; |
33 | for(fields_iterator f=fields_BEGIN;f<fields_END;++f) { | 33 | for(fields_iterator f=fields_BEGIN;f<fields_END;++f) { |
34 | if(f->fieldbit&fields_required) { | 34 | if(f->fieldbit&fields_required) { |
@@ -46,7 +46,11 @@ namespace opkele { | |||
46 | if(!policy_url.empty()) om.set_field(pfx+".policy_url",policy_url); | 46 | if(!policy_url.empty()) om.set_field(pfx+".policy_url",policy_url); |
47 | } | 47 | } |
48 | 48 | ||
49 | void sreg_t::id_res_hook(const basic_openid_message& om,const basic_openid_message& sp) { | 49 | void sreg_t::checkid_hook(basic_openid_message& om) { |
50 | rp_checkid_hook(om); } | ||
51 | |||
52 | void sreg_t::rp_id_res_hook(const basic_openid_message& om, | ||
53 | const basic_openid_message& sp) { | ||
50 | clear(); | 54 | clear(); |
51 | string pfx; | 55 | string pfx; |
52 | try { | 56 | try { |
@@ -67,6 +71,10 @@ namespace opkele { | |||
67 | } | 71 | } |
68 | } | 72 | } |
69 | 73 | ||
74 | void sreg_t::id_res_hook(const basic_openid_message& om, | ||
75 | const basic_openid_message& sp) { | ||
76 | rp_id_res_hook(om,sp); } | ||
77 | |||
70 | const string& sreg_t::get_field(fieldbit_t fb) const { | 78 | const string& sreg_t::get_field(fieldbit_t fb) const { |
71 | response_t::const_iterator i = response.find(fb); | 79 | response_t::const_iterator i = response.find(fb); |
72 | if(i==response.end()) | 80 | if(i==response.end()) |
@@ -105,7 +113,7 @@ namespace opkele { | |||
105 | return rv; | 113 | return rv; |
106 | } | 114 | } |
107 | 115 | ||
108 | void sreg_t::checkid_hook(const basic_openid_message& inm,basic_openid_message& oum) { | 116 | void sreg_t::op_checkid_hook(const basic_openid_message& inm) { |
109 | string ins = inm.find_ns(OIURI_SREG11,"sreg"); | 117 | string ins = inm.find_ns(OIURI_SREG11,"sreg"); |
110 | fields_optional = 0; fields_required = 0; policy_url.erase(); | 118 | fields_optional = 0; fields_required = 0; policy_url.erase(); |
111 | fields_response = 0; | 119 | fields_response = 0; |
@@ -120,7 +128,9 @@ namespace opkele { | |||
120 | try { | 128 | try { |
121 | policy_url = inm.get_field(ins+".policy_url"); | 129 | policy_url = inm.get_field(ins+".policy_url"); |
122 | }catch(failed_lookup&) { } | 130 | }catch(failed_lookup&) { } |
123 | setup_response(inm,oum); | 131 | } |
132 | |||
133 | void sreg_t::op_id_res_hook(basic_openid_message& oum) { | ||
124 | string ons = oum.allocate_ns(OIURI_SREG11,"sreg"); | 134 | string ons = oum.allocate_ns(OIURI_SREG11,"sreg"); |
125 | fields_response &= has_fields; | 135 | fields_response &= has_fields; |
126 | string signeds = "ns."+ons; | 136 | string signeds = "ns."+ons; |
@@ -134,7 +144,17 @@ namespace opkele { | |||
134 | oum.add_to_signed(signeds); | 144 | oum.add_to_signed(signeds); |
135 | } | 145 | } |
136 | 146 | ||
147 | void sreg_t::checkid_hook(const basic_openid_message& inm, | ||
148 | basic_openid_message& oum) { | ||
149 | op_checkid_hook(inm); | ||
150 | setup_response(inm,oum); | ||
151 | op_id_res_hook(oum); | ||
152 | } | ||
153 | |||
137 | void sreg_t::setup_response(const basic_openid_message& /* inm */,basic_openid_message& /* oum */) { | 154 | void sreg_t::setup_response(const basic_openid_message& /* inm */,basic_openid_message& /* oum */) { |
155 | setup_response(); | ||
156 | } | ||
157 | void sreg_t::setup_response() { | ||
138 | fields_response = (fields_required|fields_optional)&has_fields; | 158 | fields_response = (fields_required|fields_optional)&has_fields; |
139 | } | 159 | } |
140 | } | 160 | } |