summaryrefslogtreecommitdiffabout
authorMichael Krelin <hacker@klever.net>2008-01-21 19:51:23 (UTC)
committer Michael Krelin <hacker@klever.net>2008-01-21 19:51:23 (UTC)
commit2a116bce75236e46946bb9564790c26c6a59b9a4 (patch) (side-by-side diff)
tree27b047f773ea2f37d080c8c9c8f583d345649856
parenteee78b62ac9c4aed629fc47eb2af6615ca17d2e2 (diff)
downloadlibopkele-2a116bce75236e46946bb9564790c26c6a59b9a4.zip
libopkele-2a116bce75236e46946bb9564790c26c6a59b9a4.tar.gz
libopkele-2a116bce75236e46946bb9564790c26c6a59b9a4.tar.bz2
Implement URI construction handling append='qxri' xrd:URI attribute.
This is the right thing to do and may come in handy assisting OPs in improving UI. Signed-off-by: Michael Krelin <hacker@klever.net>
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--include/opkele/discovery.h10
-rw-r--r--lib/discovery.cc29
2 files changed, 31 insertions, 8 deletions
diff --git a/include/opkele/discovery.h b/include/opkele/discovery.h
index ab4b9d9..677d7bb 100644
--- a/include/opkele/discovery.h
+++ b/include/opkele/discovery.h
@@ -37,3 +37,11 @@ namespace opkele {
typedef set<string> types_t;
- typedef priority_map<string> uris_t;
+ struct uri_t {
+ string uri;
+ string append;
+
+ uri_t() { }
+ uri_t(const string& u) : uri(u) { }
+ uri_t(const string& u,const string& a) : uri(u), append(a) { }
+ };
+ typedef priority_map<uri_t> uris_t;
diff --git a/lib/discovery.cc b/lib/discovery.cc
index 93409f4..6e20654 100644
--- a/lib/discovery.cc
+++ b/lib/discovery.cc
@@ -61,2 +61,11 @@ namespace opkele {
}
+ /* 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;
+ }
@@ -120,4 +129,3 @@ namespace opkele {
* or whatever... */
- rv = idis.normalized_id = id;
- idis.xri_identity = true;
+ rv = id;
set<string> cids;
@@ -157,2 +165,3 @@ namespace opkele {
idis.canonicalized_id = cid;
+ idis.normalized_id = rv; idis.xri_identity = true;
queue_endpoints(oi,idis,st);
@@ -197,3 +206,2 @@ 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());
@@ -392,3 +400,5 @@ namespace opkele {
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")
@@ -486,3 +496,3 @@ 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")
@@ -490,3 +500,3 @@ namespace opkele {
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")
@@ -509,3 +519,8 @@ namespace opkele {
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) {