summaryrefslogtreecommitdiffabout
authorMichael Krelin <hacker@klever.net>2008-02-03 15:29:07 (UTC)
committer Michael Krelin <hacker@klever.net>2008-02-03 15:29:07 (UTC)
commit23a6d48436e24d3d145b742984ef68ec3bae2bfd (patch) (side-by-side diff)
tree9cd085f583f4235e4f21e640cfc1b1ab1fb04b06
parentd1c45af16b3bd31f65d03eec0fcd1c61b4d69fb0 (diff)
downloadlibopkele-23a6d48436e24d3d145b742984ef68ec3bae2bfd.zip
libopkele-23a6d48436e24d3d145b742984ef68ec3bae2bfd.tar.gz
libopkele-23a6d48436e24d3d145b742984ef68ec3bae2bfd.tar.bz2
added provisions for discovery on RP
Signed-off-by: Michael Krelin <hacker@klever.net>
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--include/opkele/discovery.h5
-rw-r--r--lib/discovery.cc45
2 files changed, 39 insertions, 11 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
@@ -5,3 +5,2 @@
#include <opkele/types.h>
-#include <opkele/basic_rp.h>
@@ -94,2 +93,6 @@ namespace opkele {
const string& identity);
+ void yadiscover(
+ endpoint_discovery_iterator oi,
+ const string& yurl,
+ const char **types, bool redirs=false);
diff --git a/lib/discovery.cc b/lib/discovery.cc
index 6e20654..6f58339 100644
--- a/lib/discovery.cc
+++ b/lib/discovery.cc
@@ -30,3 +30,3 @@ namespace opkele {
const char *forceid;
- } service_types[] = {
+ } op_service_types[] = {
{ STURI_OPENID20_OP, IDURI_SELECT20 },
@@ -76,3 +76,4 @@ namespace opkele {
enum {
- xmode_html = 1, xmode_xrd = 2, xmode_cid = 4
+ xmode_html = 1, xmode_xrd = 2, xmode_cid = 4,
+ xmode_noredirs = 8
};
@@ -112,2 +113,16 @@ namespace opkele {
+ void yadiscover(endpoint_discovery_iterator oi,const string& yurl,const char **types,bool redirs) {
+ idiscovery_t idis;
+ idis.xri_identity = false;
+ discover_at(idis,yurl,xmode_html|xmode_xrd|(redirs?0:xmode_noredirs));
+ if(!xrds_location.empty()) {
+ idis.clear();
+ discover_at(idis,xrds_location,xmode_xrd);
+ }
+ idis.normalized_id = idis.canonicalized_id = yurl;
+ service_type_t st;
+ for(st.uri=*types;*types;st.uri=*(++types))
+ queue_endpoints(oi,idis,&st);
+ }
+
string discover(endpoint_discovery_iterator& oi,const string& identity) {
@@ -131,4 +146,4 @@ namespace opkele {
set<string> cids;
- for(const struct service_type_t *st=service_types;
- st<&service_types[sizeof(service_types)/sizeof(*service_types)];++st) {
+ for(const struct service_type_t *st=op_service_types;
+ st<&op_service_types[sizeof(op_service_types)/sizeof(*op_service_types)];++st) {
idis.clear();
@@ -196,4 +211,4 @@ namespace opkele {
else{
- for(const service_type_t *st=service_types;
- st<&service_types[sizeof(service_types)/sizeof(*service_types)];++st)
+ for(const service_type_t *st=op_service_types;
+ st<&op_service_types[sizeof(op_service_types)/sizeof(*op_service_types)];++st)
queue_endpoints(oi,idis,st);
@@ -206,5 +221,7 @@ namespace opkele {
void discover_at(idiscovery_t& idis,const string& url,int xm) {
- CURLcode r = easy_setopt(CURLOPT_URL,url.c_str());
+ CURLcode r = easy_setopt(CURLOPT_MAXREDIRS, (xm&xmode_noredirs)?0:5);
if(r)
- throw exception_curl(OPKELE_CP_ "failed to set culry urlie",r);
+ throw exception_curl(OPKELE_CP_ "failed to set curly maxredirs option");
+ if( (r=easy_setopt(CURLOPT_URL,url.c_str())) )
+ throw exception_curl(OPKELE_CP_ "failed to set curly urlie",r);
@@ -274,3 +291,3 @@ namespace opkele {
x.services.add(-1,html_openid2);
- queue_endpoints(oi,id,&service_types[st_index_2]);
+ queue_endpoints(oi,id,&op_service_types[st_index_2]);
}
@@ -279,3 +296,3 @@ namespace opkele {
x.services.add(-1,html_openid1);
- queue_endpoints(oi,id,&service_types[st_index_1]);
+ queue_endpoints(oi,id,&op_service_types[st_index_1]);
}
@@ -551,2 +568,10 @@ namespace opkele {
+ void yadiscover(endpoint_discovery_iterator oi,const string& yurl,const char **types,bool redirs) try {
+ idigger_t idigger;
+ idigger.yadiscover(oi,yurl,types,redirs);
+ }catch(exception_curl& ec) {
+ if(redirs || ec._error!=CURLE_TOO_MANY_REDIRECTS)
+ throw;
+ }
+
}