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/discovery.h33
-rw-r--r--include/opkele/exception.h19
-rw-r--r--include/opkele/expat.h91
-rw-r--r--include/opkele/types.h63
-rw-r--r--include/opkele/uris.h15
6 files changed, 226 insertions, 3 deletions
diff --git a/include/Makefile.am b/include/Makefile.am
index b31786d..0c2928d 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -10,8 +10,10 @@ nobase_include_HEADERS = \
opkele/sreg.h \
opkele/extension_chain.h \
opkele/xconsumer.h \
- opkele/xserver.h
+ opkele/xserver.h \
+ opkele/curl.h opkele/expat.h \
+ opkele/discovery.h \
+ opkele/uris.h
EXTRA_DIST = \
opkele/data.h \
- opkele/util.h \
- opkele/curl.h
+ opkele/util.h
diff --git a/include/opkele/discovery.h b/include/opkele/discovery.h
new file mode 100644
index 0000000..5d7129b
--- a/dev/null
+++ b/include/opkele/discovery.h
@@ -0,0 +1,33 @@
+#ifndef __OPKELE_DISCOVERY_H
+#define __OPKELE_DISCOVERY_H
+
+#include <string>
+#include <opkele/types.h>
+
+namespace opkele {
+ using std::string;
+
+ struct idiscovery_t;
+
+ void idiscover(idiscovery_t& result,const string& identity);
+
+ struct idiscovery_t {
+ string normalized_id;
+ string canonicalized_id;
+ xrd::XRD_t xrd;
+
+ idiscovery_t(const string& i) {
+ idiscover(*this,i);
+ }
+ idiscovery_t(const char *i) {
+ idiscover(*this,i);
+ }
+
+ void clear() {
+ normalized_id.clear(); canonicalized_id.clear();
+ xrd.clear();
+ }
+ };
+}
+
+#endif /* __OPKELE_DISCOVERY_H */
diff --git a/include/opkele/exception.h b/include/opkele/exception.h
index 2ff44b7..8913665 100644
--- a/include/opkele/exception.h
+++ b/include/opkele/exception.h
@@ -212,6 +212,25 @@ namespace opkele {
};
/**
+ * exception thrown in case of failed discovery
+ */
+ class failed_discovery : public exception {
+ public:
+ failed_discovery(OPKELE_E_PARS)
+ : exception(OPKELE_E_CONS) { }
+ };
+
+ /**
+ * unsuccessfull xri resolution
+ */
+ class failed_xri_resolution : public failed_discovery {
+ public:
+ long _code;
+ failed_xri_resolution(OPKELE_E_PARS,long _c=-1)
+ : failed_discovery(OPKELE_E_CONS), _code(_c) { }
+ };
+
+ /**
* not implemented (think pure virtual) member function executed, signfies
* programmer error
*/
diff --git a/include/opkele/expat.h b/include/opkele/expat.h
new file mode 100644
index 0000000..60c41ac
--- a/dev/null
+++ b/include/opkele/expat.h
@@ -0,0 +1,91 @@
+#ifndef __OPKELE_EXPAT_H
+#define __OPKELE_EXPAT_H
+
+#include <cassert>
+#include <expat.h>
+
+namespace opkele {
+
+ namespace util {
+
+ class expat_t {
+ public:
+ XML_Parser _x;
+
+ expat_t() : _x(0) { }
+ expat_t(XML_Parser x) : _x(x) { }
+ virtual ~expat_t() throw();
+
+ expat_t& operator=(XML_Parser x);
+
+ operator const XML_Parser(void) const { return _x; }
+ operator XML_Parser(void) { return _x; }
+
+ inline bool parse(const char *s,int len,bool final=false) {
+ assert(_x);
+ return XML_Parse(_x,s,len,final);
+ }
+
+ virtual void start_element(const XML_Char *n,const XML_Char **a) { }
+ virtual void end_element(const XML_Char *n) { }
+ void set_element_handler();
+
+ virtual void character_data(const XML_Char *s,int l) { }
+ void set_character_data_handler();
+
+ virtual void processing_instruction(const XML_Char *t,const XML_Char *d) { }
+ void set_processing_instruction_handler();
+
+ virtual void comment(const XML_Char *d) { }
+ void set_comment_handler();
+
+ virtual void start_cdata_section() { }
+ virtual void end_cdata_section() { }
+ void set_cdata_section_handler();
+
+ virtual void default_handler(const XML_Char *s,int l) { }
+ void set_default_handler();
+ void set_default_handler_expand();
+
+ virtual void start_namespace_decl(const XML_Char *p,const XML_Char *u) { }
+ virtual void end_namespace_decl(const XML_Char *p) { }
+ void set_namespace_decl_handler();
+
+ inline enum XML_Error get_error_code() {
+ assert(_x); return XML_GetErrorCode(_x); }
+ static inline const XML_LChar *error_string(XML_Error c) {
+ return XML_ErrorString(c); }
+
+ inline long get_current_byte_index() {
+ assert(_x); return XML_GetCurrentByteIndex(_x); }
+ inline int get_current_line_number() {
+ assert(_x); return XML_GetCurrentLineNumber(_x); }
+ inline int get_current_column_number() {
+ assert(_x); return XML_GetCurrentColumnNumber(_x); }
+
+ inline void set_user_data() {
+ assert(_x); XML_SetUserData(_x,this); }
+
+ inline bool set_base(const XML_Char *b) {
+ assert(_x); return XML_SetBase(_x,b); }
+ inline const XML_Char *get_base() {
+ assert(_x); return XML_GetBase(_x); }
+
+ inline int get_specified_attribute_count() {
+ assert(_x); return XML_GetSpecifiedAttributeCount(_x); }
+
+ inline bool set_param_entity_parsing(enum XML_ParamEntityParsing c) {
+ assert(_x); return XML_SetParamEntityParsing(_x,c); }
+
+ inline static XML_Parser parser_create(const XML_Char *e=0) {
+ return XML_ParserCreate(e); }
+ inline static XML_Parser parser_create_ns(const XML_Char *e=0,XML_Char s='\t') {
+ return XML_ParserCreateNS(e,s); }
+
+ };
+
+ }
+
+}
+
+#endif /* __OPKELE_EXPAT_H */
diff --git a/include/opkele/types.h b/include/opkele/types.h
index f732a1e..520618d 100644
--- a/include/opkele/types.h
+++ b/include/opkele/types.h
@@ -11,6 +11,7 @@
#include <string>
#include <map>
#include <memory>
+#include <set>
namespace opkele {
using std::vector;
@@ -18,6 +19,8 @@ namespace opkele {
using std::map;
using std::ostream;
using std::auto_ptr;
+ using std::multimap;
+ using std::set;
/**
* the OpenID operation mode
@@ -167,6 +170,66 @@ namespace opkele {
*/
ostream& operator << (ostream& o,const params_t& p);
+ namespace xrd {
+
+ struct priority_compare {
+ inline bool operator()(long a,long b) const {
+ return (a<0) ? false : (b<0) ? false : (a<b);
+ }
+ };
+
+ template <typename _DT>
+ class priority_map : public multimap<long,_DT,priority_compare> {
+ typedef multimap<long,_DT,priority_compare> map_type;
+ public:
+
+ inline _DT& add(long priority,const _DT& d) {
+ return insert(typename map_type::value_type(priority,d))->second;
+ }
+ };
+
+ typedef priority_map<string> canonical_ids_t;
+ typedef priority_map<string> local_ids_t;
+ typedef set<string> types_t;
+ typedef priority_map<string> uris_t;
+
+ class service_t {
+ public:
+ types_t types;
+ uris_t uris;
+ local_ids_t local_ids;
+
+ void clear() {
+ types.clear();
+ uris.clear(); local_ids.clear();
+ }
+ };
+ typedef priority_map<service_t> services_t;
+
+ class XRD_t {
+ public:
+ time_t expires;
+
+ canonical_ids_t canonical_ids;
+ local_ids_t local_ids;
+ services_t services;
+
+ void clear() {
+ expires = 0;
+ canonical_ids.clear(); local_ids.clear();
+ services.clear();
+ }
+ bool empty() const {
+ return
+ canonical_ids.empty()
+ && local_ids.empty()
+ && services.empty();
+ }
+
+ };
+
+ }
+
}
#endif /* __OPKELE_TYPES_H */
diff --git a/include/opkele/uris.h b/include/opkele/uris.h
new file mode 100644
index 0000000..a432b13
--- a/dev/null
+++ b/include/opkele/uris.h
@@ -0,0 +1,15 @@
+#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"
+#define STURI_OPENID11 "http://openid.net/signon/1.1"
+#define STURI_OPENID20 "http://specs.openid.net/auth/2.0/signon"
+#define STURI_OPENID20_OP "http://specs.openid.net/auth/2.0/server"
+
+#define IDURI_SELECT20 "http://specs.openid.net/auth/2.0/identifier_select"
+
+#endif /* __OPKELE_URIS_H */