| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package OpenID::Lite::Provider::Handler::Association; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
6
|
use Any::Moose; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
12
|
|
|
4
|
1
|
|
|
1
|
|
765
|
use OpenID::Lite::Message; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
9
|
|
|
5
|
1
|
|
|
1
|
|
29
|
use OpenID::Lite::Constants::SessionType qw(:all); |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
180
|
|
|
6
|
1
|
|
|
1
|
|
7
|
use OpenID::Lite::Constants::AssocType qw(:all); |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
104
|
|
|
7
|
1
|
|
|
1
|
|
6
|
use OpenID::Lite::Constants::Namespace qw(:all); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
158
|
|
|
8
|
1
|
|
|
1
|
|
7
|
use OpenID::Lite::Constants::ProviderResponseType qw(:all); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
132
|
|
|
9
|
1
|
|
|
1
|
|
49
|
use OpenID::Lite::SessionHandlers; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
with 'OpenID::Lite::Role::ErrorHandler'; |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has 'assoc_builder' => ( |
|
13
|
|
|
|
|
|
|
is => 'ro', |
|
14
|
|
|
|
|
|
|
isa => 'OpenID::Lite::Provider::AssociationBuilder', |
|
15
|
|
|
|
|
|
|
); |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub handle_request { |
|
18
|
|
|
|
|
|
|
my ( $self, $req_params ) = @_; |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# check session type |
|
21
|
|
|
|
|
|
|
my $session_type = $req_params->get('session_type'); |
|
22
|
|
|
|
|
|
|
my $ns = $req_params->get('ns'); |
|
23
|
|
|
|
|
|
|
if ( $ns && $req_params->is_openid1 ) { |
|
24
|
|
|
|
|
|
|
$session_type = NO_ENCRYPTION unless $session_type; |
|
25
|
|
|
|
|
|
|
} |
|
26
|
|
|
|
|
|
|
elsif ( $req_params->is_openid2 ) { |
|
27
|
|
|
|
|
|
|
return $self->_build_error( $req_params, |
|
28
|
|
|
|
|
|
|
q{Missing parameter, "session_type".}, $ns ) |
|
29
|
|
|
|
|
|
|
unless $session_type; |
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
else { |
|
32
|
|
|
|
|
|
|
return $self->_build_error( $req_params, |
|
33
|
|
|
|
|
|
|
q{Missing or invalid parameter, "ns"}, $ns ); |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# prepare session handler |
|
37
|
|
|
|
|
|
|
my $session = OpenID::Lite::SessionHandlers->select_session($session_type) |
|
38
|
|
|
|
|
|
|
or return $self->_build_error( $req_params, |
|
39
|
|
|
|
|
|
|
sprintf( q{Invalid session type, "%s"}, $session_type || '' ), $ns ); |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# check assoc_type |
|
42
|
|
|
|
|
|
|
my $assoc_type = $req_params->get('assoc_type') || ''; |
|
43
|
|
|
|
|
|
|
unless ( $assoc_type && $req_params->is_openid1 ) { |
|
44
|
|
|
|
|
|
|
$assoc_type = HMAC_SHA1; |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
unless ( $session->can_handle_assoc_type($assoc_type) ) { |
|
47
|
|
|
|
|
|
|
if ( $req_params->is_openid1 ) { |
|
48
|
|
|
|
|
|
|
return $self->_build_error( $req_params, |
|
49
|
|
|
|
|
|
|
q{Invalid assoc_type and session_type combination.}, $ns ); |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
my $unsupported = OpenID::Lite::Message->new; |
|
52
|
|
|
|
|
|
|
$unsupported->set( ns => $req_params->ns ); |
|
53
|
|
|
|
|
|
|
$unsupported->set( |
|
54
|
|
|
|
|
|
|
error => q{Invalid assoc_type and session_type combination.} ); |
|
55
|
|
|
|
|
|
|
$unsupported->set( error_code => q{unsupported-type} ); |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# set preferred type |
|
58
|
|
|
|
|
|
|
#$unsupported->set( assoc_type => ); |
|
59
|
|
|
|
|
|
|
#$unsupported->set( session_type => ); |
|
60
|
|
|
|
|
|
|
return OpenID::Lite::Provider::Response->new( |
|
61
|
|
|
|
|
|
|
type => DIRECT, |
|
62
|
|
|
|
|
|
|
req_params => $req_params, |
|
63
|
|
|
|
|
|
|
res_params => $unsupported, |
|
64
|
|
|
|
|
|
|
); |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# build association |
|
68
|
|
|
|
|
|
|
my $assoc = $self->assoc_builder->build_association( |
|
69
|
|
|
|
|
|
|
type => $assoc_type, |
|
70
|
|
|
|
|
|
|
dumb => 0, |
|
71
|
|
|
|
|
|
|
); |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
my $res_params = OpenID::Lite::Message->new; |
|
74
|
|
|
|
|
|
|
$res_params->set( ns => $ns ); |
|
75
|
|
|
|
|
|
|
$res_params->set( expires_in => $assoc->expires_in ); |
|
76
|
|
|
|
|
|
|
$res_params->set( assoc_handle => $assoc->handle ); |
|
77
|
|
|
|
|
|
|
$res_params->set( assoc_type => $assoc->type ); |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
$session->set_response_params( $req_params, $res_params, $assoc ); |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
my $res = OpenID::Lite::Provider::Response->new( |
|
82
|
|
|
|
|
|
|
type => DIRECT, |
|
83
|
|
|
|
|
|
|
req_params => $req_params, |
|
84
|
|
|
|
|
|
|
res_params => $res_params, |
|
85
|
|
|
|
|
|
|
); |
|
86
|
|
|
|
|
|
|
return $res; |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub _build_error { |
|
90
|
|
|
|
|
|
|
my ( $self, $req_params, $msg, $ns ) = @_; |
|
91
|
|
|
|
|
|
|
$ns ||= SIGNON_2_0; |
|
92
|
|
|
|
|
|
|
my $error = OpenID::Lite::Message->new(); |
|
93
|
|
|
|
|
|
|
$error->set( ns => $ns ); |
|
94
|
|
|
|
|
|
|
$error->set( error => $msg ); |
|
95
|
|
|
|
|
|
|
my $res = OpenID::Lite::Provider::Response->new( |
|
96
|
|
|
|
|
|
|
type => DIRECT, |
|
97
|
|
|
|
|
|
|
req_params => $req_params, |
|
98
|
|
|
|
|
|
|
res_params => $error, |
|
99
|
|
|
|
|
|
|
); |
|
100
|
|
|
|
|
|
|
return $res; |
|
101
|
|
|
|
|
|
|
} |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
no Any::Moose; |
|
104
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
|
105
|
|
|
|
|
|
|
1; |
|
106
|
|
|
|
|
|
|
|