From 9bfb6fadf71c46bf4cb5adabba0c96c32e84c1bc Mon Sep 17 00:00:00 2001 From: Michael Krelin Date: Sun, 20 Jan 2008 21:08:05 +0000 Subject: the whole library rewritten Signed-off-by: Michael Krelin --- (limited to 'lib/prequeue_rp.cc') diff --git a/lib/prequeue_rp.cc b/lib/prequeue_rp.cc new file mode 100644 index 0000000..e242f87 --- a/dev/null +++ b/lib/prequeue_rp.cc @@ -0,0 +1,81 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace opkele { + + class __OP_verifier_good_input : public exception { + public: + __OP_verifier_good_input(OPKELE_E_PARS) + : exception(OPKELE_E_CONS) { } + }; + + class OP_verifier : public iterator { + public: + const string& OP; + const string& id; + + OP_verifier(const string& o,const string& i) + : OP(o), id(i) { } + + OP_verifier& operator*() { return *this; } + OP_verifier& operator=(const openid_endpoint_t& oep) { + if(oep.uri==OP) { + if(oep.claimed_id==IDURI_SELECT20 + || oep.local_id==IDURI_SELECT20 ) + throw bad_input(OPKELE_CP_ "claimed_id is an OP-Id"); + 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); + 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 { + public: + prequeue_RP& rp; + + endpoint_queuer(prequeue_RP& rp) : rp(rp) { } + + 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) ); + end_queueing(); + } + + void prequeue_RP::set_normalized_id(const string& nid) { + } + + const string prequeue_RP::get_normalized_id() const { + throw not_implemented(OPKELE_CP_ "get_normalized_id() is not implemented"); + } + +} -- cgit v0.9.0.2