summaryrefslogtreecommitdiffabout
authorMichael Krelin <hacker@klever.net>2007-12-13 18:33:20 (UTC)
committer Michael Krelin <hacker@klever.net>2007-12-13 18:37:33 (UTC)
commit58383f07af80dfd5b5c18e5158291c3d8caefbe7 (patch) (side-by-side diff)
treefe7b9bc8da74bce0dcc6d8a033b8a8073f81ad14
parent54f9cf0424f47ef6384bc55904097dc4ecb5fc78 (diff)
downloadlibopkele-58383f07af80dfd5b5c18e5158291c3d8caefbe7.zip
libopkele-58383f07af80dfd5b5c18e5158291c3d8caefbe7.tar.gz
libopkele-58383f07af80dfd5b5c18e5158291c3d8caefbe7.tar.bz2
keep track of whether the identity being discovered is XRI
Signed-off-by: Michael Krelin <hacker@klever.net>
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--include/opkele/discovery.h1
-rw-r--r--lib/discovery.cc2
-rw-r--r--test/idiscover.cc1
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 {
struct idiscovery_t;
void idiscover(idiscovery_t& result,const string& identity);
struct idiscovery_t {
+ bool xri_identity;
string normalized_id;
string canonicalized_id;
xrd::XRD_t xrd;
idiscovery_t(const string& i) {
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 {
fsc += sizeof("xri://")-1;
if((fsc+1)>=lsc)
throw bad_input(OPKELE_CP_ "not a character of importance in identity");
string id(identity,fsc,lsc-fsc+1);
if(strchr(i_leaders,id[0])) {
result.normalized_id = id;
+ result.xri_identity = true;
/* TODO: further canonicalize xri identity? Like folding case or whatever... */
discover_at(
result,
xri_proxy + util::url_encode(id)+
"?_xrd_r=application/xrd+xml;sep=false", xmode_xrd);
if(status_code!=100)
throw failed_xri_resolution(OPKELE_CP_
"XRI resolution failed with '"+status_string+"' message",status_code);
if(result.xrd.canonical_ids.empty())
throw opkele::failed_discovery(OPKELE_CP_ "No CanonicalID for XRI identity found");
}else{
+ result.xri_identity = false;
if(id.find("://")==string::npos)
id.insert(0,"http://");
string::size_type fp = id.find('#');
if(fp!=string::npos) {
string::size_type qp = id.find('?');
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) {
opkele::idiscovery_t discovery(argv[a]);
clog
<< "===============================================================" << endl
<< "User-supplied ID: " << argv[a] << endl
<< "Normalized ID: " << discovery.normalized_id << endl
<< "Canonicalized ID: " << discovery.canonicalized_id << endl
+ << "The identity is " << (discovery.xri_identity?"":"not ") << "an i-name" << endl
<< endl
<< "CanonicalID: " << discovery.xrd.canonical_ids << endl
<< "LocalID: " << discovery.xrd.local_ids << endl
<< "Services: " << discovery.xrd.services << endl;
}
}catch(exception& e) {