summaryrefslogtreecommitdiffabout
path: root/include
authorMichael Krelin <hacker@klever.net>2009-12-22 21:40:18 (UTC)
committer Michael Krelin <hacker@klever.net>2009-12-22 21:40:18 (UTC)
commit282e937cefbca9ebb564e83e79f5e5b136ec960d (patch) (unidiff)
tree31c2ae20899825157b90216f1e1c71ee1c7e1122 /include
parent142ca30cad85769067419a9ed5b60501af67e17c (diff)
downloadlibopkele-282e937cefbca9ebb564e83e79f5e5b136ec960d.zip
libopkele-282e937cefbca9ebb564e83e79f5e5b136ec960d.tar.gz
libopkele-282e937cefbca9ebb564e83e79f5e5b136ec960d.tar.bz2
minor cleanup of ax/oauth code
Signed-off-by: Michael Krelin <hacker@klever.net>
Diffstat (limited to 'include') (more/less context) (show whitespace changes)
-rw-r--r--include/opkele/ax.h6
-rw-r--r--include/opkele/oauth_ext.h9
2 files changed, 3 insertions, 12 deletions
diff --git a/include/opkele/ax.h b/include/opkele/ax.h
index 996d756..ba629c1 100644
--- a/include/opkele/ax.h
+++ b/include/opkele/ax.h
@@ -1,84 +1,84 @@
1#ifndef __OPKELE_AX_H 1#ifndef __OPKELE_AX_H
2#define __OPKELE_AX_H 2#define __OPKELE_AX_H
3 3
4/** 4/**
5 * @file 5 * @file
6 * @brief Attribute Exchange extension 6 * @brief Attribute Exchange extension
7 */ 7 */
8 8
9#include <opkele/extension.h> 9#include <opkele/extension.h>
10 10
11namespace opkele { 11namespace opkele {
12 12
13 /** 13 /**
14 * OpenID simple registration extension implementation 14 * OpenID attribute exchange extension implementation
15 * http://openid.net/specs/openid-simple-registration-extension-1_0.html 15 * http://openid.net/specs/openid-attribute-exchange-1_0.html
16 */ 16 */
17 class ax_t : public extension_t { 17 class ax_t : public extension_t {
18 public: 18 public:
19 /** special "count" value for add_attribute to request fetching "as many values as possible". */ 19 /** special "count" value for add_attribute to request fetching "as many values as possible". */
20 static const int UNLIMITED_COUNT = -1; 20 static const int UNLIMITED_COUNT = -1;
21 21
22 /** 22 /**
23 * Optional URL for receiving future attribute updates. 23 * Optional URL for receiving future attribute updates.
24 * Set it before checkid_setup to send up the URL; read it after id_res to get it back. 24 * Set it before checkid_setup to send up the URL; read it after id_res to get it back.
25 */ 25 */
26 std::string update_url; 26 std::string update_url;
27 27
28 /** 28 /**
29 * Consumer constructor. 29 * Consumer constructor.
30 */ 30 */
31 ax_t() : alias_count(0) { } 31 ax_t() : alias_count(0) { }
32 32
33 /** Adds an attribute to request during checkid_setup. */ 33 /** Adds an attribute to request during checkid_setup. */
34 void add_attribute(const char *uri, bool required, const char *alias = NULL, int count = 1); 34 void add_attribute(const char *uri, bool required, const char *alias = NULL, int count = 1);
35 35
36 /** Returns an attribute fetched for the given type-uri during id_res. */ 36 /** Returns an attribute fetched for the given type-uri during id_res. */
37 std::string get_attribute(const char *uri, int index = 0); 37 std::string get_attribute(const char *uri, int index = 0);
38 /** Returns the number of values fetched for the given type-uri during id_res. */ 38 /** Returns the number of values fetched for the given type-uri during id_res. */
39 size_t get_attribute_count(const char *uri); 39 size_t get_attribute_count(const char *uri);
40 40
41 virtual void rp_checkid_hook(basic_openid_message& om); 41 virtual void rp_checkid_hook(basic_openid_message& om);
42 virtual void rp_id_res_hook(const basic_openid_message& om, 42 virtual void rp_id_res_hook(const basic_openid_message& om,
43 const basic_openid_message& sp); 43 const basic_openid_message& sp);
44 virtual void op_checkid_hook(const basic_openid_message& inm); 44 virtual void op_checkid_hook(const basic_openid_message& inm);
45 virtual void op_id_res_hook(basic_openid_message& oum); 45 virtual void op_id_res_hook(basic_openid_message& oum);
46 46
47 virtual void checkid_hook(basic_openid_message& om); 47 virtual void checkid_hook(basic_openid_message& om);
48 virtual void id_res_hook(const basic_openid_message& om, 48 virtual void id_res_hook(const basic_openid_message& om,
49 const basic_openid_message& sp); 49 const basic_openid_message& sp);
50 virtual void checkid_hook(const basic_openid_message& inm, 50 virtual void checkid_hook(const basic_openid_message& inm,
51 basic_openid_message& oum); 51 basic_openid_message& oum);
52 52
53 /** 53 /**
54 * Function called after parsing sreg request to set up response 54 * Function called after parsing sreg request to set up response
55 * fields. The default implementation tries to send as much fields 55 * fields. The default implementation tries to send as much fields
56 * as we have. The function is supposed to set the data and 56 * as we have. The function is supposed to set the data and
57 * fields_response. 57 * fields_response.
58 * @see fields_response 58 * @see fields_response
59 * @param inm incoming openid message 59 * @param inm incoming openid message
60 * @param oum outgoing openid message 60 * @param oum outgoing openid message
61 */ 61 */
62 virtual void setup_response(const basic_openid_message& inm, 62 virtual void setup_response(const basic_openid_message& inm,
63 basic_openid_message& oum); 63 basic_openid_message& oum);
64 64
65 virtual void setup_response(); 65 virtual void setup_response();
66 66
67 protected: 67 protected:
68 /** Stores attributes to request fetching during checkid_setup. */ 68 /** Stores attributes to request fetching during checkid_setup. */
69 struct ax_attr_t { 69 struct ax_attr_t {
70 std::string uri; 70 std::string uri;
71 std::string alias; 71 std::string alias;
72 bool required; 72 bool required;
73 int count; 73 int count;
74 }; 74 };
75 std::vector<ax_attr_t> attrs; 75 std::vector<ax_attr_t> attrs;
76 unsigned int alias_count; // auto-incr counter for auto-named aliases 76 unsigned int alias_count; // auto-incr counter for auto-named aliases
77 77
78 /** Stores results from fetch response during id_res. */ 78 /** Stores results from fetch response during id_res. */
79 std::map<std::string, std::vector<std::string> > response_attrs; 79 std::map<std::string, std::vector<std::string> > response_attrs;
80 }; 80 };
81} 81}
82 82
83#endif /* __OPKELE_SREG_H */ 83#endif /* __OPKELE_AX_H */
84 84
diff --git a/include/opkele/oauth_ext.h b/include/opkele/oauth_ext.h
index 37a826b..657defa 100644
--- a/include/opkele/oauth_ext.h
+++ b/include/opkele/oauth_ext.h
@@ -1,62 +1,53 @@
1#ifndef __OPKELE_OAUTH_EXT_H 1#ifndef __OPKELE_OAUTH_EXT_H
2#define __OPKELE_OAUTH_EXT_H 2#define __OPKELE_OAUTH_EXT_H
3 3
4/** 4/**
5 * @file 5 * @file
6 * @brief OAuth extension 6 * @brief OAuth extension
7 */ 7 */
8 8
9#include <opkele/extension.h> 9#include <opkele/extension.h>
10 10
11namespace opkele { 11namespace opkele {
12 12
13 /** 13 /**
14 * OpenID OAuth extension 14 * OpenID OAuth extension
15 * http://step2.googlecode.com/svn/spec/openid_oauth_extension/latest/openid_oauth_extension.html 15 * http://step2.googlecode.com/svn/spec/openid_oauth_extension/latest/openid_oauth_extension.html
16 */ 16 */
17 class oauth_ext_t : public extension_t { 17 class oauth_ext_t : public extension_t {
18 public: 18 public:
19 std::string m_consumer, m_scope, m_request_token; 19 std::string m_consumer, m_scope, m_request_token;
20 20
21 /**
22 * Consumer constructor.
23 * @param fr required fields
24 * @see fields_required
25 * @param fo optional fields
26 * @see fields_optional
27 * @param pu policy url
28 * @see policy_url
29 */
30 oauth_ext_t(const char *consumer = "", const char *scope = "") : m_consumer(consumer), m_scope(scope) { } 21 oauth_ext_t(const char *consumer = "", const char *scope = "") : m_consumer(consumer), m_scope(scope) { }
31 22
32 virtual void rp_checkid_hook(basic_openid_message& om); 23 virtual void rp_checkid_hook(basic_openid_message& om);
33 virtual void rp_id_res_hook(const basic_openid_message& om, 24 virtual void rp_id_res_hook(const basic_openid_message& om,
34 const basic_openid_message& sp); 25 const basic_openid_message& sp);
35 virtual void op_checkid_hook(const basic_openid_message& inm); 26 virtual void op_checkid_hook(const basic_openid_message& inm);
36 virtual void op_id_res_hook(basic_openid_message& oum); 27 virtual void op_id_res_hook(basic_openid_message& oum);
37 28
38 virtual void checkid_hook(basic_openid_message& om); 29 virtual void checkid_hook(basic_openid_message& om);
39 virtual void id_res_hook(const basic_openid_message& om, 30 virtual void id_res_hook(const basic_openid_message& om,
40 const basic_openid_message& sp); 31 const basic_openid_message& sp);
41 virtual void checkid_hook(const basic_openid_message& inm, 32 virtual void checkid_hook(const basic_openid_message& inm,
42 basic_openid_message& oum); 33 basic_openid_message& oum);
43 34
44 /** 35 /**
45 * Function called after parsing sreg request to set up response 36 * Function called after parsing sreg request to set up response
46 * fields. The default implementation tries to send as much fields 37 * fields. The default implementation tries to send as much fields
47 * as we have. The function is supposed to set the data and 38 * as we have. The function is supposed to set the data and
48 * fields_response. 39 * fields_response.
49 * @see fields_response 40 * @see fields_response
50 * @param inm incoming openid message 41 * @param inm incoming openid message
51 * @param oum outgoing openid message 42 * @param oum outgoing openid message
52 */ 43 */
53 virtual void setup_response(const basic_openid_message& inm, 44 virtual void setup_response(const basic_openid_message& inm,
54 basic_openid_message& oum); 45 basic_openid_message& oum);
55 46
56 virtual void setup_response(); 47 virtual void setup_response();
57 48
58 }; 49 };
59} 50}
60 51
61#endif /* __OPKELE_OAUTH_EXT_H */ 52#endif /* __OPKELE_OAUTH_EXT_H */
62 53