author | Michael Krelin <hacker@klever.net> | 2007-12-27 20:58:28 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2008-01-04 18:18:34 (UTC) |
commit | 2ddc48944c5238fa1b99e50fc194d220d9e92f43 (patch) (unidiff) | |
tree | 55d654042e3e52c30468d4cdf8b493e1b0cd59f9 | |
parent | 2e8d7f2a65518ec6cb50166771dac8ca41c7304e (diff) | |
download | libopkele-2ddc48944c5238fa1b99e50fc194d220d9e92f43.zip libopkele-2ddc48944c5238fa1b99e50fc194d220d9e92f43.tar.gz libopkele-2ddc48944c5238fa1b99e50fc194d220d9e92f43.tar.bz2 |
added openid.sreg.ns parameter to sreg extension
Signed-off-by: Michael Krelin <hacker@klever.net>
-rw-r--r-- | include/opkele/uris.h | 1 | ||||
-rw-r--r-- | lib/sreg.cc | 2 |
2 files changed, 3 insertions, 0 deletions
diff --git a/include/opkele/uris.h b/include/opkele/uris.h index 3243831..56c2d6d 100644 --- a/include/opkele/uris.h +++ b/include/opkele/uris.h | |||
@@ -1,17 +1,18 @@ | |||
1 | #ifndef __OPKELE_URIS_H | 1 | #ifndef __OPKELE_URIS_H |
2 | #define __OPKELE_URIS_H | 2 | #define __OPKELE_URIS_H |
3 | 3 | ||
4 | #define NSURI_XRDS "xri://$xrds" | 4 | #define NSURI_XRDS "xri://$xrds" |
5 | #define NSURI_XRD "xri://$xrd*($v*2.0)" | 5 | #define NSURI_XRD "xri://$xrd*($v*2.0)" |
6 | #define NSURI_OPENID10 "http://openid.net/xmlns/1.0" | 6 | #define NSURI_OPENID10 "http://openid.net/xmlns/1.0" |
7 | 7 | ||
8 | #define OIURI_OPENID20 "http://specs.openid.net/auth/2.0" | 8 | #define OIURI_OPENID20 "http://specs.openid.net/auth/2.0" |
9 | #define OIURI_SREG11 "http://openid.net/extensions/sreg/1.1" | ||
9 | 10 | ||
10 | #define STURI_OPENID10 "http://openid.net/signon/1.0" | 11 | #define STURI_OPENID10 "http://openid.net/signon/1.0" |
11 | #define STURI_OPENID11 "http://openid.net/signon/1.1" | 12 | #define STURI_OPENID11 "http://openid.net/signon/1.1" |
12 | #define STURI_OPENID20 "http://specs.openid.net/auth/2.0/signon" | 13 | #define STURI_OPENID20 "http://specs.openid.net/auth/2.0/signon" |
13 | #define STURI_OPENID20_OP"http://specs.openid.net/auth/2.0/server" | 14 | #define STURI_OPENID20_OP"http://specs.openid.net/auth/2.0/server" |
14 | 15 | ||
15 | #define IDURI_SELECT20 "http://specs.openid.net/auth/2.0/identifier_select" | 16 | #define IDURI_SELECT20 "http://specs.openid.net/auth/2.0/identifier_select" |
16 | 17 | ||
17 | #endif /* __OPKELE_URIS_H */ | 18 | #endif /* __OPKELE_URIS_H */ |
diff --git a/lib/sreg.cc b/lib/sreg.cc index 60dc691..dd7ed12 100644 --- a/lib/sreg.cc +++ b/lib/sreg.cc | |||
@@ -1,18 +1,19 @@ | |||
1 | #include <opkele/exception.h> | 1 | #include <opkele/exception.h> |
2 | #include <opkele/sreg.h> | 2 | #include <opkele/sreg.h> |
3 | #include <opkele/uris.h> | ||
3 | #include <algorithm> | 4 | #include <algorithm> |
4 | 5 | ||
5 | namespace opkele { | 6 | namespace opkele { |
6 | using std::find; | 7 | using std::find; |
7 | 8 | ||
8 | static const struct _sreg_field { | 9 | static const struct _sreg_field { |
9 | const char *fieldname; | 10 | const char *fieldname; |
10 | sreg_t::fieldbit_t fieldbit; | 11 | sreg_t::fieldbit_t fieldbit; |
11 | }fields[] = { | 12 | }fields[] = { |
12 | { "nickname", sreg_t::field_nickname }, | 13 | { "nickname", sreg_t::field_nickname }, |
13 | { "email", sreg_t::field_email }, | 14 | { "email", sreg_t::field_email }, |
14 | { "fullname", sreg_t::field_fullname }, | 15 | { "fullname", sreg_t::field_fullname }, |
15 | { "dob", sreg_t::field_dob }, | 16 | { "dob", sreg_t::field_dob }, |
16 | { "gender", sreg_t::field_gender }, | 17 | { "gender", sreg_t::field_gender }, |
17 | { "postcode", sreg_t::field_postcode }, | 18 | { "postcode", sreg_t::field_postcode }, |
18 | { "country", sreg_t::field_country }, | 19 | { "country", sreg_t::field_country }, |
@@ -26,32 +27,33 @@ namespace opkele { | |||
26 | bool operator==(const struct _sreg_field& fd,const string& fn) { | 27 | bool operator==(const struct _sreg_field& fd,const string& fn) { |
27 | return fd.fieldname==fn; | 28 | return fd.fieldname==fn; |
28 | } | 29 | } |
29 | 30 | ||
30 | void sreg_t::checkid_hook(params_t& p,const string& /* identity */) { | 31 | void sreg_t::checkid_hook(params_t& p,const string& /* identity */) { |
31 | string fr, fo; | 32 | string fr, fo; |
32 | for(fields_iterator f=fields_BEGIN;f<fields_END;++f) { | 33 | for(fields_iterator f=fields_BEGIN;f<fields_END;++f) { |
33 | if(f->fieldbit&fields_required) { | 34 | if(f->fieldbit&fields_required) { |
34 | if(!fr.empty()) fr+=","; | 35 | if(!fr.empty()) fr+=","; |
35 | fr += f->fieldname; | 36 | fr += f->fieldname; |
36 | } | 37 | } |
37 | if(f->fieldbit&fields_optional) { | 38 | if(f->fieldbit&fields_optional) { |
38 | if(!fo.empty()) fo+=","; | 39 | if(!fo.empty()) fo+=","; |
39 | fo += f->fieldname; | 40 | fo += f->fieldname; |
40 | } | 41 | } |
41 | } | 42 | } |
43 | p["sreg.ns"] = OIURI_SREG11; | ||
42 | if(!fr.empty()) p["sreg.required"]=fr; | 44 | if(!fr.empty()) p["sreg.required"]=fr; |
43 | if(!fo.empty()) p["sreg.optional"]=fo; | 45 | if(!fo.empty()) p["sreg.optional"]=fo; |
44 | if(!policy_url.empty()) p["sreg.policy_url"]=policy_url; | 46 | if(!policy_url.empty()) p["sreg.policy_url"]=policy_url; |
45 | } | 47 | } |
46 | 48 | ||
47 | void sreg_t::id_res_hook(const params_t& /* p */,const params_t& sp,const string& /* identity */) { | 49 | void sreg_t::id_res_hook(const params_t& /* p */,const params_t& sp,const string& /* identity */) { |
48 | clear(); | 50 | clear(); |
49 | for(fields_iterator f=fields_BEGIN;f<fields_END;++f) { | 51 | for(fields_iterator f=fields_BEGIN;f<fields_END;++f) { |
50 | string fn = "sreg."; fn+=f->fieldname; | 52 | string fn = "sreg."; fn+=f->fieldname; |
51 | if(!sp.has_param(fn)) continue; | 53 | if(!sp.has_param(fn)) continue; |
52 | has_fields |= f->fieldbit; | 54 | has_fields |= f->fieldbit; |
53 | response[f->fieldbit]=sp.get_param(fn); | 55 | response[f->fieldbit]=sp.get_param(fn); |
54 | } | 56 | } |
55 | } | 57 | } |
56 | 58 | ||
57 | const string& sreg_t::get_field(fieldbit_t fb) const { | 59 | const string& sreg_t::get_field(fieldbit_t fb) const { |