summaryrefslogtreecommitdiffabout
path: root/include/opkele/types.h
Unidiff
Diffstat (limited to 'include/opkele/types.h') (more/less context) (show whitespace changes)
-rw-r--r--include/opkele/types.h7
1 files changed, 3 insertions, 4 deletions
diff --git a/include/opkele/types.h b/include/opkele/types.h
index ca07df5..d959021 100644
--- a/include/opkele/types.h
+++ b/include/opkele/types.h
@@ -1,161 +1,160 @@
1#ifndef __OPKELE_TYPES_H 1#ifndef __OPKELE_TYPES_H
2#define __OPKELE_TYPES_H 2#define __OPKELE_TYPES_H
3 3
4/** 4/**
5 * @file 5 * @file
6 * @brief various types declarations 6 * @brief various types declarations
7 */ 7 */
8 8
9#include <ostream> 9#include <ostream>
10#include <vector> 10#include <vector>
11#include <string> 11#include <string>
12#include <map> 12#include <map>
13#include <memory>
14#include <set> 13#include <set>
14#include <opkele/tr1-mem.h>
15 15
16namespace opkele { 16namespace opkele {
17 using std::vector; 17 using std::vector;
18 using std::string; 18 using std::string;
19 using std::map; 19 using std::map;
20 using std::ostream; 20 using std::ostream;
21 using std::auto_ptr;
22 using std::multimap; 21 using std::multimap;
23 using std::set; 22 using std::set;
24 23
25 /** 24 /**
26 * the OpenID operation mode 25 * the OpenID operation mode
27 */ 26 */
28 typedef enum _mode_t { 27 typedef enum _mode_t {
29 mode_associate, 28 mode_associate,
30 mode_checkid_immediate, 29 mode_checkid_immediate,
31 mode_checkid_setup, 30 mode_checkid_setup,
32 mode_check_association 31 mode_check_association
33 } mode_t; 32 } mode_t;
34 33
35 /** 34 /**
36 * the association secret container 35 * the association secret container
37 */ 36 */
38 class secret_t : public vector<unsigned char> { 37 class secret_t : public vector<unsigned char> {
39 public: 38 public:
40 39
41 /** 40 /**
42 * xor the secret and hmac together and encode, using base64 41 * xor the secret and hmac together and encode, using base64
43 * @param key_d pointer to the message digest 42 * @param key_d pointer to the message digest
44 * @param rv reference to the return value 43 * @param rv reference to the return value
45 */ 44 */
46 void enxor_to_base64(const unsigned char *key_d,string& rv) const; 45 void enxor_to_base64(const unsigned char *key_d,string& rv) const;
47 /** 46 /**
48 * decode base64-encoded secret and xor it with the message digest 47 * decode base64-encoded secret and xor it with the message digest
49 * @param key_d pointer to the message digest 48 * @param key_d pointer to the message digest
50 * @param b64 base64-encoded secret value 49 * @param b64 base64-encoded secret value
51 */ 50 */
52 void enxor_from_base64(const unsigned char *key_d,const string& b64); 51 void enxor_from_base64(const unsigned char *key_d,const string& b64);
53 /** 52 /**
54 * plainly encode to base64 representation 53 * plainly encode to base64 representation
55 * @param rv reference to the return value 54 * @param rv reference to the return value
56 */ 55 */
57 void to_base64(string& rv) const; 56 void to_base64(string& rv) const;
58 /** 57 /**
59 * decode cleartext secret from base64 58 * decode cleartext secret from base64
60 * @param b64 base64-encoded representation of the secret value 59 * @param b64 base64-encoded representation of the secret value
61 */ 60 */
62 void from_base64(const string& b64); 61 void from_base64(const string& b64);
63 }; 62 };
64 63
65 /** 64 /**
66 * Interface to the association. 65 * Interface to the association.
67 */ 66 */
68 class association_t { 67 class association_t {
69 public: 68 public:
70 69
71 virtual ~association_t() { } 70 virtual ~association_t() { }
72 71
73 /** 72 /**
74 * retrieve the server with which association was established. 73 * retrieve the server with which association was established.
75 * @return server name 74 * @return server name
76 */ 75 */
77 virtual string server() const = 0; 76 virtual string server() const = 0;
78 /** 77 /**
79 * retrieve the association handle. 78 * retrieve the association handle.
80 * @return handle 79 * @return handle
81 */ 80 */
82 virtual string handle() const = 0; 81 virtual string handle() const = 0;
83 /** 82 /**
84 * retrieve the association type. 83 * retrieve the association type.
85 * @return association type 84 * @return association type
86 */ 85 */
87 virtual string assoc_type() const = 0; 86 virtual string assoc_type() const = 0;
88 /** 87 /**
89 * retrieve the association secret. 88 * retrieve the association secret.
90 * @return association secret 89 * @return association secret
91 */ 90 */
92 virtual secret_t secret() const = 0; 91 virtual secret_t secret() const = 0;
93 /** 92 /**
94 * retrieve the number of seconds the association expires in. 93 * retrieve the number of seconds the association expires in.
95 * @return seconds till expiration 94 * @return seconds till expiration
96 */ 95 */
97 virtual int expires_in() const = 0; 96 virtual int expires_in() const = 0;
98 /** 97 /**
99 * check whether the association is stateless. 98 * check whether the association is stateless.
100 * @return true if stateless 99 * @return true if stateless
101 */ 100 */
102 virtual bool stateless() const = 0; 101 virtual bool stateless() const = 0;
103 /** 102 /**
104 * check whether the association is expired. 103 * check whether the association is expired.
105 * @return true if expired 104 * @return true if expired
106 */ 105 */
107 virtual bool is_expired() const = 0; 106 virtual bool is_expired() const = 0;
108 }; 107 };
109 108
110 /** 109 /**
111 * the auto_ptr<> for association_t object type 110 * the shared_ptr<> for association_t object type
112 */ 111 */
113 typedef auto_ptr<association_t> assoc_t; 112 typedef tr1mem::shared_ptr<association_t> assoc_t;
114 113
115 /** 114 /**
116 * request/response parameters map 115 * request/response parameters map
117 */ 116 */
118 class params_t : public map<string,string> { 117 class params_t : public map<string,string> {
119 public: 118 public:
120 119
121 /** 120 /**
122 * check whether the parameter is present. 121 * check whether the parameter is present.
123 * @param n the parameter name 122 * @param n the parameter name
124 * @return true if yes 123 * @return true if yes
125 */ 124 */
126 bool has_param(const string& n) const; 125 bool has_param(const string& n) const;
127 /** 126 /**
128 * retrieve the parameter (const version) 127 * retrieve the parameter (const version)
129 * @param n the parameter name 128 * @param n the parameter name
130 * @return the parameter value 129 * @return the parameter value
131 * @throw failed_lookup if there is no such parameter 130 * @throw failed_lookup if there is no such parameter
132 */ 131 */
133 const string& get_param(const string& n) const; 132 const string& get_param(const string& n) const;
134 /** 133 /**
135 * retrieve the parameter. 134 * retrieve the parameter.
136 * @param n the parameter name 135 * @param n the parameter name
137 * @return the parameter value 136 * @return the parameter value
138 * @throw failed_lookup if there is no such parameter 137 * @throw failed_lookup if there is no such parameter
139 */ 138 */
140 string& get_param(const string& n); 139 string& get_param(const string& n);
141 140
142 /** 141 /**
143 * parse the OpenID key/value data. 142 * parse the OpenID key/value data.
144 * @param kv the OpenID key/value data 143 * @param kv the OpenID key/value data
145 */ 144 */
146 void parse_keyvalues(const string& kv); 145 void parse_keyvalues(const string& kv);
147 /** 146 /**
148 * sign the fields. 147 * sign the fields.
149 * @param secret the secret used for signing 148 * @param secret the secret used for signing
150 * @param sig reference to the string, containing base64-encoded 149 * @param sig reference to the string, containing base64-encoded
151 * result 150 * result
152 * @param slist the comma-separated list of fields to sign 151 * @param slist the comma-separated list of fields to sign
153 * @param prefix the string to prepend to parameter names 152 * @param prefix the string to prepend to parameter names
154 */ 153 */
155 void sign(secret_t secret,string& sig,const string& slist,const char *prefix=0) const; 154 void sign(secret_t secret,string& sig,const string& slist,const char *prefix=0) const;
156 155
157 /** 156 /**
158 * append parameters to the URL as a GET-request parameters. 157 * append parameters to the URL as a GET-request parameters.
159 * @param url the base URL 158 * @param url the base URL
160 * @param prefix the string to prepend to parameter names 159 * @param prefix the string to prepend to parameter names
161 * @return the ready-to-use location 160 * @return the ready-to-use location