-rw-r--r-- | include/opkele/types.h | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/include/opkele/types.h b/include/opkele/types.h index 520618d..ca07df5 100644 --- a/include/opkele/types.h +++ b/include/opkele/types.h | |||
@@ -19,58 +19,58 @@ namespace opkele { | |||
19 | using std::map; | 19 | using std::map; |
20 | using std::ostream; | 20 | using std::ostream; |
21 | using std::auto_ptr; | 21 | using std::auto_ptr; |
22 | using std::multimap; | 22 | using std::multimap; |
23 | using std::set; | 23 | using std::set; |
24 | 24 | ||
25 | /** | 25 | /** |
26 | * the OpenID operation mode | 26 | * the OpenID operation mode |
27 | */ | 27 | */ |
28 | typedef enum _mode_t { | 28 | typedef enum _mode_t { |
29 | mode_associate, | 29 | mode_associate, |
30 | mode_checkid_immediate, | 30 | mode_checkid_immediate, |
31 | mode_checkid_setup, | 31 | mode_checkid_setup, |
32 | mode_check_association | 32 | mode_check_association |
33 | } mode_t; | 33 | } mode_t; |
34 | 34 | ||
35 | /** | 35 | /** |
36 | * the association secret container | 36 | * the association secret container |
37 | */ | 37 | */ |
38 | class secret_t : public vector<unsigned char> { | 38 | class secret_t : public vector<unsigned char> { |
39 | public: | 39 | public: |
40 | 40 | ||
41 | /** | 41 | /** |
42 | * xor the secret and hmac together and encode, using base64 | 42 | * xor the secret and hmac together and encode, using base64 |
43 | * @param key_sha1 pointer to the sha1 digest | 43 | * @param key_d pointer to the message digest |
44 | * @param rv reference to the return value | 44 | * @param rv reference to the return value |
45 | */ | 45 | */ |
46 | void enxor_to_base64(const unsigned char *key_sha1,string& rv) const; | 46 | void enxor_to_base64(const unsigned char *key_d,string& rv) const; |
47 | /** | 47 | /** |
48 | * decode base64-encoded secret and xor it with the sha1 digest | 48 | * decode base64-encoded secret and xor it with the message digest |
49 | * @param key_sha1 pointer to the message digest | 49 | * @param key_d pointer to the message digest |
50 | * @param b64 base64-encoded secret value | 50 | * @param b64 base64-encoded secret value |
51 | */ | 51 | */ |
52 | void enxor_from_base64(const unsigned char *key_sha1,const string& b64); | 52 | void enxor_from_base64(const unsigned char *key_d,const string& b64); |
53 | /** | 53 | /** |
54 | * plainly encode to base64 representation | 54 | * plainly encode to base64 representation |
55 | * @param rv reference to the return value | 55 | * @param rv reference to the return value |
56 | */ | 56 | */ |
57 | void to_base64(string& rv) const; | 57 | void to_base64(string& rv) const; |
58 | /** | 58 | /** |
59 | * decode cleartext secret from base64 | 59 | * decode cleartext secret from base64 |
60 | * @param b64 base64-encoded representation of the secret value | 60 | * @param b64 base64-encoded representation of the secret value |
61 | */ | 61 | */ |
62 | void from_base64(const string& b64); | 62 | void from_base64(const string& b64); |
63 | }; | 63 | }; |
64 | 64 | ||
65 | /** | 65 | /** |
66 | * Interface to the association. | 66 | * Interface to the association. |
67 | */ | 67 | */ |
68 | class association_t { | 68 | class association_t { |
69 | public: | 69 | public: |
70 | 70 | ||
71 | virtual ~association_t() { } | 71 | virtual ~association_t() { } |
72 | 72 | ||
73 | /** | 73 | /** |
74 | * retrieve the server with which association was established. | 74 | * retrieve the server with which association was established. |
75 | * @return server name | 75 | * @return server name |
76 | */ | 76 | */ |
@@ -140,48 +140,56 @@ namespace opkele { | |||
140 | string& get_param(const string& n); | 140 | string& get_param(const string& n); |
141 | 141 | ||
142 | /** | 142 | /** |
143 | * parse the OpenID key/value data. | 143 | * parse the OpenID key/value data. |
144 | * @param kv the OpenID key/value data | 144 | * @param kv the OpenID key/value data |
145 | */ | 145 | */ |
146 | void parse_keyvalues(const string& kv); | 146 | void parse_keyvalues(const string& kv); |
147 | /** | 147 | /** |
148 | * sign the fields. | 148 | * sign the fields. |
149 | * @param secret the secret used for signing | 149 | * @param secret the secret used for signing |
150 | * @param sig reference to the string, containing base64-encoded | 150 | * @param sig reference to the string, containing base64-encoded |
151 | * result | 151 | * result |
152 | * @param slist the comma-separated list of fields to sign | 152 | * @param slist the comma-separated list of fields to sign |
153 | * @param prefix the string to prepend to parameter names | 153 | * @param prefix the string to prepend to parameter names |
154 | */ | 154 | */ |
155 | void sign(secret_t secret,string& sig,const string& slist,const char *prefix=0) const; | 155 | void sign(secret_t secret,string& sig,const string& slist,const char *prefix=0) const; |
156 | 156 | ||
157 | /** | 157 | /** |
158 | * append parameters to the URL as a GET-request parameters. | 158 | * append parameters to the URL as a GET-request parameters. |
159 | * @param url the base URL | 159 | * @param url the base URL |
160 | * @param prefix the string to prepend to parameter names | 160 | * @param prefix the string to prepend to parameter names |
161 | * @return the ready-to-use location | 161 | * @return the ready-to-use location |
162 | */ | 162 | */ |
163 | string append_query(const string& url,const char *prefix = "openid.") const; | 163 | string append_query(const string& url,const char *prefix = "openid.") const; |
164 | |||
165 | /** | ||
166 | * make up a query string suitable for use in GET and POST | ||
167 | * requests. | ||
168 | * @param prefix string to prened to parameter names | ||
169 | * @return query string | ||
170 | */ | ||
171 | string query_string(const char *prefix = "openid.") const; | ||
164 | }; | 172 | }; |
165 | 173 | ||
166 | /** | 174 | /** |
167 | * dump the key/value pairs for the parameters to the stream. | 175 | * dump the key/value pairs for the parameters to the stream. |
168 | * @param o output stream | 176 | * @param o output stream |
169 | * @param p the parameters | 177 | * @param p the parameters |
170 | */ | 178 | */ |
171 | ostream& operator << (ostream& o,const params_t& p); | 179 | ostream& operator << (ostream& o,const params_t& p); |
172 | 180 | ||
173 | namespace xrd { | 181 | namespace xrd { |
174 | 182 | ||
175 | struct priority_compare { | 183 | struct priority_compare { |
176 | inline bool operator()(long a,long b) const { | 184 | inline bool operator()(long a,long b) const { |
177 | return (a<0) ? false : (b<0) ? false : (a<b); | 185 | return (a<0) ? false : (b<0) ? false : (a<b); |
178 | } | 186 | } |
179 | }; | 187 | }; |
180 | 188 | ||
181 | template <typename _DT> | 189 | template <typename _DT> |
182 | class priority_map : public multimap<long,_DT,priority_compare> { | 190 | class priority_map : public multimap<long,_DT,priority_compare> { |
183 | typedef multimap<long,_DT,priority_compare> map_type; | 191 | typedef multimap<long,_DT,priority_compare> map_type; |
184 | public: | 192 | public: |
185 | 193 | ||
186 | inline _DT& add(long priority,const _DT& d) { | 194 | inline _DT& add(long priority,const _DT& d) { |
187 | return insert(typename map_type::value_type(priority,d))->second; | 195 | return insert(typename map_type::value_type(priority,d))->second; |