summaryrefslogtreecommitdiffabout
path: root/lib
Unidiff
Diffstat (limited to 'lib') (more/less context) (ignore whitespace changes)
-rw-r--r--lib/Makefile.am2
-rw-r--r--lib/curl.cc20
-rw-r--r--lib/fields.cc86
-rw-r--r--lib/message.cc (renamed from lib/openid_message.cc)84
4 files changed, 108 insertions, 84 deletions
diff --git a/lib/Makefile.am b/lib/Makefile.am
index e8bfbf5..20d15b8 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -1,34 +1,34 @@
1lib_LTLIBRARIES = libopkele.la 1lib_LTLIBRARIES = libopkele.la
2 2
3AM_CPPFLAGS = ${CPPFLAGS_DEBUG} 3AM_CPPFLAGS = ${CPPFLAGS_DEBUG}
4DEFAULT_INCLUDES = -I${top_builddir} 4DEFAULT_INCLUDES = -I${top_builddir}
5INCLUDES = \ 5INCLUDES = \
6 -I${top_builddir}/include/ -I${top_srcdir}/include/ \ 6 -I${top_builddir}/include/ -I${top_srcdir}/include/ \
7 ${KONFORKA_CFLAGS} \ 7 ${KONFORKA_CFLAGS} \
8 ${OPENSSL_CFLAGS} \ 8 ${OPENSSL_CFLAGS} \
9 ${LIBCURL_CPPFLAGS} \ 9 ${LIBCURL_CPPFLAGS} \
10 ${PCRE_CFLAGS} ${EXPAT_CFLAGS} ${TIDY_CFLAGS} 10 ${PCRE_CFLAGS} ${EXPAT_CFLAGS} ${TIDY_CFLAGS}
11libopkele_la_LIBADD = \ 11libopkele_la_LIBADD = \
12 ${LIBCURL} \ 12 ${LIBCURL} \
13 ${PCRE_LIBS} ${EXPAT_LIBS} \ 13 ${PCRE_LIBS} ${EXPAT_LIBS} \
14 ${OPENSSL_LIBS} \ 14 ${OPENSSL_LIBS} \
15 ${KONFORKA_LIBS} ${TIDY_LIBS} 15 ${KONFORKA_LIBS} ${TIDY_LIBS}
16 16
17libopkele_la_SOURCES = \ 17libopkele_la_SOURCES = \
18 params.cc \ 18 params.cc \
19 util.cc \ 19 util.cc \
20 server.cc \ 20 server.cc \
21 secret.cc \ 21 secret.cc \
22 data.cc \ 22 data.cc \
23 consumer.cc \ 23 consumer.cc \
24 exception.cc \ 24 exception.cc \
25 extension.cc \ 25 extension.cc \
26 sreg.cc \ 26 sreg.cc \
27 extension_chain.cc \ 27 extension_chain.cc \
28 curl.cc expat.cc \ 28 curl.cc expat.cc \
29 discovery.cc \ 29 discovery.cc \
30 basic_rp.cc prequeue_rp.cc \ 30 basic_rp.cc prequeue_rp.cc \
31 openid_message.cc \ 31 fields.cc message.cc \
32 basic_op.cc verify_op.cc 32 basic_op.cc verify_op.cc
33libopkele_la_LDFLAGS = \ 33libopkele_la_LDFLAGS = \
34 -version-info 2:0:0 34 -version-info 2:0:0
diff --git a/lib/curl.cc b/lib/curl.cc
index 6172828..734e2ca 100644
--- a/lib/curl.cc
+++ b/lib/curl.cc
@@ -1,56 +1,76 @@
1#include <opkele/exception.h>
1#include <opkele/curl.h> 2#include <opkele/curl.h>
2 3
3#include "config.h" 4#include "config.h"
4 5
5namespace opkele { 6namespace opkele {
6 7
7 namespace util { 8 namespace util {
8 9
10 curl_slist_t::~curl_slist_t() throw() {
11 if(_s)
12 curl_slist_free_all(_s);
13 }
14
15 curl_slist_t& curl_slist_t::operator=(curl_slist *s) {
16 if(_s)
17 curl_slist_free_all(_s);
18 _s = s;
19 return *this;
20 }
21
22 void curl_slist_t::append(const char *str) {
23 curl_slist *s = curl_slist_append(_s,str);
24 if(!s)
25 throw opkele::exception(OPKELE_CP_ "failed to curl_slist_append()");
26 _s=s;
27 }
28
9 curl_t::~curl_t() throw() { 29 curl_t::~curl_t() throw() {
10 if(_c) 30 if(_c)
11 curl_easy_cleanup(_c); 31 curl_easy_cleanup(_c);
12 } 32 }
13 33
14 curl_t& curl_t::operator=(CURL *c) { 34 curl_t& curl_t::operator=(CURL *c) {
15 if(_c) 35 if(_c)
16 curl_easy_cleanup(_c); 36 curl_easy_cleanup(_c);
17 _c = c; 37 _c = c;
18 return *this; 38 return *this;
19 } 39 }
20 40
21 CURLcode curl_t::misc_sets() { 41 CURLcode curl_t::misc_sets() {
22 assert(_c); 42 assert(_c);
23 CURLcode r; 43 CURLcode r;
24 (r=easy_setopt(CURLOPT_FOLLOWLOCATION,1)) 44 (r=easy_setopt(CURLOPT_FOLLOWLOCATION,1))
25 || (r=easy_setopt(CURLOPT_MAXREDIRS,5)) 45 || (r=easy_setopt(CURLOPT_MAXREDIRS,5))
26 || (r=easy_setopt(CURLOPT_DNS_CACHE_TIMEOUT,120)) 46 || (r=easy_setopt(CURLOPT_DNS_CACHE_TIMEOUT,120))
27 || (r=easy_setopt(CURLOPT_DNS_USE_GLOBAL_CACHE,1)) 47 || (r=easy_setopt(CURLOPT_DNS_USE_GLOBAL_CACHE,1))
28 || (r=easy_setopt(CURLOPT_USERAGENT,PACKAGE_NAME"/"PACKAGE_SRC_VERSION)) 48 || (r=easy_setopt(CURLOPT_USERAGENT,PACKAGE_NAME"/"PACKAGE_SRC_VERSION))
29 || (r=easy_setopt(CURLOPT_TIMEOUT,20)) 49 || (r=easy_setopt(CURLOPT_TIMEOUT,20))
30 #ifdefDISABLE_CURL_SSL_VERIFYHOST 50 #ifdefDISABLE_CURL_SSL_VERIFYHOST
31 || (r=easy_setopt(CURLOPT_SSL_VERIFYHOST,0)) 51 || (r=easy_setopt(CURLOPT_SSL_VERIFYHOST,0))
32#endif 52#endif
33 #ifdefDISABLE_CURL_SSL_VERIFYPEER 53 #ifdefDISABLE_CURL_SSL_VERIFYPEER
34 || (r=easy_setopt(CURLOPT_SSL_VERIFYPEER,0)) 54 || (r=easy_setopt(CURLOPT_SSL_VERIFYPEER,0))
35#endif 55#endif
36 ; 56 ;
37 return r; 57 return r;
38 } 58 }
39 59
40 static size_t _write(void *p,size_t s,size_t nm,void *stream) { 60 static size_t _write(void *p,size_t s,size_t nm,void *stream) {
41 return ((curl_t*)stream)->write(p,s,nm); 61 return ((curl_t*)stream)->write(p,s,nm);
42 } 62 }
43 63
44 CURLcode curl_t::set_write() { 64 CURLcode curl_t::set_write() {
45 assert(_c); 65 assert(_c);
46 CURLcode r; 66 CURLcode r;
47 (r = easy_setopt(CURLOPT_WRITEDATA,this)) 67 (r = easy_setopt(CURLOPT_WRITEDATA,this))
48 || (r = easy_setopt(CURLOPT_WRITEFUNCTION,_write)); 68 || (r = easy_setopt(CURLOPT_WRITEFUNCTION,_write));
49 return r; 69 return r;
50 } 70 }
51 71
52 static int _progress(void *cp,double dlt,double dln,double ult,double uln) { 72 static int _progress(void *cp,double dlt,double dln,double ult,double uln) {
53 return ((curl_t*)cp)->progress(dlt,dln,ult,uln); 73 return ((curl_t*)cp)->progress(dlt,dln,ult,uln);
54 } 74 }
55 75
56 CURLcode curl_t::set_progress() { 76 CURLcode curl_t::set_progress() {
diff --git a/lib/fields.cc b/lib/fields.cc
new file mode 100644
index 0000000..d494098
--- a/dev/null
+++ b/lib/fields.cc
@@ -0,0 +1,86 @@
1#include <opkele/types.h>
2#include <opkele/exception.h>
3#include <opkele/util.h>
4
5namespace opkele {
6 using std::unary_function;
7
8 struct __om_copier : public unary_function<const string&,void> {
9 public:
10 const basic_fields& from;
11 basic_fields& to;
12
13 __om_copier(basic_fields& t,const basic_fields& f)
14 : from(f), to(t) { }
15
16 result_type operator()(argument_type f) {
17 to.set_field(f,from.get_field(f)); }
18 };
19
20 basic_fields::basic_fields(const basic_fields& x) {
21 x.copy_to(*this);
22 }
23 void basic_fields::copy_to(basic_fields& x) const {
24 x.reset_fields();
25 for_each(fields_begin(),fields_end(),
26 __om_copier(x,*this) );
27 }
28 void basic_fields::append_to(basic_fields& x) const {
29 for_each(fields_begin(),fields_end(),
30 __om_copier(x,*this) );
31 }
32
33 struct __om_query_builder : public unary_function<const string&,void> {
34 public:
35 const basic_fields& om;
36 bool first;
37 string& rv;
38 const char *pfx;
39
40 __om_query_builder(const char *p,string& r,const basic_fields& m)
41 : om(m), first(true), rv(r), pfx(p) {
42 for_each(om.fields_begin(),om.fields_end(),*this);
43 }
44 __om_query_builder(const char *p,string& r,const basic_fields& m,const string& u)
45 : om(m), first(true), rv(r), pfx(p) {
46 rv = u;
47 if(rv.find('?')==string::npos)
48 rv += '?';
49 else
50 first = false;
51 for_each(om.fields_begin(),om.fields_end(),*this);
52 }
53
54 result_type operator()(argument_type f) {
55 if(first)
56 first = false;
57 else
58 rv += '&';
59 if(pfx) rv += pfx;
60 rv+= f;
61 rv += '=';
62 rv += util::url_encode(om.get_field(f));
63 }
64 };
65
66 string basic_fields::append_query(const string& url,const char *pfx) const {
67 string rv;
68 return __om_query_builder(pfx,rv,*this,url).rv;
69 }
70 string basic_fields::query_string(const char *pfx) const {
71 string rv;
72 return __om_query_builder(pfx,rv,*this).rv;
73 }
74
75 void basic_fields::reset_fields() {
76 throw not_implemented(OPKELE_CP_ "reset_fields() not implemented");
77 }
78 void basic_fields::set_field(const string&,const string&) {
79 throw not_implemented(OPKELE_CP_ "set_field() not implemented");
80 }
81 void basic_fields::reset_field(const string&) {
82 throw not_implemented(OPKELE_CP_ "reset_field() not implemented");
83 }
84
85
86}
diff --git a/lib/openid_message.cc b/lib/message.cc
index e244f43..b2324b7 100644
--- a/lib/openid_message.cc
+++ b/lib/message.cc
@@ -1,180 +1,104 @@
1#include <cassert> 1#include <cassert>
2#include <opkele/types.h> 2#include <opkele/types.h>
3#include <opkele/exception.h> 3#include <opkele/exception.h>
4#include <opkele/util.h> 4#include <opkele/util.h>
5#include <opkele/debug.h> 5#include <opkele/debug.h>
6 6
7#include "config.h" 7#include "config.h"
8 8
9namespace opkele { 9namespace opkele {
10 using std::input_iterator_tag; 10 using std::input_iterator_tag;
11 using std::unary_function; 11 using std::unary_function;
12 12
13 struct __om_copier : public unary_function<const string&,void> {
14 public:
15 const basic_openid_message& from;
16 basic_openid_message& to;
17
18 __om_copier(basic_openid_message& t,const basic_openid_message& f)
19 : from(f), to(t) { }
20
21 result_type operator()(argument_type f) {
22 to.set_field(f,from.get_field(f)); }
23 };
24
25 basic_openid_message::basic_openid_message(const basic_openid_message& x) {
26 x.copy_to(*this);
27 }
28 void basic_openid_message::copy_to(basic_openid_message& x) const {
29 x.reset_fields();
30 for_each(fields_begin(),fields_end(),
31 __om_copier(x,*this) );
32 }
33 void basic_openid_message::append_to(basic_openid_message& x) const {
34 for_each(fields_begin(),fields_end(),
35 __om_copier(x,*this) );
36 }
37 13
38 struct __om_ns_finder : public unary_function<const string&,bool> { 14 struct __om_ns_finder : public unary_function<const string&,bool> {
39 public: 15 public:
40 const basic_openid_message& om; 16 const basic_openid_message& om;
41 const string& uri; 17 const string& uri;
42 18
43 __om_ns_finder(const basic_openid_message& m, 19 __om_ns_finder(const basic_openid_message& m,
44 const string& u) : om(m), uri(u) { } 20 const string& u) : om(m), uri(u) { }
45 21
46 result_type operator()(argument_type f) { 22 result_type operator()(argument_type f) {
47 return 23 return
48 (!strncmp(f.c_str(),"ns.",sizeof("ns.")-1)) 24 (!strncmp(f.c_str(),"ns.",sizeof("ns.")-1))
49 && om.get_field(f)==uri ; 25 && om.get_field(f)==uri ;
50 } 26 }
51 }; 27 };
52 28
53 bool basic_openid_message::has_ns(const string& uri) const { 29 bool basic_openid_message::has_ns(const string& uri) const {
54 fields_iterator ei = fields_end(); 30 fields_iterator ei = fields_end();
55 fields_iterator i = find_if(fields_begin(),fields_end(), 31 fields_iterator i = find_if(fields_begin(),fields_end(),
56 __om_ns_finder(*this,uri)); 32 __om_ns_finder(*this,uri));
57 return !(i==ei); 33 return !(i==ei);
58 } 34 }
59 string basic_openid_message::get_ns(const string& uri) const { 35 string basic_openid_message::get_ns(const string& uri) const {
60 fields_iterator ei = fields_end(); 36 fields_iterator ei = fields_end();
61 fields_iterator i = find_if(fields_begin(),fields_end(), 37 fields_iterator i = find_if(fields_begin(),fields_end(),
62 __om_ns_finder(*this,uri)); 38 __om_ns_finder(*this,uri));
63 if(i==ei) 39 if(i==ei)
64 throw failed_lookup(OPKELE_CP_ string("failed to find namespace ")+uri); 40 throw failed_lookup(OPKELE_CP_ string("failed to find namespace ")+uri);
65 return i->substr(3); 41 return i->substr(3);
66 } 42 }
67 43
68 struct __om_query_builder : public unary_function<const string&,void> {
69 public:
70 const basic_openid_message& om;
71 bool first;
72 string& rv;
73 const char *pfx;
74
75 __om_query_builder(const char *p,string& r,const basic_openid_message& m)
76 : om(m), first(true), rv(r), pfx(p) {
77 for_each(om.fields_begin(),om.fields_end(),*this);
78 }
79 __om_query_builder(const char *p,string& r,const basic_openid_message& m,const string& u)
80 : om(m), first(true), rv(r), pfx(p) {
81 rv = u;
82 if(rv.find('?')==string::npos)
83 rv += '?';
84 else
85 first = false;
86 for_each(om.fields_begin(),om.fields_end(),*this);
87 }
88
89 result_type operator()(argument_type f) {
90 if(first)
91 first = false;
92 else
93 rv += '&';
94 if(pfx) rv += pfx;
95 rv+= f;
96 rv += '=';
97 rv += util::url_encode(om.get_field(f));
98 }
99 };
100
101 string basic_openid_message::append_query(const string& url,const char *pfx) const {
102 string rv;
103 return __om_query_builder(pfx,rv,*this,url).rv;
104 }
105 string basic_openid_message::query_string(const char *pfx) const {
106 string rv;
107 return __om_query_builder(pfx,rv,*this).rv;
108 }
109
110 void basic_openid_message::reset_fields() {
111 throw not_implemented(OPKELE_CP_ "reset_fields() not implemented");
112 }
113 void basic_openid_message::set_field(const string&,const string&) {
114 throw not_implemented(OPKELE_CP_ "set_field() not implemented");
115 }
116 void basic_openid_message::reset_field(const string&) {
117 throw not_implemented(OPKELE_CP_ "reset_field() not implemented");
118 }
119
120 void basic_openid_message::from_keyvalues(const string& kv) { 44 void basic_openid_message::from_keyvalues(const string& kv) {
121 reset_fields(); 45 reset_fields();
122 string::size_type p = 0; 46 string::size_type p = 0;
123 while(true) { 47 while(true) {
124 string::size_type co = kv.find(':',p); 48 string::size_type co = kv.find(':',p);
125 if(co==string::npos) 49 if(co==string::npos)
126 break; 50 break;
127#ifndef POSTELS_LAW 51#ifndef POSTELS_LAW
128 string::size_type nl = kv.find('\n',co+1); 52 string::size_type nl = kv.find('\n',co+1);
129 if(nl==string::npos) 53 if(nl==string::npos)
130 throw bad_input(OPKELE_CP_ "malformed input"); 54 throw bad_input(OPKELE_CP_ "malformed input");
131 if(nl>co) 55 if(nl>co)
132 insert(value_type(kv.substr(p,co-p),kv.substr(co+1,nl-co-1))); 56 set_field(kv.substr(p,co-p),kv.substr(co+1,nl-co-1));
133 p = nl+1; 57 p = nl+1;
134#else /* POSTELS_LAW */ 58#else /* POSTELS_LAW */
135 string::size_type lb = kv.find_first_of("\r\n",co+1); 59 string::size_type lb = kv.find_first_of("\r\n",co+1);
136 if(lb==string::npos) { 60 if(lb==string::npos) {
137 set_field(kv.substr(p,co-p),kv.substr(co+1)); 61 set_field(kv.substr(p,co-p),kv.substr(co+1));
138 break; 62 break;
139 } 63 }
140 if(lb>co) 64 if(lb>co)
141 set_field(kv.substr(p,co-p),kv.substr(co+1,lb-co-1)); 65 set_field(kv.substr(p,co-p),kv.substr(co+1,lb-co-1));
142 string::size_type nolb = kv.find_first_not_of("\r\n",lb); 66 string::size_type nolb = kv.find_first_not_of("\r\n",lb);
143 if(nolb==string::npos) 67 if(nolb==string::npos)
144 break; 68 break;
145 p = nolb; 69 p = nolb;
146#endif /* POSTELS_LAW */ 70#endif /* POSTELS_LAW */
147 } 71 }
148 } 72 }
149 73
150 struct __om_kv_outputter : public unary_function<const string&,void> { 74 struct __om_kv_outputter : public unary_function<const string&,void> {
151 public: 75 public:
152 const basic_openid_message& om; 76 const basic_openid_message& om;
153 ostream& os; 77 ostream& os;
154 78
155 __om_kv_outputter(const basic_openid_message& m,ostream& s) 79 __om_kv_outputter(const basic_openid_message& m,ostream& s)
156 : om(m), os(s) { } 80 : om(m), os(s) { }
157 81
158 result_type operator()(argument_type f) { 82 result_type operator()(argument_type f) {
159 os << f << ':' << om.get_field(f) << '\n'; 83 os << f << ':' << om.get_field(f) << '\n';
160 } 84 }
161 }; 85 };
162 86
163 void basic_openid_message::to_keyvalues(ostream& o) const { 87 void basic_openid_message::to_keyvalues(ostream& o) const {
164 for_each(fields_begin(),fields_end(),__om_kv_outputter(*this,o)); 88 for_each(fields_begin(),fields_end(),__om_kv_outputter(*this,o));
165 } 89 }
166 90
167 struct __om_html_outputter : public unary_function<const string&,void> { 91 struct __om_html_outputter : public unary_function<const string&,void> {
168 public: 92 public:
169 const basic_openid_message& om; 93 const basic_openid_message& om;
170 ostream& os; 94 ostream& os;
171 const char *pfx; 95 const char *pfx;
172 96
173 __om_html_outputter(const basic_openid_message& m,ostream& s,const char *p=0) 97 __om_html_outputter(const basic_openid_message& m,ostream& s,const char *p=0)
174 : om(m), os(s), pfx(p) { } 98 : om(m), os(s), pfx(p) { }
175 99
176 result_type operator()(argument_type f) { 100 result_type operator()(argument_type f) {
177 os << 101 os <<
178 "<input type=\"hidden\"" 102 "<input type=\"hidden\""
179 " name=\""; 103 " name=\"";
180 if(pfx) 104 if(pfx)
@@ -195,82 +119,76 @@ namespace opkele {
195 string signeds; 119 string signeds;
196 try { 120 try {
197 signeds = get_field("signed"); 121 signeds = get_field("signed");
198 string::size_type lnc = signeds.find_last_not_of(","); 122 string::size_type lnc = signeds.find_last_not_of(",");
199 if(lnc==string::npos) 123 if(lnc==string::npos)
200 signeds.assign(fields,fnc,fields.size()-fnc); 124 signeds.assign(fields,fnc,fields.size()-fnc);
201 else{ 125 else{
202 string::size_type ss = signeds.size(); 126 string::size_type ss = signeds.size();
203 if(lnc==(ss-1)) { 127 if(lnc==(ss-1)) {
204 signeds+= ','; 128 signeds+= ',';
205 signeds.append(fields,fnc,fields.size()-fnc); 129 signeds.append(fields,fnc,fields.size()-fnc);
206 }else{ 130 }else{
207 if(lnc<(ss-2)) 131 if(lnc<(ss-2))
208 signeds.replace(lnc+2,ss-lnc-2, 132 signeds.replace(lnc+2,ss-lnc-2,
209 fields,fnc,fields.size()-fnc); 133 fields,fnc,fields.size()-fnc);
210 else 134 else
211 signeds.append(fields,fnc,fields.size()-fnc); 135 signeds.append(fields,fnc,fields.size()-fnc);
212 } 136 }
213 } 137 }
214 }catch(failed_lookup&) { 138 }catch(failed_lookup&) {
215 signeds.assign(fields,fnc,fields.size()-fnc); 139 signeds.assign(fields,fnc,fields.size()-fnc);
216 } 140 }
217 set_field("signed",signeds); 141 set_field("signed",signeds);
218 } 142 }
219 143
220 string basic_openid_message::find_ns(const string& uri,const char *pfx) const { 144 string basic_openid_message::find_ns(const string& uri,const char *pfx) const {
221 try { 145 try {
222 return get_ns(uri); 146 return get_ns(uri);
223 }catch(failed_lookup&) { 147 }catch(failed_lookup&) {
224 return pfx; 148 return pfx;
225 } 149 }
226 } 150 }
227 string basic_openid_message::allocate_ns(const string& uri,const char *pfx) { 151 string basic_openid_message::allocate_ns(const string& uri,const char *pfx) {
228 if(!has_field("ns")) 152 if(!has_field("ns"))
229 return pfx; 153 return pfx;
230 if(has_ns(uri)) 154 if(has_ns(uri))
231 throw bad_input(OPKELE_CP_ "OpenID message already contains namespace"); 155 throw bad_input(OPKELE_CP_ "OpenID message already contains namespace");
232 string rv = pfx; 156 string rv = pfx;
233 if(has_field("ns."+rv)) { 157 if(has_field("ns."+rv)) {
234 string::reference c=rv[rv.length()]; 158 string::reference c=rv[rv.length()];
235 for(c='a';c<='z' && has_field("ns."+rv);++c); 159 for(c='a';c<='z' && has_field("ns."+rv);++c);
236 if(c=='z') 160 if(c=='z')
237 throw exception(OPKELE_CP_ "Failed to allocate namespace"); 161 throw exception(OPKELE_CP_ "Failed to allocate namespace");
238 } 162 }
239 set_field("ns."+rv,uri); 163 set_field("ns."+rv,uri);
240 return rv; 164 return rv;
241 } 165 }
242 166
243 void openid_message_t::copy_to(basic_openid_message& x) const {
244 x.reset_fields();
245 for(const_iterator i=begin();i!=end();++i)
246 x.set_field(i->first,i->second);
247 }
248
249 bool openid_message_t::has_field(const string& n) const { 167 bool openid_message_t::has_field(const string& n) const {
250 return find(n)!=end(); 168 return find(n)!=end();
251 } 169 }
252 const string& openid_message_t::get_field(const string& n) const { 170 const string& openid_message_t::get_field(const string& n) const {
253 const_iterator i=find(n); 171 const_iterator i=find(n);
254 if(i==end()) 172 if(i==end())
255 throw failed_lookup(OPKELE_CP_ n+": no such field"); 173 throw failed_lookup(OPKELE_CP_ n+": no such field");
256 return i->second; 174 return i->second;
257 } 175 }
258 176
259 openid_message_t::fields_iterator openid_message_t::fields_begin() const { 177 openid_message_t::fields_iterator openid_message_t::fields_begin() const {
260 return util::map_keys_iterator<const_iterator,string,const string&,const string*>(begin(),end()); 178 return util::map_keys_iterator<const_iterator,string,const string&,const string*>(begin(),end());
261 } 179 }
262 openid_message_t::fields_iterator openid_message_t::fields_end() const { 180 openid_message_t::fields_iterator openid_message_t::fields_end() const {
263 return util::map_keys_iterator<const_iterator,string,const string&,const string*>(end(),end()); 181 return util::map_keys_iterator<const_iterator,string,const string&,const string*>(end(),end());
264 } 182 }
265 183
266 void openid_message_t::reset_fields() { 184 void openid_message_t::reset_fields() {
267 clear(); 185 clear();
268 } 186 }
269 void openid_message_t::set_field(const string& n,const string& v) { 187 void openid_message_t::set_field(const string& n,const string& v) {
270 (*this)[n]=v; 188 (*this)[n]=v;
271 } 189 }
272 void openid_message_t::reset_field(const string& n) { 190 void openid_message_t::reset_field(const string& n) {
273 erase(n); 191 erase(n);
274 } 192 }
275 193
276} 194}