summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--include/opkele/basic_rp.h18
-rw-r--r--include/opkele/types.h18
2 files changed, 18 insertions, 18 deletions
diff --git a/include/opkele/basic_rp.h b/include/opkele/basic_rp.h
index 3f17fd9..d5356aa 100644
--- a/include/opkele/basic_rp.h
+++ b/include/opkele/basic_rp.h
@@ -1,76 +1,58 @@
#ifndef __OPKELE_BASIC_RP_H
#define __OPKELE_BASIC_RP_H
-#include <cstring>
#include <string>
#include <opkele/types.h>
#include <opkele/extension.h>
namespace opkele {
using std::string;
- struct openid_endpoint_t {
- string uri;
- string claimed_id;
- string local_id;
-
- openid_endpoint_t() { }
- openid_endpoint_t(const string& u,const string& cid,const string& lid)
- : uri(u), claimed_id(cid), local_id(lid) { }
-
- bool operator==(const openid_endpoint_t& x) const {
- return uri==x.uri && local_id==x.local_id; }
- bool operator<(const openid_endpoint_t& x) const {
- int c;
- return (c=strcmp(uri.c_str(),x.uri.c_str()))
- ? (c<0) : (strcmp(local_id.c_str(),x.local_id.c_str())<0); }
- };
-
class basic_RP {
public:
virtual ~basic_RP() { }
/**
* @name Global persistent store API
* These are functions related to the associations with OP storage
* and retrieval and nonce records. They provide an interface to
* the persistent storage which is shared by all sessions. If the
* implementor prefers the dumb mode instead, the function should
* throw dumb_RP exception instead.
* @see opkele::dumb_RP
* @{
*/
/**
* Store association and return allocated association object.
* @param OP OP endpoint
* @param handle association handle
* @param type association type
* @param secret association secret
* @params expires_in the number of seconds association expires in
* @return the association object
* @throw dumb_RP for dumb RP
*/
virtual assoc_t store_assoc(
const string& OP,const string& handle,
const string& type,const secret_t& secret,
int expires_in) = 0;
/**
* Find valid unexpired association with an OP.
* @param OP OP endpoint URL
* @return association found
* @throw failed_lookup if no association found
* @throw dumb_RP for dumb RP
*/
virtual assoc_t find_assoc(
const string& OP) = 0;
/**
* Retrieve valid association handle for an OP by handle.
* @param OP OP endpoint URL
* @param handle association handle
* @return association found
* @throw failed_lookup if no association found
* @throw dumb_RP for dumb RP
*/
virtual assoc_t retrieve_assoc(
const string& OP,const string& handle) = 0;
diff --git a/include/opkele/types.h b/include/opkele/types.h
index 5d39a5c..6ab51ef 100644
--- a/include/opkele/types.h
+++ b/include/opkele/types.h
@@ -1,56 +1,57 @@
#ifndef __OPKELE_TYPES_H
#define __OPKELE_TYPES_H
/**
* @file
* @brief various types declarations
*/
+#include <cstring>
#include <ostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <list>
#include <opkele/iterator.h>
#include <opkele/tr1-mem.h>
namespace opkele {
using std::vector;
using std::string;
using std::map;
using std::ostream;
using std::multimap;
using std::set;
using std::list;
using std::iterator;
using std::forward_iterator_tag;
/**
* the OpenID operation mode
*/
typedef enum _mode_t {
mode_unknown = 0,
mode_associate,
mode_checkid_immediate,
mode_checkid_setup,
mode_check_association
} mode_t;
/**
* the association secret container
*/
class secret_t : public vector<unsigned char> {
public:
/**
* xor the secret and hmac together and encode, using base64
* @param key_d pointer to the message digest
* @param rv reference to the return value
*/
void enxor_to_base64(const unsigned char *key_d,string& rv) const;
/**
* decode base64-encoded secret and xor it with the message digest
* @param key_d pointer to the message digest
* @param b64 base64-encoded secret value
*/
@@ -161,51 +162,68 @@ namespace opkele {
openid_message_t(const basic_openid_message& x)
: basic_openid_message(x) { }
void copy_to(basic_openid_message& x) const;
bool has_field(const string& n) const;
const string& get_field(const string& n) const;
virtual fields_iterator fields_begin() const;
virtual fields_iterator fields_end() const;
void reset_fields();
void set_field(const string& n,const string& v);
void reset_field(const string& n);
};
/**
* request/response parameters map
*/
class params_t : public openid_message_t {
public:
/**
* check whether the parameter is present.
* @param n the parameter name
* @return true if yes
*/
bool has_param(const string& n) const {
return has_field(n); }
/**
* retrieve the parameter (const version)
* @param n the parameter name
* @return the parameter value
* @throw failed_lookup if there is no such parameter
*/
const string& get_param(const string& n) const {
return get_field(n); }
/**
* parse the OpenID key/value data.
* @param kv the OpenID key/value data
*/
void parse_keyvalues(const string& kv) {
from_keyvalues(kv); }
string append_query(const string& url,const char *prefix="openid.") const;
};
+ struct openid_endpoint_t {
+ string uri;
+ string claimed_id;
+ string local_id;
+
+ openid_endpoint_t() { }
+ openid_endpoint_t(const string& u,const string& cid,const string& lid)
+ : uri(u), claimed_id(cid), local_id(lid) { }
+
+ bool operator==(const openid_endpoint_t& x) const {
+ return uri==x.uri && local_id==x.local_id; }
+ bool operator<(const openid_endpoint_t& x) const {
+ int c;
+ return (c=strcmp(uri.c_str(),x.uri.c_str()))
+ ? (c<0) : (strcmp(local_id.c_str(),x.local_id.c_str())<0); }
+ };
+
}
#endif /* __OPKELE_TYPES_H */