-rw-r--r-- | lib/prequeue_rp.cc | 81 |
1 files changed, 81 insertions, 0 deletions
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 @@ | |||
1 | #include <iostream> | ||
2 | #include <openssl/sha.h> | ||
3 | #include <openssl/hmac.h> | ||
4 | #include <opkele/exception.h> | ||
5 | #include <opkele/prequeue_rp.h> | ||
6 | #include <opkele/discovery.h> | ||
7 | #include <opkele/uris.h> | ||
8 | #include <opkele/data.h> | ||
9 | #include <opkele/util.h> | ||
10 | #include <opkele/curl.h> | ||
11 | #include <opkele/debug.h> | ||
12 | |||
13 | namespace opkele { | ||
14 | |||
15 | class __OP_verifier_good_input : public exception { | ||
16 | public: | ||
17 | __OP_verifier_good_input(OPKELE_E_PARS) | ||
18 | : exception(OPKELE_E_CONS) { } | ||
19 | }; | ||
20 | |||
21 | class OP_verifier : public iterator<output_iterator_tag,openid_endpoint_t,void> { | ||
22 | public: | ||
23 | const string& OP; | ||
24 | const string& id; | ||
25 | |||
26 | OP_verifier(const string& o,const string& i) | ||
27 | : OP(o), id(i) { } | ||
28 | |||
29 | OP_verifier& operator*() { return *this; } | ||
30 | OP_verifier& operator=(const openid_endpoint_t& oep) { | ||
31 | if(oep.uri==OP) { | ||
32 | if(oep.claimed_id==IDURI_SELECT20 | ||
33 | || oep.local_id==IDURI_SELECT20 ) | ||
34 | throw bad_input(OPKELE_CP_ "claimed_id is an OP-Id"); | ||
35 | if(oep.local_id==id) | ||
36 | throw __OP_verifier_good_input(OPKELE_CP_ "Found corresponding endpoint"); | ||
37 | } | ||
38 | return *this; | ||
39 | } | ||
40 | |||
41 | OP_verifier& operator++() { return *this; } | ||
42 | OP_verifier& operator++(int) { return *this; } | ||
43 | }; | ||
44 | |||
45 | void prequeue_RP::verify_OP(const string& OP,const string& claimed_id,const string& identity) const { | ||
46 | try { | ||
47 | idiscover(OP_verifier(OP,identity),claimed_id); | ||
48 | throw id_res_unauthorized(OPKELE_CP_ | ||
49 | "OP is not authorized to make an assertion regarding the identity"); | ||
50 | }catch(__OP_verifier_good_input& ovgi) { | ||
51 | } | ||
52 | } | ||
53 | |||
54 | class endpoint_queuer : public iterator<output_iterator_tag,openid_endpoint_t,void> { | ||
55 | public: | ||
56 | prequeue_RP& rp; | ||
57 | |||
58 | endpoint_queuer(prequeue_RP& rp) : rp(rp) { } | ||
59 | |||
60 | endpoint_queuer& operator*() { return *this; } | ||
61 | endpoint_queuer& operator=(const openid_endpoint_t& oep) { | ||
62 | rp.queue_endpoint(oep); return *this; } | ||
63 | |||
64 | endpoint_queuer& operator++() { return *this; } | ||
65 | endpoint_queuer& operator++(int) { return *this; } | ||
66 | }; | ||
67 | |||
68 | void prequeue_RP::initiate(const string& usi) { | ||
69 | begin_queueing(); | ||
70 | set_normalized_id( idiscover(endpoint_queuer(*this),usi) ); | ||
71 | end_queueing(); | ||
72 | } | ||
73 | |||
74 | void prequeue_RP::set_normalized_id(const string& nid) { | ||
75 | } | ||
76 | |||
77 | const string prequeue_RP::get_normalized_id() const { | ||
78 | throw not_implemented(OPKELE_CP_ "get_normalized_id() is not implemented"); | ||
79 | } | ||
80 | |||
81 | } | ||