summaryrefslogtreecommitdiffabout
path: root/include/opkele
authorMichael Krelin <hacker@klever.net>2007-01-11 00:57:06 (UTC)
committer Michael Krelin <hacker@klever.net>2007-01-11 00:57:06 (UTC)
commit06eaf00c48fc563245b85c2be4b8b5a03ef2cfe9 (patch) (unidiff)
treeef978c5d86188d2fc4c7e98a921804d7bfeb5557 /include/opkele
parent100199abfdf7a353f9ba2aa9618e0711213290d3 (diff)
downloadlibopkele-06eaf00c48fc563245b85c2be4b8b5a03ef2cfe9.zip
libopkele-06eaf00c48fc563245b85c2be4b8b5a03ef2cfe9.tar.gz
libopkele-06eaf00c48fc563245b85c2be4b8b5a03ef2cfe9.tar.bz2
introduced extension hooks framework
Diffstat (limited to 'include/opkele') (more/less context) (ignore whitespace changes)
-rw-r--r--include/opkele/consumer.h25
-rw-r--r--include/opkele/exception.h10
-rw-r--r--include/opkele/extension.h59
-rw-r--r--include/opkele/server.h10
4 files changed, 90 insertions, 14 deletions
diff --git a/include/opkele/consumer.h b/include/opkele/consumer.h
index 9932315..f9939cf 100644
--- a/include/opkele/consumer.h
+++ b/include/opkele/consumer.h
@@ -4,2 +4,3 @@
4#include <opkele/types.h> 4#include <opkele/types.h>
5#include <opkele/extension.h>
5 6
@@ -84,2 +85,3 @@ namespace opkele {
84 * @param trust_root the trust root to advertise with the request 85 * @param trust_root the trust root to advertise with the request
86 * @param ext pointer to an extension(s) hooks object
85 * @return the location string 87 * @return the location string
@@ -87,3 +89,3 @@ namespace opkele {
87 */ 89 */
88 string checkid_immediate(const string& identity,const string& return_to,const string& trust_root=""); 90 string checkid_immediate(const string& identity,const string& return_to,const string& trust_root="",extension_t *ext=0);
89 /** 91 /**
@@ -94,2 +96,3 @@ namespace opkele {
94 * @param trust_root the trust root to advertise with the request 96 * @param trust_root the trust root to advertise with the request
97 * @param ext pointer to an extension(s) hooks object
95 * @return the location string 98 * @return the location string
@@ -97,3 +100,3 @@ namespace opkele {
97 */ 100 */
98 string checkid_setup(const string& identity,const string& return_to,const string& trust_root=""); 101 string checkid_setup(const string& identity,const string& return_to,const string& trust_root="",extension_t *ext=0);
99 /** 102 /**
@@ -105,2 +108,3 @@ namespace opkele {
105 * @param trust_root the trust root to advertise with the request 108 * @param trust_root the trust root to advertise with the request
109 * @param ext pointer to an extension(s) hooks object
106 * @return the location string 110 * @return the location string
@@ -108,3 +112,3 @@ namespace opkele {
108 */ 112 */
109 string checkid_(mode_t mode,const string& identity,const string& return_to,const string& trust_root=""); 113 string checkid_(mode_t mode,const string& identity,const string& return_to,const string& trust_root="",extension_t *ext=0);
110 /** 114 /**
@@ -112,9 +116,8 @@ namespace opkele {
112 * @param pin the response parameters 116 * @param pin the response parameters
113 * @param identity the identity being checked (if not specified, extracted 117 * @param identity the identity being checked (if not specified,
114 * from the openid.identity parameter 118 * @param ext pointer to an extension(s) hooks object
115 * @throw id_res_mismatch in case of signature 119 * extracted from the openid.identity parameter
116 * mismatch 120 * @throw id_res_mismatch in case of signature mismatch
117 * @throw id_res_setup in case of 121 * @throw id_res_setup in case of openid.user_setup_url failure
118 * openid.user_setup_url failure (supposedly 122 * (supposedly checkid_immediate only)
119 * checkid_immediate only)
120 * @throw id_res_failed in case of failure 123 * @throw id_res_failed in case of failure
@@ -122,3 +125,3 @@ namespace opkele {
122 */ 125 */
123 void id_res(const params_t& pin,const string& identity=""); 126 void id_res(const params_t& pin,const string& identity="",extension_t *ext=0);
124 /** 127 /**
diff --git a/include/opkele/exception.h b/include/opkele/exception.h
index c5f5811..9fc9bd3 100644
--- a/include/opkele/exception.h
+++ b/include/opkele/exception.h
@@ -207,2 +207,12 @@ namespace opkele {
207 207
208 /**
209 * not implemented (think pure virtual) member function executed, signfies
210 * programmer error
211 */
212 class not_implemented : public exception {
213 public:
214 not_implemented(OPKELE_E_PARS)
215 : exception(OPKELE_E_CONS) { }
216 };
217
208} 218}
diff --git a/include/opkele/extension.h b/include/opkele/extension.h
new file mode 100644
index 0000000..3fb5f6e
--- a/dev/null
+++ b/include/opkele/extension.h
@@ -0,0 +1,59 @@
1#ifndef __OPKELE_EXTENSIONS_H
2#define __OPKELE_EXTENSIONS_H
3
4/**
5 * @file
6 * @brief extensions framework basics
7 */
8
9#include <opkele/types.h>
10
11/**
12 * @brief the main opkele namespace
13 */
14namespace opkele {
15
16 /**
17 * OpenID consumer extension hooks base class
18 */
19 class extension_t {
20 public:
21 /**
22 * hook called by consumer before submitting data to OpenID server.
23 * It is supposed to manipulate parameters list.
24 * @param p parameters about to be submitted to server
25 * @param identity identity being verified. It may differ from the
26 * one available in parameters list in case of delegation
27 */
28 virtual void checkid_hook(params_t& p,const string& identity);
29 /**
30 * hook called by consumer after identity information received from
31 * OpenID server is verified.
32 * @param p parameters received from server
33 * @param sp signed parameters received from server with 'openid.'
34 * leader stripped
35 * @param identity identity confirmed. May differ from the one
36 * available in parameters list in case of delegation. May also be
37 * empty which means - extract one from parameters
38 */
39 virtual void id_res_hook(const params_t& p,const params_t& sp,const string& identity);
40
41 /**
42 * hook called by server before returning information to consumer.
43 * The hook may manipulate output parameters. It is important to
44 * note that modified pout["signed"] is used for signing response.
45 * @param pin request parameters list
46 * @param put response parameters list
47 */
48 virtual void checkid_hook(const params_t& pin,params_t& pout);
49
50 /**
51 * Casts the object to pointer to itself. For convenient passing
52 * of pointer.
53 */
54 operator extension_t*(void) { return this; }
55 };
56
57}
58
59#endif /* __OPKELE_EXTENSIONS_H */
diff --git a/include/opkele/server.h b/include/opkele/server.h
index fe07448..bf131d8 100644
--- a/include/opkele/server.h
+++ b/include/opkele/server.h
@@ -9,2 +9,3 @@
9#include <opkele/types.h> 9#include <opkele/types.h>
10#include <opkele/extension.h>
10 11
@@ -62,5 +63,6 @@ namespace opkele {
62 * @param pout the response parameters 63 * @param pout the response parameters
64 * @param ext pointer to the extension hooks object
63 * @throw exception in case of errors or negative reply 65 * @throw exception in case of errors or negative reply
64 */ 66 */
65 void checkid_immediate(const params_t& pin,string& return_to,params_t& pout); 67 void checkid_immediate(const params_t& pin,string& return_to,params_t& pout,extension_t *ext=0);
66 /** 68 /**
@@ -70,5 +72,6 @@ namespace opkele {
70 * @param pout the response parameters 72 * @param pout the response parameters
73 * @param ext pointer to the extension hooks object
71 * @throw exception in case of errors or negative reply 74 * @throw exception in case of errors or negative reply
72 */ 75 */
73 void checkid_setup(const params_t& pin,string& return_to,params_t& pout); 76 void checkid_setup(const params_t& pin,string& return_to,params_t& pout,extension_t *ext=0);
74 /** 77 /**
@@ -81,5 +84,6 @@ namespace opkele {
81 * @param pout the response parameters 84 * @param pout the response parameters
85 * @param ext pointer to the extension hooks object
82 * @throw exception in case of errors or negative reply 86 * @throw exception in case of errors or negative reply
83 */ 87 */
84 void checkid_(mode_t mode,const params_t& pin,string& return_to,params_t& pout); 88 void checkid_(mode_t mode,const params_t& pin,string& return_to,params_t& pout,extension_t *ext=0);
85 /** 89 /**