summaryrefslogtreecommitdiffabout
path: root/include/opkele/consumer.h
authorMichael Krelin <hacker@klever.net>2007-08-09 11:23:36 (UTC)
committer Michael Krelin <hacker@klever.net>2007-08-09 11:23:36 (UTC)
commit65bab7c9f984d6fe45ce72e7db014c40eba4d240 (patch) (unidiff)
tree28c4791aea6b7dc404ad0d27050c34f447a84314 /include/opkele/consumer.h
parent1f347795ef5eba50892fd777c173a2a6db1755f2 (diff)
downloadlibopkele-65bab7c9f984d6fe45ce72e7db014c40eba4d240.zip
libopkele-65bab7c9f984d6fe45ce72e7db014c40eba4d240.tar.gz
libopkele-65bab7c9f984d6fe45ce72e7db014c40eba4d240.tar.bz2
associations robustness improvements and documentation updates
Diffstat (limited to 'include/opkele/consumer.h') (more/less context) (ignore whitespace changes)
-rw-r--r--include/opkele/consumer.h19
1 files changed, 18 insertions, 1 deletions
diff --git a/include/opkele/consumer.h b/include/opkele/consumer.h
index 042e2d1..b9d1e54 100644
--- a/include/opkele/consumer.h
+++ b/include/opkele/consumer.h
@@ -1,149 +1,166 @@
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
12namespace opkele { 12namespace opkele {
13 13
14 /** 14 /**
15 * implementation of basic consumer functionality 15 * implementation of basic consumer functionality
16 *
17 * @note
18 * The consumer uses libcurl internally, which means that if you're using
19 * libopkele in multithreaded environment you should call curl_global_init
20 * yourself before spawning any threads.
16 */ 21 */
17 class consumer_t { 22 class consumer_t {
18 public: 23 public:
19 24
20 /** 25 /**
21 * store association. The function should be overridden in the real 26 * store association. The function should be overridden in the real
22 * implementation to provide persistent associations store. 27 * implementation to provide persistent associations store.
23 * @param server the OpenID server 28 * @param server the OpenID server
24 * @param handle association handle 29 * @param handle association handle
25 * @param secret the secret associated with the server and handle 30 * @param secret the secret associated with the server and handle
26 * @param expires_in the number of seconds until the handle is expired 31 * @param expires_in the number of seconds until the handle is expired
27 * @return the auto_ptr<> for the newly allocated association_t object 32 * @return the auto_ptr<> for the newly allocated association_t object
28 */ 33 */
29 virtual assoc_t store_assoc(const string& server,const string& handle,const secret_t& secret,int expires_in) = 0; 34 virtual assoc_t store_assoc(const string& server,const string& handle,const secret_t& secret,int expires_in) = 0;
30 /** 35 /**
31 * retrieve stored association. The function should be overridden 36 * retrieve stored association. The function should be overridden
32 * in the real implementation to provide persistent assocations 37 * in the real implementation to provide persistent assocations
33 * store. 38 * store.
39 *
40 * @note
41 * The user is responsible for handling associations expiry and
42 * this function should never return an expired or invalidated
43 * association.
44 *
34 * @param server the OpenID server 45 * @param server the OpenID server
35 * @param handle association handle 46 * @param handle association handle
36 * @return the autho_ptr<> for the newly allocated association_t object 47 * @return the autho_ptr<> for the newly allocated association_t object
37 * @throw failed_lookup in case of error 48 * @throw failed_lookup if no unexpired association found
38 */ 49 */
39 virtual assoc_t retrieve_assoc(const string& server,const string& handle) = 0; 50 virtual assoc_t retrieve_assoc(const string& server,const string& handle) = 0;
40 /** 51 /**
41 * invalidate stored association. The function should be overridden 52 * invalidate stored association. The function should be overridden
42 * in the real implementation of the consumer. 53 * in the real implementation of the consumer.
43 * @param server the OpenID server 54 * @param server the OpenID server
44 * @param handle association handle 55 * @param handle association handle
45 */ 56 */
46 virtual void invalidate_assoc(const string& server,const string& handle) = 0; 57 virtual void invalidate_assoc(const string& server,const string& handle) = 0;
47 /** 58 /**
48 * retrieve any unexpired association for the server. If the 59 * retrieve any unexpired association for the server. If the
49 * function is not overridden in the real implementation, the new 60 * function is not overridden in the real implementation, the new
50 * association will be established for each request. 61 * association will be established for each request.
62 *
63 * @note
64 * The user is responsible for handling associations and this
65 * function should never return an expired or invalidated
66 * association.
67 *
51 * @param server the OpenID server 68 * @param server the OpenID server
52 * @return the auto_ptr<> for the newly allocated association_t object 69 * @return the auto_ptr<> for the newly allocated association_t object
53 * @throw failed_lookup in case of absence of the handle 70 * @throw failed_lookup in case of absence of the handle
54 */ 71 */
55 virtual assoc_t find_assoc(const string& server); 72 virtual assoc_t find_assoc(const string& server);
56 73
57 /** 74 /**
58 * retrieve the metainformation contained in link tags from the 75 * retrieve the metainformation contained in link tags from the
59 * page pointed by url. the function may implement caching of the 76 * page pointed by url. the function may implement caching of the
60 * information. 77 * information.
61 * @param url url to harvest for link tags 78 * @param url url to harvest for link tags
62 * @param server reference to the string object where to put 79 * @param server reference to the string object where to put
63 * openid.server value 80 * openid.server value
64 * @param delegate reference to the string object where to put the 81 * @param delegate reference to the string object where to put the
65 * openid.delegate value (if any) 82 * openid.delegate value (if any)
66 */ 83 */
67 virtual void retrieve_links(const string& url,string& server,string& delegate); 84 virtual void retrieve_links(const string& url,string& server,string& delegate);
68 85
69 /** 86 /**
70 * perform the associate request to OpenID server. 87 * perform the associate request to OpenID server.
71 * @param server the OpenID server 88 * @param server the OpenID server
72 * @return the auto_ptr<> for the newly allocated association_t 89 * @return the auto_ptr<> for the newly allocated association_t
73 * object, representing established association 90 * object, representing established association
74 * @throw exception in case of error 91 * @throw exception in case of error
75 */ 92 */
76 assoc_t associate(const string& server); 93 assoc_t associate(const string& server);
77 /** 94 /**
78 * prepare the parameters for the checkid_immediate 95 * prepare the parameters for the checkid_immediate
79 * request. 96 * request.
80 * @param identity the identity to verify 97 * @param identity the identity to verify
81 * @param return_to the return_to url to pass with the request 98 * @param return_to the return_to url to pass with the request
82 * @param trust_root the trust root to advertise with the request 99 * @param trust_root the trust root to advertise with the request
83 * @param ext pointer to an extension(s) hooks object 100 * @param ext pointer to an extension(s) hooks object
84 * @return the location string 101 * @return the location string
85 * @throw exception in case of error 102 * @throw exception in case of error
86 */ 103 */
87 virtual string checkid_immediate(const string& identity,const string& return_to,const string& trust_root="",extension_t *ext=0); 104 virtual string checkid_immediate(const string& identity,const string& return_to,const string& trust_root="",extension_t *ext=0);
88 /** 105 /**
89 * prepare the parameters for the checkid_setup 106 * prepare the parameters for the checkid_setup
90 * request. 107 * request.
91 * @param identity the identity to verify 108 * @param identity the identity to verify
92 * @param return_to the return_to url to pass with the request 109 * @param return_to the return_to url to pass with the request
93 * @param trust_root the trust root to advertise with the request 110 * @param trust_root the trust root to advertise with the request
94 * @param ext pointer to an extension(s) hooks object 111 * @param ext pointer to an extension(s) hooks object
95 * @return the location string 112 * @return the location string
96 * @throw exception in case of error 113 * @throw exception in case of error
97 */ 114 */
98 virtual string checkid_setup(const string& identity,const string& return_to,const string& trust_root="",extension_t *ext=0); 115 virtual string checkid_setup(const string& identity,const string& return_to,const string& trust_root="",extension_t *ext=0);
99 /** 116 /**
100 * the actual implementation behind checkid_immediate() and 117 * the actual implementation behind checkid_immediate() and
101 * checkid_setup() functions. 118 * checkid_setup() functions.
102 * @param mode checkid_* mode - either mode_checkid_immediate or mode_checkid_setup 119 * @param mode checkid_* mode - either mode_checkid_immediate or mode_checkid_setup
103 * @param identity the identity to verify 120 * @param identity the identity to verify
104 * @param return_to the return_to url to pass with the request 121 * @param return_to the return_to url to pass with the request
105 * @param trust_root the trust root to advertise with the request 122 * @param trust_root the trust root to advertise with the request
106 * @param ext pointer to an extension(s) hooks object 123 * @param ext pointer to an extension(s) hooks object
107 * @return the location string 124 * @return the location string
108 * @throw exception in case of error 125 * @throw exception in case of error
109 */ 126 */
110 virtual string checkid_(mode_t mode,const string& identity,const string& return_to,const string& trust_root="",extension_t *ext=0); 127 virtual string checkid_(mode_t mode,const string& identity,const string& return_to,const string& trust_root="",extension_t *ext=0);
111 /** 128 /**
112 * verify the id_res response 129 * verify the id_res response
113 * @param pin the response parameters 130 * @param pin the response parameters
114 * @param identity the identity being checked (if not specified, 131 * @param identity the identity being checked (if not specified,
115 * @param ext pointer to an extension(s) hooks object 132 * @param ext pointer to an extension(s) hooks object
116 * extracted from the openid.identity parameter 133 * extracted from the openid.identity parameter
117 * @throw id_res_mismatch in case of signature mismatch 134 * @throw id_res_mismatch in case of signature mismatch
118 * @throw id_res_setup in case of openid.user_setup_url failure 135 * @throw id_res_setup in case of openid.user_setup_url failure
119 * (supposedly checkid_immediate only) 136 * (supposedly checkid_immediate only)
120 * @throw id_res_failed in case of failure 137 * @throw id_res_failed in case of failure
121 * @throw exception in case of other failures 138 * @throw exception in case of other failures
122 */ 139 */
123 virtual void id_res(const params_t& pin,const string& identity="",extension_t *ext=0); 140 virtual void id_res(const params_t& pin,const string& identity="",extension_t *ext=0);
124 /** 141 /**
125 * perform a check_authentication request. 142 * perform a check_authentication request.
126 * @param server the OpenID server 143 * @param server the OpenID server
127 * @param p request parameters 144 * @param p request parameters
128 */ 145 */
129 void check_authentication(const string& server,const params_t& p); 146 void check_authentication(const string& server,const params_t& p);
130 147
131 /** 148 /**
132 * normalize URL by adding http:// and trailing slash if needed. 149 * normalize URL by adding http:// and trailing slash if needed.
133 * @param url 150 * @param url
134 * @return normalized url 151 * @return normalized url
135 */ 152 */
136 static string normalize(const string& url); 153 static string normalize(const string& url);
137 154
138 /** 155 /**
139 * Canonicalize URL, by normalizing its appearance and following redirects. 156 * Canonicalize URL, by normalizing its appearance and following redirects.
140 * @param url 157 * @param url
141 * @return canonicalized url 158 * @return canonicalized url
142 */ 159 */
143 virtual string canonicalize(const string& url); 160 virtual string canonicalize(const string& url);
144 161
145 }; 162 };
146 163
147} 164}
148 165
149#endif /* __OPKELE_CONSUMER_H */ 166#endif /* __OPKELE_CONSUMER_H */