-rw-r--r-- | lib/discovery.cc | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/lib/discovery.cc b/lib/discovery.cc index 93409f4..6e20654 100644 --- a/lib/discovery.cc +++ b/lib/discovery.cc @@ -60,4 +60,13 @@ namespace opkele { return -1; } + /* TODO: ideally all attributes should be + * retrieved in one run */ + static const char *element_attr(const XML_Char **a, const char *at) { + for(;*a;++a) + if(!strcasecmp(*(a++),at)) { + return *a; + } + return 0; + } class idigger_t : public util::curl_t, public util::expat_t { @@ -119,6 +128,5 @@ namespace opkele { /* TODO: further normalize xri identity? Like folding case * or whatever... */ - rv = idis.normalized_id = id; - idis.xri_identity = true; + rv = id; set<string> cids; for(const struct service_type_t *st=service_types; @@ -156,4 +164,5 @@ namespace opkele { } idis.canonicalized_id = cid; + idis.normalized_id = rv; idis.xri_identity = true; queue_endpoints(oi,idis,st); } @@ -196,5 +205,4 @@ namespace opkele { void discover_at(idiscovery_t& idis,const string& url,int xm) { - DOUT_("Doing discovery at " << url); CURLcode r = easy_setopt(CURLOPT_URL,url.c_str()); if(r) @@ -391,5 +399,7 @@ namespace opkele { }else if(is_qelement(n,NSURI_XRD "\tURI")) { assert(xrd); assert(xrd_service); - cdata = &(xrd_service->uris.add(element_priority(a),string())); + const char *append = element_attr(a,"append"); + xrd::uri_t& uri = xrd_service->uris.add(element_priority(a),xrd::uri_t("",append?append:"")); + cdata = &uri.uri; }else if(is_qelement(n,NSURI_XRD "\tLocalID") || is_qelement(n,NSURI_OPENID10 "\tDelegate") ) { @@ -485,9 +495,9 @@ namespace opkele { } if(rel=="openid.server") - html_openid1.uris.add(-1,href); + html_openid1.uris.add(-1,xrd::uri_t(href)); else if(rel=="openid.delegate") html_openid1.local_ids.add(-1,href); else if(rel=="openid2.provider") - html_openid2.uris.add(-1,href); + html_openid2.uris.add(-1,xrd::uri_t(href)); else if(rel=="openid2.local_id") html_openid2.local_ids.add(-1,href); @@ -508,5 +518,10 @@ namespace opkele { if(svc.types.find(st->uri)==svc.types.end()) continue; for(xrd::uris_t::const_iterator iu=svc.uris.begin();iu!=svc.uris.end();++iu) { - ep.uri = iu->second; + ep.uri = iu->second.uri; + if(id.xri_identity) { + if(iu->second.append=="qxri") { + ep.uri += id.normalized_id; + } /* TODO: else handle other append attribute values */ + } if(st->forceid) { ep.local_id = ep.claimed_id = st->forceid; |