line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::OpenID::Consumer::Yadis; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
23448
|
use strict; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
39
|
|
4
|
1
|
|
|
1
|
|
6
|
use Carp (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
20
|
|
5
|
1
|
|
|
1
|
|
5
|
use base qw(Net::OpenID::Consumer); |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
748
|
|
6
|
1
|
|
|
1
|
|
1578
|
use Net::Yadis::Discovery; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use vars qw($VERSION); |
8
|
|
|
|
|
|
|
$VERSION = "0.01"; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
use fields qw(yadis choose_logic __yadis_localcache); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
13
|
|
|
|
|
|
|
my $self = shift; |
14
|
|
|
|
|
|
|
$self = fields::new( $self ) unless ref $self; |
15
|
|
|
|
|
|
|
my %opts = @_; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
$self->{yadis} = delete $opts{yadis}; |
18
|
|
|
|
|
|
|
$self->{choose_logic} = delete $opts{choose_logic}; |
19
|
|
|
|
|
|
|
$self->{__yadis_localcache} = {}; |
20
|
|
|
|
|
|
|
$self->SUPER::new(%opts); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
return $self; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub choose_logic { &Net::OpenID::Consumer::_getset; } |
26
|
|
|
|
|
|
|
sub __yadis_localcache { &Net::OpenID::Consumer::_getset; } |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub ua { |
29
|
|
|
|
|
|
|
my $self = shift; |
30
|
|
|
|
|
|
|
$self->{ua} = shift if @_; |
31
|
|
|
|
|
|
|
Carp::croak("Too many parameters") if @_; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
unless ($self->{ua}) { |
34
|
|
|
|
|
|
|
$self->{ua} = $self->yadis->ua; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
$self->{ua}; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub yadis { |
41
|
|
|
|
|
|
|
my $self = shift; |
42
|
|
|
|
|
|
|
$self->{yadis} = shift if @_; |
43
|
|
|
|
|
|
|
Carp::croak("Too many parameters") if @_; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
unless ($self->{yadis}) { |
46
|
|
|
|
|
|
|
$self->{yadis} = Net::Yadis::Discovery->new( |
47
|
|
|
|
|
|
|
ua => $self->{ua}, |
48
|
|
|
|
|
|
|
cache => $self->cache, |
49
|
|
|
|
|
|
|
); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
$self->{yadis}->ua($self->{ua}) unless ($self->{yadis}->{_ua}); |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
$self->{yadis}; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub _find_semantic_info { |
57
|
|
|
|
|
|
|
my $self = shift; |
58
|
|
|
|
|
|
|
my $url = shift; |
59
|
|
|
|
|
|
|
my $final_url_ref = shift; |
60
|
|
|
|
|
|
|
my $yadis = $self->yadis; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
if ($self->cache) { |
63
|
|
|
|
|
|
|
$yadis->cache($self->cache) unless ($yadis->cache); |
64
|
|
|
|
|
|
|
} else { |
65
|
|
|
|
|
|
|
$self->cache($yadis->cache ? $yadis->cache : $yadis->cache($self)); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
unless ($yadis->xrd_objects && $yadis->identity_url eq $url) { |
69
|
|
|
|
|
|
|
$yadis->discover($url,YR_GET); # or return $self->_fail($yadis->errcode,$yadis->errtext); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
my $sem_info = {}; |
73
|
|
|
|
|
|
|
if ($url ne $yadis->xrd_url) { |
74
|
|
|
|
|
|
|
$sem_info = $self->SUPER::_find_semantic_info($url,$final_url_ref) or return; |
75
|
|
|
|
|
|
|
} else { |
76
|
|
|
|
|
|
|
$$final_url_ref = $yadis->xrd_url; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
my $logic; |
80
|
|
|
|
|
|
|
if (my $a_ident = $self->args("openid.identity")) { |
81
|
|
|
|
|
|
|
$logic = sub { |
82
|
|
|
|
|
|
|
foreach my $srv (@_) { |
83
|
|
|
|
|
|
|
return ($srv) if ($srv->Delegate eq $a_ident); |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
return; |
86
|
|
|
|
|
|
|
}; |
87
|
|
|
|
|
|
|
} elsif (ref($self->choose_logic) eq 'CODE') { |
88
|
|
|
|
|
|
|
$logic = $self->choose_logic; |
89
|
|
|
|
|
|
|
} else { |
90
|
|
|
|
|
|
|
$logic = sub { |
91
|
|
|
|
|
|
|
# ($_[int(rand(@_))]) |
92
|
|
|
|
|
|
|
($_[0]) |
93
|
|
|
|
|
|
|
}; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
if (my @services = $yadis->openid_servers($logic)) { |
97
|
|
|
|
|
|
|
$sem_info->{'openid.server'} = $services[0]->URI; |
98
|
|
|
|
|
|
|
$sem_info->{'openid.delegate'} = $services[0]->Delegate; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
$self->cache($yadis->cache(undef)) if ($yadis->cache->can("__yadis_localcache")); |
102
|
|
|
|
|
|
|
$self->__yadis_localcache({}); |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
return $sem_info; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub set { |
108
|
|
|
|
|
|
|
my ($self,$key,$value) = @_; |
109
|
|
|
|
|
|
|
$self->__yadis_localcache->{$key} = $value if (defined($key)); |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub get { |
113
|
|
|
|
|
|
|
my ($self,$key) = @_; |
114
|
|
|
|
|
|
|
$self->__yadis_localcache->{$key} if (defined($key)); |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
1; |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
__END__ |