summaryrefslogtreecommitdiffabout
authorMichael Krelin <hacker@klever.net>2008-02-12 23:37:05 (UTC)
committer Michael Krelin <hacker@klever.net>2008-02-12 23:37:05 (UTC)
commit2048be862b8619ddec90163af05e6472bf5175e4 (patch) (side-by-side diff)
tree74ab3384a2a088abe5748ab93cd2f65fa121e1ae
parenta3eba4c33fee80fcf152dcbd198586e12b687e54 (diff)
downloadlibopkele-2048be862b8619ddec90163af05e6472bf5175e4.zip
libopkele-2048be862b8619ddec90163af05e6472bf5175e4.tar.gz
libopkele-2048be862b8619ddec90163af05e6472bf5175e4.tar.bz2
slight api improvement to ease caching of discovery information
* added opend_endpoint_output_iterator to types.h * changed endpoint_discovery_iterator to the aforementioned iterator typedef * added discover() virtual to prequeue_RP and made use thereof. Signed-off-by: Michael Krelin <hacker@klever.net>
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--include/opkele/discovery.h3
-rw-r--r--include/opkele/prequeue_rp.h8
-rw-r--r--include/opkele/types.h3
-rw-r--r--lib/prequeue_rp.cc9
4 files changed, 19 insertions, 4 deletions
diff --git a/include/opkele/discovery.h b/include/opkele/discovery.h
index 4471597..f2721a6 100644
--- a/include/opkele/discovery.h
+++ b/include/opkele/discovery.h
@@ -76,26 +76,25 @@ namespace opkele {
}
bool empty() const {
return
canonical_ids.empty()
&& local_ids.empty()
&& services.empty();
}
};
}
- typedef util::output_iterator_proxy<openid_endpoint_t>
- endpoint_discovery_iterator;
+ typedef openid_endpoint_output_iterator endpoint_discovery_iterator;
string idiscover(
endpoint_discovery_iterator oi,
const string& identity);
void yadiscover(
endpoint_discovery_iterator oi,
const string& yurl,
const char **types, bool redirs=false);
struct idiscovery_t {
bool xri_identity;
string normalized_id;
diff --git a/include/opkele/prequeue_rp.h b/include/opkele/prequeue_rp.h
index 68fe03d..6f1fda9 100644
--- a/include/opkele/prequeue_rp.h
+++ b/include/opkele/prequeue_rp.h
@@ -72,17 +72,25 @@ namespace opkele {
/**
* In addition to base class implementation it does endpoints
* discovery and queueing
* @param usi User-suppled identifier
*/
void initiate(const string& usi);
/**
* @}
*/
void verify_OP(const string& OP,
const string& claimed_id,const string& identity) const;
+
+ /**
+ * Perform full discovery on identity
+ * @param it iterator used for feeding discovered endpoints back to caller
+ * @param id user supplied identity
+ * @returns normalized identity (canonical identifier can be found in endpoints)
+ */
+ virtual const string discover(openid_endpoint_output_iterator it,const string& id) const;
};
}
#endif /* __OPKELE_RP_H */
diff --git a/include/opkele/types.h b/include/opkele/types.h
index 1f48362..1fab869 100644
--- a/include/opkele/types.h
+++ b/include/opkele/types.h
@@ -216,15 +216,18 @@ namespace opkele {
openid_endpoint_t() { }
openid_endpoint_t(const string& u,const string& cid,const string& lid)
: uri(u), claimed_id(cid), local_id(lid) { }
bool operator==(const openid_endpoint_t& x) const {
return uri==x.uri && local_id==x.local_id; }
bool operator<(const openid_endpoint_t& x) const {
int c;
return (c=strcmp(uri.c_str(),x.uri.c_str()))
? (c<0) : (strcmp(local_id.c_str(),x.local_id.c_str())<0); }
};
+ typedef util::output_iterator_proxy<openid_endpoint_t>
+ openid_endpoint_output_iterator;
+
}
#endif /* __OPKELE_TYPES_H */
diff --git a/lib/prequeue_rp.cc b/lib/prequeue_rp.cc
index 3aa960f..ed1ddfe 100644
--- a/lib/prequeue_rp.cc
+++ b/lib/prequeue_rp.cc
@@ -35,47 +35,52 @@ namespace opkele {
if(oep.local_id==id)
throw __OP_verifier_good_input(OPKELE_CP_ "Found corresponding endpoint");
}
return *this;
}
OP_verifier& operator++() { return *this; }
OP_verifier& operator++(int) { return *this; }
};
void prequeue_RP::verify_OP(const string& OP,const string& claimed_id,const string& identity) const {
try {
- idiscover(OP_verifier(OP,identity),claimed_id);
+ discover(OP_verifier(OP,identity),claimed_id);
throw id_res_unauthorized(OPKELE_CP_
"OP is not authorized to make an assertion regarding the identity");
}catch(__OP_verifier_good_input& ovgi) {
}
}
class endpoint_queuer : public iterator<output_iterator_tag,openid_endpoint_t,void> {
public:
prequeue_RP& rp;
endpoint_queuer(prequeue_RP& r) : rp(r) { }
endpoint_queuer& operator*() { return *this; }
endpoint_queuer& operator=(const openid_endpoint_t& oep) {
rp.queue_endpoint(oep); return *this; }
endpoint_queuer& operator++() { return *this; }
endpoint_queuer& operator++(int) { return *this; }
};
void prequeue_RP::initiate(const string& usi) {
begin_queueing();
- set_normalized_id( idiscover(endpoint_queuer(*this),usi) );
+ set_normalized_id( discover(endpoint_queuer(*this),usi) );
end_queueing();
}
void prequeue_RP::set_normalized_id(const string&) {
}
const string prequeue_RP::get_normalized_id() const {
throw not_implemented(OPKELE_CP_ "get_normalized_id() is not implemented");
}
+ const string prequeue_RP::discover(openid_endpoint_output_iterator it,
+ const string& id) const {
+ return idiscover(it,id);
+ }
+
}