Diffstat (limited to 'include/opkele/openid_service_resolver.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | include/opkele/openid_service_resolver.h | 118 |
1 files changed, 0 insertions, 118 deletions
diff --git a/include/opkele/openid_service_resolver.h b/include/opkele/openid_service_resolver.h deleted file mode 100644 index 64edd28..0000000 --- a/include/opkele/openid_service_resolver.h +++ b/dev/null | |||
@@ -1,118 +0,0 @@ | |||
1 | #ifndef __OPKELE_OPENID_SERVICE_RESOLVER_H | ||
2 | #define __OPKELE_OPENID_SERVICE_RESOLVER_H | ||
3 | |||
4 | #include <climits> | ||
5 | #include <string> | ||
6 | #include <list> | ||
7 | #include <set> | ||
8 | #include <map> | ||
9 | #include <opkele/curl.h> | ||
10 | #include <opkele/expat.h> | ||
11 | |||
12 | namespace opkele { | ||
13 | using std::list; | ||
14 | using std::string; | ||
15 | using std::set; | ||
16 | using std::map; | ||
17 | |||
18 | struct openid_auth_SEP_t { | ||
19 | long priority; | ||
20 | set<string> xrd_Type; | ||
21 | string xrd_URI; | ||
22 | string openid_Delegate; | ||
23 | |||
24 | openid_auth_SEP_t() : priority(LONG_MAX) { } | ||
25 | }; | ||
26 | |||
27 | struct openid_auth_info_t { | ||
28 | string canonical_id; | ||
29 | openid_auth_SEP_t auth_SEP; | ||
30 | }; | ||
31 | |||
32 | |||
33 | class openid_service_resolver_t : public util::curl_t, public util::expat_t { | ||
34 | public: | ||
35 | string xri_proxy; | ||
36 | |||
37 | openid_service_resolver_t(const string& xp=""); | ||
38 | ~openid_service_resolver_t() throw() { } | ||
39 | |||
40 | const openid_auth_info_t& resolve(const string& id); | ||
41 | |||
42 | enum state_t { | ||
43 | state_parse = 0, | ||
44 | state_stopping_head, state_stopping_body, | ||
45 | state_stopping_size | ||
46 | }; | ||
47 | state_t state; | ||
48 | |||
49 | struct parser_node_t { | ||
50 | string element; | ||
51 | string content; | ||
52 | typedef map<string,string> attrs_t; | ||
53 | attrs_t attrs; | ||
54 | bool skip_text, skip_tags; | ||
55 | openid_auth_info_t auth_info; | ||
56 | |||
57 | parser_node_t(const XML_Char *n,const XML_Char **a) | ||
58 | : skip_text(true), skip_tags(true) | ||
59 | { | ||
60 | element = n; | ||
61 | for(;*a;a+=2) | ||
62 | attrs[a[0]] = a[1]; | ||
63 | } | ||
64 | |||
65 | }; | ||
66 | |||
67 | class parser_tree_t : public list<parser_node_t> { | ||
68 | public: | ||
69 | const_reference top() const { return back(); } | ||
70 | reference top() { return back(); } | ||
71 | |||
72 | const_reference parent() const { | ||
73 | const_reverse_iterator rv = rbegin(); | ||
74 | return *(++rv); } | ||
75 | reference parent() { | ||
76 | reverse_iterator rv = rbegin(); | ||
77 | return *(++rv); } | ||
78 | |||
79 | inline void pop() { pop_back(); } | ||
80 | inline void push(const_reference e) { push_back(e); } | ||
81 | |||
82 | void push(const XML_Char *n,const XML_Char **a) { | ||
83 | parser_node_t nn(n,a); | ||
84 | if(empty()) | ||
85 | nn.skip_text = nn.skip_tags = true; | ||
86 | else{ | ||
87 | const_reference t = top(); | ||
88 | nn.skip_text = t.skip_text; nn.skip_tags = t.skip_tags; | ||
89 | } | ||
90 | push(nn); | ||
91 | } | ||
92 | }; | ||
93 | parser_tree_t tree; | ||
94 | |||
95 | void start_element(const XML_Char *n,const XML_Char **a); | ||
96 | void end_element(const XML_Char *n); | ||
97 | void character_data(const XML_Char *s,int l); | ||
98 | |||
99 | string xrds_location; | ||
100 | openid_auth_SEP_t html_SEP; | ||
101 | openid_auth_info_t auth_info; | ||
102 | |||
103 | void pop_tag(); | ||
104 | |||
105 | size_t write(void *p,size_t s,size_t nm); | ||
106 | |||
107 | string http_content_type; | ||
108 | |||
109 | size_t header(void *p,size_t s,size_t nm); | ||
110 | |||
111 | bool xri_mode; | ||
112 | |||
113 | void discover_service(const string& url,bool xri=false); | ||
114 | }; | ||
115 | |||
116 | } | ||
117 | |||
118 | #endif /* __OPKELE_OPENID_SERVICE_RESOLVER_H */ | ||