line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package OpenID::Lite::RelyingParty::Discover::Service; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
9
|
use Any::Moose; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
22
|
|
4
|
|
|
|
|
|
|
use OpenID::Lite::Constants::Namespace |
5
|
2
|
|
|
2
|
|
1317
|
qw(SERVER_2_0 SPEC_2_0 SPEC_1_0 SIGNON_2_0 SIGNON_1_1 SIGNON_1_0); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
175
|
|
6
|
2
|
|
|
2
|
|
11
|
use URI; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
38
|
|
7
|
2
|
|
|
2
|
|
865
|
use List::MoreUtils qw(any none); |
|
2
|
|
|
|
|
1192
|
|
|
2
|
|
|
|
|
2297
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
has 'uris' => ( |
10
|
|
|
|
|
|
|
is => 'ro', |
11
|
|
|
|
|
|
|
isa => 'ArrayRef', |
12
|
|
|
|
|
|
|
default => sub { [] }, |
13
|
|
|
|
|
|
|
); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has 'types' => ( |
16
|
|
|
|
|
|
|
is => 'ro', |
17
|
|
|
|
|
|
|
isa => 'ArrayRef', |
18
|
|
|
|
|
|
|
default => sub { [] }, |
19
|
|
|
|
|
|
|
); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
has 'claimed_identifier' => ( |
22
|
|
|
|
|
|
|
is => 'rw', |
23
|
|
|
|
|
|
|
isa => 'Str', |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
has 'op_local_identifier' => ( |
27
|
|
|
|
|
|
|
is => 'rw', |
28
|
|
|
|
|
|
|
isa => 'Str', |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
my @PRIORITY_ORDER = ( SERVER_2_0, SIGNON_2_0, SIGNON_1_1, SIGNON_1_0 ); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
has 'type_priority' => ( |
34
|
|
|
|
|
|
|
is => 'rw', |
35
|
|
|
|
|
|
|
isa => 'Int', |
36
|
|
|
|
|
|
|
default => sub {$#PRIORITY_ORDER} |
37
|
|
|
|
|
|
|
); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
has '_display_identifier' => ( |
40
|
|
|
|
|
|
|
is => 'rw', |
41
|
|
|
|
|
|
|
isa => 'Str', |
42
|
|
|
|
|
|
|
); |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub copy { |
45
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
46
|
0
|
|
|
|
|
0
|
my $class = ref($self); |
47
|
0
|
|
|
|
|
0
|
my $copied = $class->new; |
48
|
0
|
|
|
|
|
0
|
my $uris = $self->uris; |
49
|
0
|
|
|
|
|
0
|
$copied->add_uri($_) for @$uris; |
50
|
0
|
|
|
|
|
0
|
my $types = $self->types; |
51
|
0
|
|
|
|
|
0
|
$copied->add_type($_) for @$types; |
52
|
0
|
0
|
|
|
|
0
|
$copied->claimed_identifier( $self->claimed_identifier ) |
53
|
|
|
|
|
|
|
if $self->claimed_identifier; |
54
|
0
|
0
|
|
|
|
0
|
$copied->op_local_identifier( $self->op_local_identifier ) |
55
|
|
|
|
|
|
|
if $self->op_local_identifier; |
56
|
0
|
0
|
|
|
|
0
|
$copied->_display_identifier( $self->_display_identifier ) |
57
|
|
|
|
|
|
|
if $self->_display_identifier; |
58
|
0
|
|
|
|
|
0
|
return $copied; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub display_identifier { |
62
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
63
|
0
|
|
|
|
|
0
|
my $dispid = shift; |
64
|
0
|
0
|
|
|
|
0
|
if ($dispid) { |
65
|
0
|
|
|
|
|
0
|
$self->_display_identifier($dispid); |
66
|
|
|
|
|
|
|
} else { |
67
|
0
|
0
|
|
|
|
0
|
return $self->_display_identifier if $self->_display_identifier; |
68
|
0
|
0
|
|
|
|
0
|
return unless $self->claimed_identifier; |
69
|
0
|
|
|
|
|
0
|
my $parsed_id = URI->new($self->claimed_identifier); |
70
|
0
|
0
|
|
|
|
0
|
return $self->claimed_identifier if not $parsed_id->fragment; |
71
|
0
|
|
|
|
|
0
|
$parsed_id->fragment(undef); |
72
|
0
|
|
|
|
|
0
|
return $parsed_id->as_string; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub find_local_identifier { |
77
|
10
|
|
|
10
|
1
|
15
|
my $self = shift; |
78
|
10
|
|
66
|
|
|
69
|
return $self->op_local_identifier || $self->claimed_identifier; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub url { |
82
|
10
|
|
|
10
|
1
|
2583
|
my $self = shift; |
83
|
10
|
|
|
|
|
30
|
my $uris = $self->uris; |
84
|
10
|
|
50
|
|
|
61
|
return $uris->[0] || ''; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub is_op_identifier { |
88
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
89
|
0
|
|
|
|
|
0
|
my $types = $self->types; |
90
|
0
|
|
|
0
|
|
0
|
return ( any { $_ eq SERVER_2_0 } @$types ); |
|
0
|
|
|
|
|
0
|
|
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub preferred_namespace { |
94
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
95
|
0
|
0
|
|
|
|
0
|
$self->requires_compatibility_mode ? SPEC_1_0 : SPEC_2_0; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub requires_compatibility_mode { |
99
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
100
|
0
|
|
|
|
|
0
|
my $types = $self->types; |
101
|
0
|
0
|
|
0
|
|
0
|
return ( none { $_ eq SERVER_2_0 || $_ eq SIGNON_2_0 } @$types ); |
|
0
|
|
|
|
|
0
|
|
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub has_uri { |
105
|
0
|
|
|
0
|
1
|
0
|
my ( $self, $uri ) = @_; |
106
|
0
|
|
|
0
|
|
0
|
return ( any { $_ eq $uri } @{ $self->uris } ); |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub add_uri { |
110
|
10
|
|
|
10
|
1
|
15
|
my ( $self, $uri ) = @_; |
111
|
10
|
|
|
|
|
29
|
my $uris = $self->uris; |
112
|
10
|
|
|
|
|
28
|
push @$uris, $uri; |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub add_uris { |
116
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
117
|
0
|
|
|
|
|
0
|
$self->add_uri($_) for @_; |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub add_type { |
121
|
10
|
|
|
10
|
1
|
15
|
my ( $self, $type ) = @_; |
122
|
10
|
|
|
|
|
22
|
my $types = $self->types; |
123
|
10
|
|
|
|
|
37
|
for ( my $i = 0; $i < @PRIORITY_ORDER; $i++ ) { |
124
|
40
|
100
|
66
|
|
|
161
|
if ( $type eq $PRIORITY_ORDER[$i] |
125
|
|
|
|
|
|
|
&& $self->type_priority > $i ) |
126
|
|
|
|
|
|
|
{ |
127
|
10
|
|
|
|
|
36
|
$self->type_priority($i); |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
} |
130
|
10
|
|
|
|
|
27
|
push @$types, $type; |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
sub add_types { |
134
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
135
|
0
|
|
|
|
|
|
$self->add_type($_) for @_; |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
sub has_type { |
139
|
0
|
|
|
0
|
1
|
|
my ( $self, $type ) = @_; |
140
|
0
|
|
|
0
|
|
|
return ( any { $_ eq $type } @{ $self->types } ); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
|
143
|
2
|
|
|
2
|
|
17
|
no Any::Moose; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
21
|
|
144
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
145
|
|
|
|
|
|
|
1; |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head1 NAME |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
OpenID::Lite::Relyingparty::Discover::Service - Discovered information |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head1 SYNOPSIS |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
$service->url; |
154
|
|
|
|
|
|
|
$service->claimed_identifier |
155
|
|
|
|
|
|
|
$service->op_local_identifier |
156
|
|
|
|
|
|
|
$service->copy; |
157
|
|
|
|
|
|
|
$service->find_local_identifier; |
158
|
|
|
|
|
|
|
$service->is_op_identifier; |
159
|
|
|
|
|
|
|
$service->preferred_namespace; |
160
|
|
|
|
|
|
|
$service->requires_compatibility_mode; |
161
|
|
|
|
|
|
|
$service->has_type( ); |
162
|
|
|
|
|
|
|
$service->add_type(); |
163
|
|
|
|
|
|
|
$service->has_uri(); |
164
|
|
|
|
|
|
|
$service->add_uri(); |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=head1 DESCRIPTION |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
This class's object represents discovered information. |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=head1 METHODS |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=head2 new |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
my $service = OpenID::Lite::RelyingParty::Discover::Service->new; |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=head2 url |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
Returns service endpoint url. |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
my $service_endpoint_url = $service->url; |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=head2 add_type |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
Add a type of service the OP provides. |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
use OpenID::Lite::Constants::Namespace qw( SERVER_2_0 SIGNON_2_0 ); |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
$service->add_type( SERVER_2_0 ); |
189
|
|
|
|
|
|
|
$service->add_type( SIGNON_2_0 ); |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=head2 has_type |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
Check if the OP provides indicated type of service. |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
use OpenID::Lite::Constants::Namespace qw( SERVER_2_0 ); |
196
|
|
|
|
|
|
|
$service->has_type( SERVER_2_0 ); |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=head2 add_uri |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
Add endpoint uri |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
$service->has_uri(q{http://yourapp.com/openid/endpoint}); |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
=head2 has_uri |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
Check if the service includes indicated uri. |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
if ( $service->has_uri( $endpoint_uri ) ) { |
209
|
|
|
|
|
|
|
... |
210
|
|
|
|
|
|
|
} |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=head2 claimed_identifier |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
Return claimed identitifier if it has. |
215
|
|
|
|
|
|
|
(When discovery is carried out with claimed_id) |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
my $claimed_id = $service->claimed_identifier; |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
=head2 op_local_identifier |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
Return op local identitifier if it has. |
222
|
|
|
|
|
|
|
(When discovery is carried out with claimed_id and the response which OP returns includes LocalID) |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
my $op_local_identifier = $service->op_local_identifier; |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
=head2 find_local_identifier |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
Returns op_local_identfier if it found. |
229
|
|
|
|
|
|
|
Or return claimed id. |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
my $identity = $service->find_local_identifier; |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
=head2 copy |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
my $copied_service = $service->copy(); |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
=head2 is_op_identifier |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
Return true if this is for OP identifier |
241
|
|
|
|
|
|
|
(When discovery is carried out with OP identifier) |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
if ( $service->is_op_identifier ) { |
244
|
|
|
|
|
|
|
... |
245
|
|
|
|
|
|
|
} |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
=head2 preferred_namespace |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
Return proper namespace for openid.ns |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
=head2 requires_compatibility_mode |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
If the endpoint accepts only OpenID 1.x version protocol, |
254
|
|
|
|
|
|
|
return true. |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
=head1 AUTHOR |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
Lyo Kato, Elyo.kato@gmail.comE |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
Copyright (C) 2009 by Lyo Kato |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
265
|
|
|
|
|
|
|
it under the same terms as Perl itself, either Perl version 5.8.8 or, |
266
|
|
|
|
|
|
|
at your option, any later version of Perl 5 you may have available. |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
=cut |