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