-rw-r--r-- | include/opkele/discovery.h | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/include/opkele/discovery.h b/include/opkele/discovery.h index 677d7bb..4471597 100644 --- a/include/opkele/discovery.h +++ b/include/opkele/discovery.h | |||
@@ -1,112 +1,115 @@ | |||
1 | #ifndef __OPKELE_DISCOVERY_H | 1 | #ifndef __OPKELE_DISCOVERY_H |
2 | #define __OPKELE_DISCOVERY_H | 2 | #define __OPKELE_DISCOVERY_H |
3 | 3 | ||
4 | #include <string> | 4 | #include <string> |
5 | #include <opkele/types.h> | 5 | #include <opkele/types.h> |
6 | #include <opkele/basic_rp.h> | ||
7 | 6 | ||
8 | namespace opkele { | 7 | namespace opkele { |
9 | using std::string; | 8 | using std::string; |
10 | 9 | ||
11 | namespace xrd { | 10 | namespace xrd { |
12 | 11 | ||
13 | struct priority_compare { | 12 | struct priority_compare { |
14 | inline bool operator()(long a,long b) const { | 13 | inline bool operator()(long a,long b) const { |
15 | return (a<0) ? false : (b<0) ? true : (a<b); | 14 | return (a<0) ? false : (b<0) ? true : (a<b); |
16 | } | 15 | } |
17 | }; | 16 | }; |
18 | 17 | ||
19 | template <typename _DT> | 18 | template <typename _DT> |
20 | class priority_map : public multimap<long,_DT,priority_compare> { | 19 | class priority_map : public multimap<long,_DT,priority_compare> { |
21 | typedef multimap<long,_DT,priority_compare> map_type; | 20 | typedef multimap<long,_DT,priority_compare> map_type; |
22 | public: | 21 | public: |
23 | 22 | ||
24 | inline _DT& add(long priority,const _DT& d) { | 23 | inline _DT& add(long priority,const _DT& d) { |
25 | return insert(typename map_type::value_type(priority,d))->second; | 24 | return insert(typename map_type::value_type(priority,d))->second; |
26 | } | 25 | } |
27 | 26 | ||
28 | bool has_value(const _DT& d) const { | 27 | bool has_value(const _DT& d) const { |
29 | for(typename map_type::const_iterator i=this->begin();i!=this->end();++i) | 28 | for(typename map_type::const_iterator i=this->begin();i!=this->end();++i) |
30 | if(i->second==d) return true; | 29 | if(i->second==d) return true; |
31 | return false; | 30 | return false; |
32 | } | 31 | } |
33 | }; | 32 | }; |
34 | 33 | ||
35 | typedef priority_map<string> canonical_ids_t; | 34 | typedef priority_map<string> canonical_ids_t; |
36 | typedef priority_map<string> local_ids_t; | 35 | typedef priority_map<string> local_ids_t; |
37 | typedef set<string> types_t; | 36 | typedef set<string> types_t; |
38 | struct uri_t { | 37 | struct uri_t { |
39 | string uri; | 38 | string uri; |
40 | string append; | 39 | string append; |
41 | 40 | ||
42 | uri_t() { } | 41 | uri_t() { } |
43 | uri_t(const string& u) : uri(u) { } | 42 | uri_t(const string& u) : uri(u) { } |
44 | uri_t(const string& u,const string& a) : uri(u), append(a) { } | 43 | uri_t(const string& u,const string& a) : uri(u), append(a) { } |
45 | }; | 44 | }; |
46 | typedef priority_map<uri_t> uris_t; | 45 | typedef priority_map<uri_t> uris_t; |
47 | 46 | ||
48 | class service_t { | 47 | class service_t { |
49 | public: | 48 | public: |
50 | types_t types; | 49 | types_t types; |
51 | uris_t uris; | 50 | uris_t uris; |
52 | local_ids_t local_ids; | 51 | local_ids_t local_ids; |
53 | string provider_id; | 52 | string provider_id; |
54 | 53 | ||
55 | void clear() { | 54 | void clear() { |
56 | types.clear(); | 55 | types.clear(); |
57 | uris.clear(); local_ids.clear(); | 56 | uris.clear(); local_ids.clear(); |
58 | provider_id.clear(); | 57 | provider_id.clear(); |
59 | } | 58 | } |
60 | }; | 59 | }; |
61 | typedef priority_map<service_t> services_t; | 60 | typedef priority_map<service_t> services_t; |
62 | 61 | ||
63 | class XRD_t { | 62 | class XRD_t { |
64 | public: | 63 | public: |
65 | time_t expires; | 64 | time_t expires; |
66 | 65 | ||
67 | canonical_ids_t canonical_ids; | 66 | canonical_ids_t canonical_ids; |
68 | local_ids_t local_ids; | 67 | local_ids_t local_ids; |
69 | services_t services; | 68 | services_t services; |
70 | string provider_id; | 69 | string provider_id; |
71 | 70 | ||
72 | void clear() { | 71 | void clear() { |
73 | expires = 0; | 72 | expires = 0; |
74 | canonical_ids.clear(); local_ids.clear(); | 73 | canonical_ids.clear(); local_ids.clear(); |
75 | services.clear(); | 74 | services.clear(); |
76 | provider_id.clear(); | 75 | provider_id.clear(); |
77 | } | 76 | } |
78 | bool empty() const { | 77 | bool empty() const { |
79 | return | 78 | return |
80 | canonical_ids.empty() | 79 | canonical_ids.empty() |
81 | && local_ids.empty() | 80 | && local_ids.empty() |
82 | && services.empty(); | 81 | && services.empty(); |
83 | } | 82 | } |
84 | 83 | ||
85 | }; | 84 | }; |
86 | 85 | ||
87 | } | 86 | } |
88 | 87 | ||
89 | typedef util::output_iterator_proxy<openid_endpoint_t> | 88 | typedef util::output_iterator_proxy<openid_endpoint_t> |
90 | endpoint_discovery_iterator; | 89 | endpoint_discovery_iterator; |
91 | 90 | ||
92 | string idiscover( | 91 | string idiscover( |
93 | endpoint_discovery_iterator oi, | 92 | endpoint_discovery_iterator oi, |
94 | const string& identity); | 93 | const string& identity); |
94 | void yadiscover( | ||
95 | endpoint_discovery_iterator oi, | ||
96 | const string& yurl, | ||
97 | const char **types, bool redirs=false); | ||
95 | 98 | ||
96 | struct idiscovery_t { | 99 | struct idiscovery_t { |
97 | bool xri_identity; | 100 | bool xri_identity; |
98 | string normalized_id; | 101 | string normalized_id; |
99 | string canonicalized_id; | 102 | string canonicalized_id; |
100 | xrd::XRD_t xrd; | 103 | xrd::XRD_t xrd; |
101 | 104 | ||
102 | idiscovery_t() { } | 105 | idiscovery_t() { } |
103 | 106 | ||
104 | void clear() { | 107 | void clear() { |
105 | normalized_id.clear(); canonicalized_id.clear(); | 108 | normalized_id.clear(); canonicalized_id.clear(); |
106 | xrd.clear(); | 109 | xrd.clear(); |
107 | } | 110 | } |
108 | 111 | ||
109 | }; | 112 | }; |
110 | } | 113 | } |
111 | 114 | ||
112 | #endif /* __OPKELE_DISCOVERY_H */ | 115 | #endif /* __OPKELE_DISCOVERY_H */ |