-rw-r--r-- | include/opkele/discovery.h | 1 | ||||
-rw-r--r-- | lib/discovery.cc | 2 | ||||
-rw-r--r-- | test/idiscover.cc | 1 |
3 files changed, 4 insertions, 0 deletions
diff --git a/include/opkele/discovery.h b/include/opkele/discovery.h index 5d7129b..7865fb2 100644 --- a/include/opkele/discovery.h +++ b/include/opkele/discovery.h | |||
@@ -9,12 +9,13 @@ namespace opkele { | |||
9 | 9 | ||
10 | struct idiscovery_t; | 10 | struct idiscovery_t; |
11 | 11 | ||
12 | void idiscover(idiscovery_t& result,const string& identity); | 12 | void idiscover(idiscovery_t& result,const string& identity); |
13 | 13 | ||
14 | struct idiscovery_t { | 14 | struct idiscovery_t { |
15 | bool xri_identity; | ||
15 | string normalized_id; | 16 | string normalized_id; |
16 | string canonicalized_id; | 17 | string canonicalized_id; |
17 | xrd::XRD_t xrd; | 18 | xrd::XRD_t xrd; |
18 | 19 | ||
19 | idiscovery_t(const string& i) { | 20 | idiscovery_t(const string& i) { |
20 | idiscover(*this,i); | 21 | idiscover(*this,i); |
diff --git a/lib/discovery.cc b/lib/discovery.cc index a35ce32..1f23ff1 100644 --- a/lib/discovery.cc +++ b/lib/discovery.cc | |||
@@ -92,23 +92,25 @@ namespace opkele { | |||
92 | fsc += sizeof("xri://")-1; | 92 | fsc += sizeof("xri://")-1; |
93 | if((fsc+1)>=lsc) | 93 | if((fsc+1)>=lsc) |
94 | throw bad_input(OPKELE_CP_ "not a character of importance in identity"); | 94 | throw bad_input(OPKELE_CP_ "not a character of importance in identity"); |
95 | string id(identity,fsc,lsc-fsc+1); | 95 | string id(identity,fsc,lsc-fsc+1); |
96 | if(strchr(i_leaders,id[0])) { | 96 | if(strchr(i_leaders,id[0])) { |
97 | result.normalized_id = id; | 97 | result.normalized_id = id; |
98 | result.xri_identity = true; | ||
98 | /* TODO: further canonicalize xri identity? Like folding case or whatever... */ | 99 | /* TODO: further canonicalize xri identity? Like folding case or whatever... */ |
99 | discover_at( | 100 | discover_at( |
100 | result, | 101 | result, |
101 | xri_proxy + util::url_encode(id)+ | 102 | xri_proxy + util::url_encode(id)+ |
102 | "?_xrd_r=application/xrd+xml;sep=false", xmode_xrd); | 103 | "?_xrd_r=application/xrd+xml;sep=false", xmode_xrd); |
103 | if(status_code!=100) | 104 | if(status_code!=100) |
104 | throw failed_xri_resolution(OPKELE_CP_ | 105 | throw failed_xri_resolution(OPKELE_CP_ |
105 | "XRI resolution failed with '"+status_string+"' message",status_code); | 106 | "XRI resolution failed with '"+status_string+"' message",status_code); |
106 | if(result.xrd.canonical_ids.empty()) | 107 | if(result.xrd.canonical_ids.empty()) |
107 | throw opkele::failed_discovery(OPKELE_CP_ "No CanonicalID for XRI identity found"); | 108 | throw opkele::failed_discovery(OPKELE_CP_ "No CanonicalID for XRI identity found"); |
108 | }else{ | 109 | }else{ |
110 | result.xri_identity = false; | ||
109 | if(id.find("://")==string::npos) | 111 | if(id.find("://")==string::npos) |
110 | id.insert(0,"http://"); | 112 | id.insert(0,"http://"); |
111 | string::size_type fp = id.find('#'); | 113 | string::size_type fp = id.find('#'); |
112 | if(fp!=string::npos) { | 114 | if(fp!=string::npos) { |
113 | string::size_type qp = id.find('?'); | 115 | string::size_type qp = id.find('?'); |
114 | if(qp==string::npos || qp<fp) | 116 | if(qp==string::npos || qp<fp) |
diff --git a/test/idiscover.cc b/test/idiscover.cc index 2abedc9..05cbcae 100644 --- a/test/idiscover.cc +++ b/test/idiscover.cc | |||
@@ -33,12 +33,13 @@ int main(int argc,char **argv) { | |||
33 | opkele::idiscovery_t discovery(argv[a]); | 33 | opkele::idiscovery_t discovery(argv[a]); |
34 | clog | 34 | clog |
35 | << "===============================================================" << endl | 35 | << "===============================================================" << endl |
36 | << "User-supplied ID: " << argv[a] << endl | 36 | << "User-supplied ID: " << argv[a] << endl |
37 | << "Normalized ID: " << discovery.normalized_id << endl | 37 | << "Normalized ID: " << discovery.normalized_id << endl |
38 | << "Canonicalized ID: " << discovery.canonicalized_id << endl | 38 | << "Canonicalized ID: " << discovery.canonicalized_id << endl |
39 | << "The identity is " << (discovery.xri_identity?"":"not ") << "an i-name" << endl | ||
39 | << endl | 40 | << endl |
40 | << "CanonicalID: " << discovery.xrd.canonical_ids << endl | 41 | << "CanonicalID: " << discovery.xrd.canonical_ids << endl |
41 | << "LocalID: " << discovery.xrd.local_ids << endl | 42 | << "LocalID: " << discovery.xrd.local_ids << endl |
42 | << "Services: " << discovery.xrd.services << endl; | 43 | << "Services: " << discovery.xrd.services << endl; |
43 | } | 44 | } |
44 | }catch(exception& e) { | 45 | }catch(exception& e) { |