author | Michael Krelin <hacker@klever.net> | 2007-12-28 13:20:49 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2008-01-04 18:18:43 (UTC) |
commit | f18a3be558f9df3267f6de4f5889cb16b420be98 (patch) (unidiff) | |
tree | d77f2282b1c812402da3f291394d39fcfd33597e | |
parent | 2ddc48944c5238fa1b99e50fc194d220d9e92f43 (diff) | |
download | libopkele-f18a3be558f9df3267f6de4f5889cb16b420be98.zip libopkele-f18a3be558f9df3267f6de4f5889cb16b420be98.tar.gz libopkele-f18a3be558f9df3267f6de4f5889cb16b420be98.tar.bz2 |
fixed sreg namespace setting ('sreg.ns' to 'ns.sreg')
Signed-off-by: Michael Krelin <hacker@klever.net>
-rw-r--r-- | lib/sreg.cc | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/sreg.cc b/lib/sreg.cc index dd7ed12..03edf57 100644 --- a/lib/sreg.cc +++ b/lib/sreg.cc | |||
@@ -1,91 +1,91 @@ | |||
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 <opkele/uris.h> |
4 | #include <algorithm> | 4 | #include <algorithm> |
5 | 5 | ||
6 | namespace opkele { | 6 | namespace opkele { |
7 | using std::find; | 7 | using std::find; |
8 | 8 | ||
9 | static const struct _sreg_field { | 9 | static const struct _sreg_field { |
10 | const char *fieldname; | 10 | const char *fieldname; |
11 | sreg_t::fieldbit_t fieldbit; | 11 | sreg_t::fieldbit_t fieldbit; |
12 | }fields[] = { | 12 | }fields[] = { |
13 | { "nickname", sreg_t::field_nickname }, | 13 | { "nickname", sreg_t::field_nickname }, |
14 | { "email", sreg_t::field_email }, | 14 | { "email", sreg_t::field_email }, |
15 | { "fullname", sreg_t::field_fullname }, | 15 | { "fullname", sreg_t::field_fullname }, |
16 | { "dob", sreg_t::field_dob }, | 16 | { "dob", sreg_t::field_dob }, |
17 | { "gender", sreg_t::field_gender }, | 17 | { "gender", sreg_t::field_gender }, |
18 | { "postcode", sreg_t::field_postcode }, | 18 | { "postcode", sreg_t::field_postcode }, |
19 | { "country", sreg_t::field_country }, | 19 | { "country", sreg_t::field_country }, |
20 | { "language", sreg_t::field_language }, | 20 | { "language", sreg_t::field_language }, |
21 | { "timezone", sreg_t::field_timezone } | 21 | { "timezone", sreg_t::field_timezone } |
22 | }; | 22 | }; |
23 | # define fields_BEGINfields | 23 | # define fields_BEGINfields |
24 | # define fields_END &fields[sizeof(fields)/sizeof(*fields)] | 24 | # define fields_END &fields[sizeof(fields)/sizeof(*fields)] |
25 | typedef const struct _sreg_field *fields_iterator; | 25 | typedef const struct _sreg_field *fields_iterator; |
26 | 26 | ||
27 | bool operator==(const struct _sreg_field& fd,const string& fn) { | 27 | bool operator==(const struct _sreg_field& fd,const string& fn) { |
28 | return fd.fieldname==fn; | 28 | return fd.fieldname==fn; |
29 | } | 29 | } |
30 | 30 | ||
31 | void sreg_t::checkid_hook(params_t& p,const string& /* identity */) { | 31 | void sreg_t::checkid_hook(params_t& p,const string& /* identity */) { |
32 | string fr, fo; | 32 | string fr, fo; |
33 | for(fields_iterator f=fields_BEGIN;f<fields_END;++f) { | 33 | for(fields_iterator f=fields_BEGIN;f<fields_END;++f) { |
34 | if(f->fieldbit&fields_required) { | 34 | if(f->fieldbit&fields_required) { |
35 | if(!fr.empty()) fr+=","; | 35 | if(!fr.empty()) fr+=","; |
36 | fr += f->fieldname; | 36 | fr += f->fieldname; |
37 | } | 37 | } |
38 | if(f->fieldbit&fields_optional) { | 38 | if(f->fieldbit&fields_optional) { |
39 | if(!fo.empty()) fo+=","; | 39 | if(!fo.empty()) fo+=","; |
40 | fo += f->fieldname; | 40 | fo += f->fieldname; |
41 | } | 41 | } |
42 | } | 42 | } |
43 | p["sreg.ns"] = OIURI_SREG11; | 43 | p["ns.sreg"] = OIURI_SREG11; |
44 | if(!fr.empty()) p["sreg.required"]=fr; | 44 | if(!fr.empty()) p["sreg.required"]=fr; |
45 | if(!fo.empty()) p["sreg.optional"]=fo; | 45 | if(!fo.empty()) p["sreg.optional"]=fo; |
46 | if(!policy_url.empty()) p["sreg.policy_url"]=policy_url; | 46 | if(!policy_url.empty()) p["sreg.policy_url"]=policy_url; |
47 | } | 47 | } |
48 | 48 | ||
49 | 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 */) { |
50 | clear(); | 50 | clear(); |
51 | for(fields_iterator f=fields_BEGIN;f<fields_END;++f) { | 51 | for(fields_iterator f=fields_BEGIN;f<fields_END;++f) { |
52 | string fn = "sreg."; fn+=f->fieldname; | 52 | string fn = "sreg."; fn+=f->fieldname; |
53 | if(!sp.has_param(fn)) continue; | 53 | if(!sp.has_param(fn)) continue; |
54 | has_fields |= f->fieldbit; | 54 | has_fields |= f->fieldbit; |
55 | response[f->fieldbit]=sp.get_param(fn); | 55 | response[f->fieldbit]=sp.get_param(fn); |
56 | } | 56 | } |
57 | } | 57 | } |
58 | 58 | ||
59 | const string& sreg_t::get_field(fieldbit_t fb) const { | 59 | const string& sreg_t::get_field(fieldbit_t fb) const { |
60 | response_t::const_iterator i = response.find(fb); | 60 | response_t::const_iterator i = response.find(fb); |
61 | if(i==response.end()) | 61 | if(i==response.end()) |
62 | throw failed_lookup(OPKELE_CP_ "no field data available"); | 62 | throw failed_lookup(OPKELE_CP_ "no field data available"); |
63 | return i->second; | 63 | return i->second; |
64 | } | 64 | } |
65 | 65 | ||
66 | void sreg_t::set_field(fieldbit_t fb,const string& fv) { | 66 | void sreg_t::set_field(fieldbit_t fb,const string& fv) { |
67 | response[fb] = fv; | 67 | response[fb] = fv; |
68 | has_fields |= fb; | 68 | has_fields |= fb; |
69 | } | 69 | } |
70 | 70 | ||
71 | void sreg_t::reset_field(fieldbit_t fb) { | 71 | void sreg_t::reset_field(fieldbit_t fb) { |
72 | has_fields &= ~fb; | 72 | has_fields &= ~fb; |
73 | response.erase(fb); | 73 | response.erase(fb); |
74 | } | 74 | } |
75 | 75 | ||
76 | void sreg_t::clear() { | 76 | void sreg_t::clear() { |
77 | has_fields = 0; response.clear(); | 77 | has_fields = 0; response.clear(); |
78 | } | 78 | } |
79 | 79 | ||
80 | static long fields_list_to_bitmask(string& fl) { | 80 | static long fields_list_to_bitmask(string& fl) { |
81 | long rv = 0; | 81 | long rv = 0; |
82 | while(!fl.empty()) { | 82 | while(!fl.empty()) { |
83 | string::size_type co = fl.find(','); | 83 | string::size_type co = fl.find(','); |
84 | string fn; | 84 | string fn; |
85 | if(co==string::npos) { | 85 | if(co==string::npos) { |
86 | fn = fl; fl.erase(); | 86 | fn = fl; fl.erase(); |
87 | }else{ | 87 | }else{ |
88 | fn = fl.substr(0,co); fl.erase(0,co+1); | 88 | fn = fl.substr(0,co); fl.erase(0,co+1); |
89 | } | 89 | } |
90 | fields_iterator f = find(fields_BEGIN,fields_END,fn); | 90 | fields_iterator f = find(fields_BEGIN,fields_END,fn); |
91 | if(f!=fields_END) | 91 | if(f!=fields_END) |