-rw-r--r-- | include/opkele/consumer.h | 3 |
1 files changed, 0 insertions, 3 deletions
diff --git a/include/opkele/consumer.h b/include/opkele/consumer.h index f32509e..fdb6119 100644 --- a/include/opkele/consumer.h +++ b/include/opkele/consumer.h | |||
@@ -1,145 +1,142 @@ | |||
1 | #ifndef __OPKELE_CONSUMER_H | 1 | #ifndef __OPKELE_CONSUMER_H |
2 | #define __OPKELE_CONSUMER_H | 2 | #define __OPKELE_CONSUMER_H |
3 | 3 | ||
4 | #include <opkele/types.h> | 4 | #include <opkele/types.h> |
5 | #include <opkele/extension.h> | 5 | #include <opkele/extension.h> |
6 | 6 | ||
7 | /** | 7 | /** |
8 | * @file | 8 | * @file |
9 | * @brief OpenID consumer-side functionality | 9 | * @brief OpenID consumer-side functionality |
10 | */ | 10 | */ |
11 | 11 | ||
12 | /** | ||
13 | * @brief the main opkele namespace | ||
14 | */ | ||
15 | namespace opkele { | 12 | namespace opkele { |
16 | 13 | ||
17 | /** | 14 | /** |
18 | * implementation of basic consumer functionality | 15 | * implementation of basic consumer functionality |
19 | */ | 16 | */ |
20 | class consumer_t { | 17 | class consumer_t { |
21 | public: | 18 | public: |
22 | 19 | ||
23 | /** | 20 | /** |
24 | * store association. The function should be overridden in the real | 21 | * store association. The function should be overridden in the real |
25 | * implementation to provide persistent associations store. | 22 | * implementation to provide persistent associations store. |
26 | * @param server the OpenID server | 23 | * @param server the OpenID server |
27 | * @param handle association handle | 24 | * @param handle association handle |
28 | * @param secret the secret associated with the server and handle | 25 | * @param secret the secret associated with the server and handle |
29 | * @param expires_in the number of seconds until the handle is expired | 26 | * @param expires_in the number of seconds until the handle is expired |
30 | * @return the auto_ptr<> for the newly allocated association_t object | 27 | * @return the auto_ptr<> for the newly allocated association_t object |
31 | */ | 28 | */ |
32 | virtual assoc_t store_assoc(const string& server,const string& handle,const secret_t& secret,int expires_in) = 0; | 29 | virtual assoc_t store_assoc(const string& server,const string& handle,const secret_t& secret,int expires_in) = 0; |
33 | /** | 30 | /** |
34 | * retrieve stored association. The function should be overridden | 31 | * retrieve stored association. The function should be overridden |
35 | * in the real implementation to provide persistent assocations | 32 | * in the real implementation to provide persistent assocations |
36 | * store. | 33 | * store. |
37 | * @param server the OpenID server | 34 | * @param server the OpenID server |
38 | * @param handle association handle | 35 | * @param handle association handle |
39 | * @return the autho_ptr<> for the newly allocated association_t object | 36 | * @return the autho_ptr<> for the newly allocated association_t object |
40 | * @throw failed_lookup in case of error | 37 | * @throw failed_lookup in case of error |
41 | */ | 38 | */ |
42 | virtual assoc_t retrieve_assoc(const string& server,const string& handle) = 0; | 39 | virtual assoc_t retrieve_assoc(const string& server,const string& handle) = 0; |
43 | /** | 40 | /** |
44 | * invalidate stored association. The function should be overridden | 41 | * invalidate stored association. The function should be overridden |
45 | * in the real implementation of the consumer. | 42 | * in the real implementation of the consumer. |
46 | * @param server the OpenID server | 43 | * @param server the OpenID server |
47 | * @param handle association handle | 44 | * @param handle association handle |
48 | */ | 45 | */ |
49 | virtual void invalidate_assoc(const string& server,const string& handle) = 0; | 46 | virtual void invalidate_assoc(const string& server,const string& handle) = 0; |
50 | /** | 47 | /** |
51 | * retrieve any unexpired association for the server. If the | 48 | * retrieve any unexpired association for the server. If the |
52 | * function is not overridden in the real implementation, the new | 49 | * function is not overridden in the real implementation, the new |
53 | * association will be established for each request. | 50 | * association will be established for each request. |
54 | * @param server the OpenID server | 51 | * @param server the OpenID server |
55 | * @return the auto_ptr<> for the newly allocated association_t object | 52 | * @return the auto_ptr<> for the newly allocated association_t object |
56 | * @throw failed_lookup in case of absence of the handle | 53 | * @throw failed_lookup in case of absence of the handle |
57 | */ | 54 | */ |
58 | virtual assoc_t find_assoc(const string& server); | 55 | virtual assoc_t find_assoc(const string& server); |
59 | 56 | ||
60 | /** | 57 | /** |
61 | * retrieve the metainformation contained in link tags from the | 58 | * retrieve the metainformation contained in link tags from the |
62 | * page pointed by url. the function may implement caching of the | 59 | * page pointed by url. the function may implement caching of the |
63 | * information. | 60 | * information. |
64 | * @param url url to harvest for link tags | 61 | * @param url url to harvest for link tags |
65 | * @param server reference to the string object where to put | 62 | * @param server reference to the string object where to put |
66 | * openid.server value | 63 | * openid.server value |
67 | * @param delegate reference to the string object where to put the | 64 | * @param delegate reference to the string object where to put the |
68 | * openid.delegate value (if any) | 65 | * openid.delegate value (if any) |
69 | */ | 66 | */ |
70 | virtual void retrieve_links(const string& url,string& server,string& delegate); | 67 | virtual void retrieve_links(const string& url,string& server,string& delegate); |
71 | 68 | ||
72 | /** | 69 | /** |
73 | * perform the associate request to OpenID server. | 70 | * perform the associate request to OpenID server. |
74 | * @param server the OpenID server | 71 | * @param server the OpenID server |
75 | * @return the auto_ptr<> for the newly allocated association_t | 72 | * @return the auto_ptr<> for the newly allocated association_t |
76 | * object, representing established association | 73 | * object, representing established association |
77 | * @throw exception in case of error | 74 | * @throw exception in case of error |
78 | */ | 75 | */ |
79 | assoc_t associate(const string& server); | 76 | assoc_t associate(const string& server); |
80 | /** | 77 | /** |
81 | * prepare the parameters for the checkid_immediate | 78 | * prepare the parameters for the checkid_immediate |
82 | * request. | 79 | * request. |
83 | * @param identity the identity to verify | 80 | * @param identity the identity to verify |
84 | * @param return_to the return_to url to pass with the request | 81 | * @param return_to the return_to url to pass with the request |
85 | * @param trust_root the trust root to advertise with the request | 82 | * @param trust_root the trust root to advertise with the request |
86 | * @param ext pointer to an extension(s) hooks object | 83 | * @param ext pointer to an extension(s) hooks object |
87 | * @return the location string | 84 | * @return the location string |
88 | * @throw exception in case of error | 85 | * @throw exception in case of error |
89 | */ | 86 | */ |
90 | virtual string checkid_immediate(const string& identity,const string& return_to,const string& trust_root="",extension_t *ext=0); | 87 | virtual string checkid_immediate(const string& identity,const string& return_to,const string& trust_root="",extension_t *ext=0); |
91 | /** | 88 | /** |
92 | * prepare the parameters for the checkid_setup | 89 | * prepare the parameters for the checkid_setup |
93 | * request. | 90 | * request. |
94 | * @param identity the identity to verify | 91 | * @param identity the identity to verify |
95 | * @param return_to the return_to url to pass with the request | 92 | * @param return_to the return_to url to pass with the request |
96 | * @param trust_root the trust root to advertise with the request | 93 | * @param trust_root the trust root to advertise with the request |
97 | * @param ext pointer to an extension(s) hooks object | 94 | * @param ext pointer to an extension(s) hooks object |
98 | * @return the location string | 95 | * @return the location string |
99 | * @throw exception in case of error | 96 | * @throw exception in case of error |
100 | */ | 97 | */ |
101 | virtual string checkid_setup(const string& identity,const string& return_to,const string& trust_root="",extension_t *ext=0); | 98 | virtual string checkid_setup(const string& identity,const string& return_to,const string& trust_root="",extension_t *ext=0); |
102 | /** | 99 | /** |
103 | * the actual implementation behind checkid_immediate() and | 100 | * the actual implementation behind checkid_immediate() and |
104 | * checkid_setup() functions. | 101 | * checkid_setup() functions. |
105 | * @param mode checkid_* mode - either mode_checkid_immediate or mode_checkid_setup | 102 | * @param mode checkid_* mode - either mode_checkid_immediate or mode_checkid_setup |
106 | * @param identity the identity to verify | 103 | * @param identity the identity to verify |
107 | * @param return_to the return_to url to pass with the request | 104 | * @param return_to the return_to url to pass with the request |
108 | * @param trust_root the trust root to advertise with the request | 105 | * @param trust_root the trust root to advertise with the request |
109 | * @param ext pointer to an extension(s) hooks object | 106 | * @param ext pointer to an extension(s) hooks object |
110 | * @return the location string | 107 | * @return the location string |
111 | * @throw exception in case of error | 108 | * @throw exception in case of error |
112 | */ | 109 | */ |
113 | virtual string checkid_(mode_t mode,const string& identity,const string& return_to,const string& trust_root="",extension_t *ext=0); | 110 | virtual string checkid_(mode_t mode,const string& identity,const string& return_to,const string& trust_root="",extension_t *ext=0); |
114 | /** | 111 | /** |
115 | * verify the id_res response | 112 | * verify the id_res response |
116 | * @param pin the response parameters | 113 | * @param pin the response parameters |
117 | * @param identity the identity being checked (if not specified, | 114 | * @param identity the identity being checked (if not specified, |
118 | * @param ext pointer to an extension(s) hooks object | 115 | * @param ext pointer to an extension(s) hooks object |
119 | * extracted from the openid.identity parameter | 116 | * extracted from the openid.identity parameter |
120 | * @throw id_res_mismatch in case of signature mismatch | 117 | * @throw id_res_mismatch in case of signature mismatch |
121 | * @throw id_res_setup in case of openid.user_setup_url failure | 118 | * @throw id_res_setup in case of openid.user_setup_url failure |
122 | * (supposedly checkid_immediate only) | 119 | * (supposedly checkid_immediate only) |
123 | * @throw id_res_failed in case of failure | 120 | * @throw id_res_failed in case of failure |
124 | * @throw exception in case of other failures | 121 | * @throw exception in case of other failures |
125 | */ | 122 | */ |
126 | virtual void id_res(const params_t& pin,const string& identity="",extension_t *ext=0); | 123 | virtual void id_res(const params_t& pin,const string& identity="",extension_t *ext=0); |
127 | /** | 124 | /** |
128 | * perform a check_authentication request. | 125 | * perform a check_authentication request. |
129 | * @param server the OpenID server | 126 | * @param server the OpenID server |
130 | * @param p request parameters | 127 | * @param p request parameters |
131 | */ | 128 | */ |
132 | void check_authentication(const string& server,const params_t& p); | 129 | void check_authentication(const string& server,const params_t& p); |
133 | 130 | ||
134 | /** | 131 | /** |
135 | * make URL canonical, by adding http:// and trailing slash, if needed. | 132 | * make URL canonical, by adding http:// and trailing slash, if needed. |
136 | * @param url | 133 | * @param url |
137 | * @return canonicalized url | 134 | * @return canonicalized url |
138 | */ | 135 | */ |
139 | static string canonicalize(const string& url); | 136 | static string canonicalize(const string& url); |
140 | 137 | ||
141 | }; | 138 | }; |
142 | 139 | ||
143 | } | 140 | } |
144 | 141 | ||
145 | #endif /* __OPKELE_CONSUMER_H */ | 142 | #endif /* __OPKELE_CONSUMER_H */ |