1 /*
2 Copyright (C) 2007-2010 Butterfat, LLC (http://butterfat.net)
3 
4 Permission is hereby granted, free of charge, to any person
5 obtaining a copy of this software and associated documentation
6 files (the "Software"), to deal in the Software without
7 restriction, including without limitation the rights to use,
8 copy, modify, merge, publish, distribute, sublicense, and/or sell
9 copies of the Software, and to permit persons to whom the
10 Software is furnished to do so, subject to the following
11 conditions:
12 
13 The above copyright notice and this permission notice shall be
14 included in all copies or substantial portions of the Software.
15 
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
18 OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 OTHER DEALINGS IN THE SOFTWARE.
24 
25 Created by bmuller <bmuller@butterfat.net>
26 */
27 
28 
29 namespace modauthopenid {
30   using namespace opkele;
31   using namespace std;
32 
33   enum error_result_t { no_idp_found, invalid_id, idp_not_trusted, invalid_nonce, canceled, unspecified, unauthorized, ax_bad_response };
34   enum exec_result_t { id_accepted, fork_failed, child_no_return, id_refused };
35 
36   typedef struct session {
37     string session_id;
38     string hostname; // name of server (this is in case there are virtual hosts on this server)
39     string path;
40     string identity;
41     string username; // optional - set by AuthOpenIDAXUsername
42     int expires_on; // exact moment it expires
43   } session_t;
44 
45   // Wrapper for basic_openid_message - just so it works with openid namespace
46   class modauthopenid_message_t : public params_t {
47   public:
modauthopenid_message_t(params_t & _bom)48     modauthopenid_message_t(params_t& _bom) { bom = _bom; };
has_field(const string & n)49     bool has_field(const string& n) const { return bom.has_param("openid."+n); };
get_field(const string & n)50     const string& get_field(const string& n) const { return bom.get_param("openid."+n); };
has_ns(const string & uri)51     bool has_ns(const string& uri) const { return bom.has_ns(uri); };
get_ns(const string & uri)52     string get_ns(const string& uri) const { return bom.get_ns(uri); };
fields_begin()53     fields_iterator fields_begin() const { return bom.fields_begin(); };
fields_end()54     fields_iterator fields_end() const { return bom.fields_end(); };
reset_fields()55     void reset_fields() { bom.reset_fields(); };
set_field(const string & n,const string & v)56     void set_field(const string& n,const string& v) { bom.set_field(n, v); };
reset_field(const string & n)57     void reset_field(const string& n) { bom.reset_field(n); };
58 
59   private:
60     params_t bom;
61   };
62 
63 }
64 
65 
66