summaryrefslogtreecommitdiffabout
path: root/include
Side-by-side diff
Diffstat (limited to 'include') (more/less context) (ignore whitespace changes)
-rw-r--r--include/Makefile.am8
-rw-r--r--include/opkele/openid_service_resolver.h118
-rw-r--r--include/opkele/uris.h10
3 files changed, 133 insertions, 3 deletions
diff --git a/include/Makefile.am b/include/Makefile.am
index 0385cfb..23c7e0d 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -11,7 +11,9 @@ nobase_include_HEADERS = \
opkele/extension_chain.h \
opkele/xconsumer.h \
- opkele/xserver.h
+ opkele/xserver.h \
+ opkele/curl.h opkele/expat.h \
+ opkele/openid_service_resolver.h \
+ opkele/uris.h
EXTRA_DIST = \
opkele/data.h \
- opkele/util.h \
- opkele/curl.h opkele/expat.h
+ opkele/util.h
diff --git a/include/opkele/openid_service_resolver.h b/include/opkele/openid_service_resolver.h
new file mode 100644
index 0000000..64edd28
--- a/dev/null
+++ b/include/opkele/openid_service_resolver.h
@@ -0,0 +1,118 @@
+#ifndef __OPKELE_OPENID_SERVICE_RESOLVER_H
+#define __OPKELE_OPENID_SERVICE_RESOLVER_H
+
+#include <climits>
+#include <string>
+#include <list>
+#include <set>
+#include <map>
+#include <opkele/curl.h>
+#include <opkele/expat.h>
+
+namespace opkele {
+ using std::list;
+ using std::string;
+ using std::set;
+ using std::map;
+
+ struct openid_auth_SEP_t {
+ long priority;
+ set<string> xrd_Type;
+ string xrd_URI;
+ string openid_Delegate;
+
+ openid_auth_SEP_t() : priority(LONG_MAX) { }
+ };
+
+ struct openid_auth_info_t {
+ string canonical_id;
+ openid_auth_SEP_t auth_SEP;
+ };
+
+
+ class openid_service_resolver_t : public util::curl_t, public util::expat_t {
+ public:
+ string xri_proxy;
+
+ openid_service_resolver_t(const string& xp="");
+ ~openid_service_resolver_t() throw() { }
+
+ const openid_auth_info_t& resolve(const string& id);
+
+ enum state_t {
+ state_parse = 0,
+ state_stopping_head, state_stopping_body,
+ state_stopping_size
+ };
+ state_t state;
+
+ struct parser_node_t {
+ string element;
+ string content;
+ typedef map<string,string> attrs_t;
+ attrs_t attrs;
+ bool skip_text, skip_tags;
+ openid_auth_info_t auth_info;
+
+ parser_node_t(const XML_Char *n,const XML_Char **a)
+ : skip_text(true), skip_tags(true)
+ {
+ element = n;
+ for(;*a;a+=2)
+ attrs[a[0]] = a[1];
+ }
+
+ };
+
+ class parser_tree_t : public list<parser_node_t> {
+ public:
+ const_reference top() const { return back(); }
+ reference top() { return back(); }
+
+ const_reference parent() const {
+ const_reverse_iterator rv = rbegin();
+ return *(++rv); }
+ reference parent() {
+ reverse_iterator rv = rbegin();
+ return *(++rv); }
+
+ inline void pop() { pop_back(); }
+ inline void push(const_reference e) { push_back(e); }
+
+ void push(const XML_Char *n,const XML_Char **a) {
+ parser_node_t nn(n,a);
+ if(empty())
+ nn.skip_text = nn.skip_tags = true;
+ else{
+ const_reference t = top();
+ nn.skip_text = t.skip_text; nn.skip_tags = t.skip_tags;
+ }
+ push(nn);
+ }
+ };
+ parser_tree_t tree;
+
+ void start_element(const XML_Char *n,const XML_Char **a);
+ void end_element(const XML_Char *n);
+ void character_data(const XML_Char *s,int l);
+
+ string xrds_location;
+ openid_auth_SEP_t html_SEP;
+ openid_auth_info_t auth_info;
+
+ void pop_tag();
+
+ size_t write(void *p,size_t s,size_t nm);
+
+ string http_content_type;
+
+ size_t header(void *p,size_t s,size_t nm);
+
+ bool xri_mode;
+
+ void discover_service(const string& url,bool xri=false);
+ };
+
+}
+
+#endif /* __OPKELE_OPENID_SERVICE_RESOLVER_H */
diff --git a/include/opkele/uris.h b/include/opkele/uris.h
new file mode 100644
index 0000000..9a6a3cd
--- a/dev/null
+++ b/include/opkele/uris.h
@@ -0,0 +1,10 @@
+#ifndef __OPKELE_URIS_H
+#define __OPKELE_URIS_H
+
+#define NSURI_XRDS "xri://$xrds"
+#define NSURI_XRD "xri://$xrd*($v*2.0)"
+#define NSURI_OPENID10 "http://openid.net/xmlns/1.0"
+
+#define STURI_OPENID10 "http://openid.net/signon/1.0"
+
+#endif /* __OPKELE_URIS_H */