line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package OpenID::Lite::Extension::SREG::Response; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
2811
|
use Any::Moose; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
use List::MoreUtils qw(any none); |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
extends 'OpenID::Lite::Extension::Response'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use OpenID::Lite::Extension::SREG qw(SREG_NS_1_0 SREG_NS_1_1 SREG_NS_ALIAS); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has 'data' => ( |
11
|
|
|
|
|
|
|
is => 'rw', |
12
|
|
|
|
|
|
|
isa => 'HashRef', |
13
|
|
|
|
|
|
|
required => 1, |
14
|
|
|
|
|
|
|
); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
has 'ns_url' => ( |
17
|
|
|
|
|
|
|
is => 'rw', |
18
|
|
|
|
|
|
|
isa => 'Str', |
19
|
|
|
|
|
|
|
default => sub {SREG_NS_1_1}, |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
has 'ns_alias' => ( |
23
|
|
|
|
|
|
|
is => 'rw', |
24
|
|
|
|
|
|
|
isa => 'Str', |
25
|
|
|
|
|
|
|
default => sub {SREG_NS_ALIAS}, |
26
|
|
|
|
|
|
|
); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub extract_response { |
29
|
|
|
|
|
|
|
my ( $class, $req, $data ) = @_; |
30
|
|
|
|
|
|
|
my $fields = $req->all_requested_fields(); |
31
|
|
|
|
|
|
|
my $rejected = {}; |
32
|
|
|
|
|
|
|
for my $key ( keys %$data ) { |
33
|
|
|
|
|
|
|
next unless ( any { $_ eq $key } @$fields ); |
34
|
|
|
|
|
|
|
$rejected->{$key} = $data->{$key}; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
return $class->new( |
37
|
|
|
|
|
|
|
data => $rejected, |
38
|
|
|
|
|
|
|
ns_url => $req->ns_url |
39
|
|
|
|
|
|
|
); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub from_success_response { |
43
|
|
|
|
|
|
|
my ( $class, $res ) = @_; |
44
|
|
|
|
|
|
|
my $message = $res->params->copy(); |
45
|
|
|
|
|
|
|
my $ns_url = SREG_NS_1_1; |
46
|
|
|
|
|
|
|
my $alias = $message->get_ns_alias($ns_url); |
47
|
|
|
|
|
|
|
unless ($alias) { |
48
|
|
|
|
|
|
|
$ns_url = SREG_NS_1_0; |
49
|
|
|
|
|
|
|
$alias = $message->get_ns_alias($ns_url); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
return unless $alias; |
52
|
|
|
|
|
|
|
my $data = $message->get_extension_args($alias) || {}; |
53
|
|
|
|
|
|
|
return $class->new( |
54
|
|
|
|
|
|
|
data => $data, |
55
|
|
|
|
|
|
|
ns_url => $ns_url |
56
|
|
|
|
|
|
|
); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
override 'append_to_params' => sub { |
60
|
|
|
|
|
|
|
my ( $self, $params ) = @_; |
61
|
|
|
|
|
|
|
$params->register_extension_namespace( $self->ns_alias, $self->ns_url ); |
62
|
|
|
|
|
|
|
for my $key ( keys %{ $self->data } ) { |
63
|
|
|
|
|
|
|
$params->set_extension( |
64
|
|
|
|
|
|
|
$self->ns_alias, |
65
|
|
|
|
|
|
|
$key, |
66
|
|
|
|
|
|
|
$self->data->{$key}, |
67
|
|
|
|
|
|
|
); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
}; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
no Any::Moose; |
72
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
73
|
|
|
|
|
|
|
1; |
74
|
|
|
|
|
|
|
|