summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--include/Makefile.am3
-rw-r--r--include/opkele/extension_chain.h50
-rw-r--r--lib/Makefile.am3
-rw-r--r--lib/extension_chain.cc16
4 files changed, 70 insertions, 2 deletions
diff --git a/include/Makefile.am b/include/Makefile.am
index 4b9b02a..2c190b8 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -1,13 +1,14 @@
nobase_include_HEADERS = \
opkele/acconfig.h \
opkele/opkele-config.h \
opkele/types.h \
opkele/association.h \
opkele/exception.h \
opkele/server.h \
opkele/consumer.h \
opkele/extension.h \
- opkele/sreg.h
+ opkele/sreg.h \
+ opkele/extension_chain.h
EXTRA_DIST = \
opkele/data.h \
opkele/util.h
diff --git a/include/opkele/extension_chain.h b/include/opkele/extension_chain.h
new file mode 100644
index 0000000..955f4d5
--- a/dev/null
+++ b/include/opkele/extension_chain.h
@@ -0,0 +1,50 @@
+#ifndef __OPKELE_EXTENSION_CHAIN_H
+#define __OPKELE_EXTENSION_CHAIN_H
+
+/**
+ * @file
+ * @brief extension chain extension
+ */
+
+#include <list>
+#include <opkele/extension.h>
+
+/**
+ * @brief the main opkele namespace
+ */
+namespace opkele {
+ using std::list;
+
+ /**
+ * OpenID extensions chain used to combine extensions, it is actually an
+ * stl list of pointers to extensions.
+ */
+ class extension_chain_t : public extension_t, public list<extension_t*> {
+ public:
+
+ /**
+ * Default constructor creates an empty chain
+ */
+ extension_chain_t() { }
+ /**
+ * Create extension chain with a single extension in it
+ */
+ extension_chain_t(extension_t *e) { push_back(e); }
+
+ /**
+ * Implementation of consumer's checkid hook
+ */
+ virtual void checkid_hook(params_t& p,const string& identity);
+ /**
+ * Implementation of consumer's id_res hook
+ */
+ virtual void id_res_hook(const params_t& p,const params_t& sp,const string& identity);
+ /**
+ * Implementation of server's checkid_hook
+ */
+ virtual void checkid_hook(const params_t& pin,params_t& pout);
+ };
+
+}
+
+#endif /* __OPKELE_EXTENSION_CHAIN_H */
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 783f2ab..bdadd44 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -10,19 +10,20 @@ INCLUDES = \
LDADD = \
${LIBCURL} \
${PCREPP_LIBS} \
${MIMETIC_LIBS} \
${OPENSSL_LIBS} \
${KONFORKA_LIBS}
libopkele_la_SOURCES = \
params.cc \
util.cc \
server.cc \
secret.cc \
data.cc \
consumer.cc \
exception.cc \
extension.cc \
- sreg.cc
+ sreg.cc \
+ extension_chain.cc
libopkele_la_LDFLAGS = \
-version-info 1:0:0
diff --git a/lib/extension_chain.cc b/lib/extension_chain.cc
new file mode 100644
index 0000000..16537dc
--- a/dev/null
+++ b/lib/extension_chain.cc
@@ -0,0 +1,16 @@
+#include <cstdarg>
+#include <opkele/extension_chain.h>
+
+namespace opkele {
+
+ void extension_chain_t::checkid_hook(params_t& p,const string& identity) {
+ for(iterator i=begin();i!=end();++i) (*i)->checkid_hook(p,identity);
+ }
+ void extension_chain_t::id_res_hook(const params_t& p,const params_t& sp,const string& identity) {
+ for(iterator i=begin();i!=end();++i) (*i)->id_res_hook(p,sp,identity);
+ }
+ void extension_chain_t::checkid_hook(const params_t& pin,params_t& pout) {
+ for(iterator i=begin();i!=end();++i) (*i)->checkid_hook(pin,pout);
+ }
+
+}