blob: b7288546f3dd5a71ed02ca206477e8920fdbd1d4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
#include <opkele/exception.h>
#include <opkele/oauth_ext.h>
#include <opkele/uris.h>
#include <algorithm>
namespace opkele {
using std::find;
void oauth_ext_t::rp_checkid_hook(basic_openid_message& om) {
string pfx = om.allocate_ns(OIURI_OAUTH10,"oauth");
//required: openid.oauth.consumer=www.plaxo.com
//optional: openid.oauth.scope=http://www.google.com/m8/feeds/
if (m_consumer.empty()) throw bad_input(OPKELE_CP_ "Required consumer key is missing from OAuth extension");
om.set_field(pfx+".consumer", m_consumer);
if (!m_scope.empty()) om.set_field(pfx+".scope", m_scope);
}
void oauth_ext_t::checkid_hook(basic_openid_message& om) {
rp_checkid_hook(om); }
void oauth_ext_t::rp_id_res_hook(const basic_openid_message& om,
const basic_openid_message& sp) {
string pfx;
try {
pfx = om.get_ns(OIURI_OAUTH10);
}catch(failed_lookup&) {
return;
}
pfx += '.';
//required: openid.oauth.request_token=abcdefg
//optional: openid.oauth.consumer=www.plaxo.com
//optional: openid.oauth.scope=http://www.google.com/m8/feeds/
string fn;
fn = pfx + "request_token";
if (sp.has_field(fn)) {
m_request_token = sp.get_field(fn);
} else throw bad_input(OPKELE_CP_ "Missing required response field: "+fn);
fn = pfx + "consumer";
if (sp.has_field(fn)) {
m_consumer = sp.get_field(fn);
}
fn = pfx + "scope";
if (sp.has_field(fn)) {
m_scope = sp.get_field(fn);
}
}
void oauth_ext_t::id_res_hook(const basic_openid_message& om,
const basic_openid_message& sp) {
rp_id_res_hook(om,sp); }
void oauth_ext_t::op_checkid_hook(const basic_openid_message& inm) {
}
void oauth_ext_t::op_id_res_hook(basic_openid_message& oum) {
}
void oauth_ext_t::checkid_hook(const basic_openid_message& inm,
basic_openid_message& oum) {
op_checkid_hook(inm);
setup_response(inm,oum);
op_id_res_hook(oum);
}
void oauth_ext_t::setup_response(const basic_openid_message& /* inm */,basic_openid_message& /* oum */) {
setup_response();
}
void oauth_ext_t::setup_response() {
}
}
|