From 434d42b37ecab09fc91ac8e6c752d3292c10a3b1 Mon Sep 17 00:00:00 2001 From: Michael Krelin Date: Sun, 03 Feb 2008 16:17:47 +0000 Subject: added verify_op that performs discovery on the relying party Signed-off-by: Michael Krelin --- (limited to 'lib/verify_op.cc') diff --git a/lib/verify_op.cc b/lib/verify_op.cc new file mode 100644 index 0000000..e7c26b5 --- a/dev/null +++ b/lib/verify_op.cc @@ -0,0 +1,53 @@ +#include +#include +#include +#include +#include + +namespace opkele { + using std::output_iterator_tag; + + class __RP_verifier_good_input : public exception { + public: + __RP_verifier_good_input(OPKELE_E_PARS) + : exception(OPKELE_E_CONS) { } + }; + + class RP_verifier : public iterator { + public: + int seen; + const string& return_to; + + RP_verifier(const string& rt) + : return_to(rt), seen(0) { } + + RP_verifier& operator*() { return *this; } + RP_verifier& operator=(const openid_endpoint_t& oep) { + if(util::uri_matches_realm(return_to,oep.uri)) + throw __RP_verifier_good_input(OPKELE_CP_ "Found matching realm"); + return *this; + } + + RP_verifier& operator++() { ++seen; return *this; } + RP_verifier& operator++(int) { +seen; return *this; } + }; + + void verify_op::verify_return_to() { + basic_op::verify_return_to(); + try { + RP_verifier rpv(return_to); + string drealm = realm; + string::size_type csss = drealm.find("://*."); + if(csss==4 || csss==5) + drealm.replace(csss+3,1,"www"); + const char *rtt[] = { STURI_OPENID20_RT, 0 }; + yadiscover(rpv,drealm,rtt,false); + if(rpv.seen) + throw bad_return_to(OPKELE_CP_ "return_to URL doesn't match any found while doing discovery on RP"); + }catch(__RP_verifier_good_input&) { + }catch(bad_return_to& brt) { + throw; + }catch(exception_network&) { } + } + +} -- cgit v0.9.0.2