-rw-r--r-- | lib/message.cc | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/message.cc b/lib/message.cc index b2324b7..524946a 100644 --- a/lib/message.cc +++ b/lib/message.cc | |||
@@ -1,49 +1,51 @@ | |||
1 | #include <cassert> | 1 | #include <cassert> |
2 | #include <algorithm> | ||
3 | |||
2 | #include <opkele/types.h> | 4 | #include <opkele/types.h> |
3 | #include <opkele/exception.h> | 5 | #include <opkele/exception.h> |
4 | #include <opkele/util.h> | 6 | #include <opkele/util.h> |
5 | #include <opkele/debug.h> | 7 | #include <opkele/debug.h> |
6 | 8 | ||
7 | #include "config.h" | 9 | #include "config.h" |
8 | 10 | ||
9 | namespace opkele { | 11 | namespace opkele { |
10 | using std::input_iterator_tag; | 12 | using std::input_iterator_tag; |
11 | using std::unary_function; | 13 | using std::unary_function; |
12 | 14 | ||
13 | 15 | ||
14 | struct __om_ns_finder : public unary_function<const string&,bool> { | 16 | struct __om_ns_finder : public unary_function<const string&,bool> { |
15 | public: | 17 | public: |
16 | const basic_openid_message& om; | 18 | const basic_openid_message& om; |
17 | const string& uri; | 19 | const string& uri; |
18 | 20 | ||
19 | __om_ns_finder(const basic_openid_message& m, | 21 | __om_ns_finder(const basic_openid_message& m, |
20 | const string& u) : om(m), uri(u) { } | 22 | const string& u) : om(m), uri(u) { } |
21 | 23 | ||
22 | result_type operator()(argument_type f) { | 24 | result_type operator()(argument_type f) { |
23 | return | 25 | return |
24 | (!strncmp(f.c_str(),"ns.",sizeof("ns.")-1)) | 26 | (!strncmp(f.c_str(),"ns.",sizeof("ns.")-1)) |
25 | && om.get_field(f)==uri ; | 27 | && om.get_field(f)==uri ; |
26 | } | 28 | } |
27 | }; | 29 | }; |
28 | 30 | ||
29 | bool basic_openid_message::has_ns(const string& uri) const { | 31 | bool basic_openid_message::has_ns(const string& uri) const { |
30 | fields_iterator ei = fields_end(); | 32 | fields_iterator ei = fields_end(); |
31 | fields_iterator i = find_if(fields_begin(),fields_end(), | 33 | fields_iterator i = find_if(fields_begin(),fields_end(), |
32 | __om_ns_finder(*this,uri)); | 34 | __om_ns_finder(*this,uri)); |
33 | return !(i==ei); | 35 | return !(i==ei); |
34 | } | 36 | } |
35 | string basic_openid_message::get_ns(const string& uri) const { | 37 | string basic_openid_message::get_ns(const string& uri) const { |
36 | fields_iterator ei = fields_end(); | 38 | fields_iterator ei = fields_end(); |
37 | fields_iterator i = find_if(fields_begin(),fields_end(), | 39 | fields_iterator i = find_if(fields_begin(),fields_end(), |
38 | __om_ns_finder(*this,uri)); | 40 | __om_ns_finder(*this,uri)); |
39 | if(i==ei) | 41 | if(i==ei) |
40 | throw failed_lookup(OPKELE_CP_ string("failed to find namespace ")+uri); | 42 | throw failed_lookup(OPKELE_CP_ string("failed to find namespace ")+uri); |
41 | return i->substr(3); | 43 | return i->substr(3); |
42 | } | 44 | } |
43 | 45 | ||
44 | void basic_openid_message::from_keyvalues(const string& kv) { | 46 | void basic_openid_message::from_keyvalues(const string& kv) { |
45 | reset_fields(); | 47 | reset_fields(); |
46 | string::size_type p = 0; | 48 | string::size_type p = 0; |
47 | while(true) { | 49 | while(true) { |
48 | string::size_type co = kv.find(':',p); | 50 | string::size_type co = kv.find(':',p); |
49 | if(co==string::npos) | 51 | if(co==string::npos) |