| 1 | =head1 OVERVIEW | ||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3 | An OpenID server must perform three tasks: | ||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5 | =over | ||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||
| 7 | =item 1. | ||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||
| 9 | Examine the incoming request to determine its nature and validity. | ||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||
| 11 | =item 2. | ||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||
| 13 | Make a decision about how to respond to this request. | ||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||
| 15 | =item 3. | ||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||
| 17 | Format the response according to the protocol. | ||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||
| 19 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||
| 21 | The first and last of these tasks may performed by | ||||||||||||||||||||||||||||||||||||||||||||||
| 22 | the L</decodeRequest> and | ||||||||||||||||||||||||||||||||||||||||||||||
| 23 | L</encodeResponse> methods of the | ||||||||||||||||||||||||||||||||||||||||||||||
| 24 | Server object. Who gets to do the intermediate task -- deciding | ||||||||||||||||||||||||||||||||||||||||||||||
| 25 | how to respond to the request -- will depend on what type of request it | ||||||||||||||||||||||||||||||||||||||||||||||
| 26 | is. | ||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||
| 28 | If it's a request to authenticate a user (a C<checkid_setup> or | ||||||||||||||||||||||||||||||||||||||||||||||
| 29 | C<checkid_immediate> request), you need to decide if you will assert | ||||||||||||||||||||||||||||||||||||||||||||||
| 30 | that this user may claim the identity in question. Exactly how you do | ||||||||||||||||||||||||||||||||||||||||||||||
| 31 | that is a matter of application policy, but it generally involves making | ||||||||||||||||||||||||||||||||||||||||||||||
| 32 | sure the user has an account with your system and is logged in, checking | ||||||||||||||||||||||||||||||||||||||||||||||
| 33 | to see if that identity is hers to claim, and verifying with the user that | ||||||||||||||||||||||||||||||||||||||||||||||
| 34 | she does consent to releasing that information to the party making the | ||||||||||||||||||||||||||||||||||||||||||||||
| 35 | request. | ||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||
| 37 | Examine the properties of the L</CheckIDRequest> object, and if | ||||||||||||||||||||||||||||||||||||||||||||||
| 38 | and when you've come to a decision, form a response by calling | ||||||||||||||||||||||||||||||||||||||||||||||
| 39 | C<</CheckIDRequest->answer>>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||
| 41 | Other types of requests relate to establishing associations between client | ||||||||||||||||||||||||||||||||||||||||||||||
| 42 | and server and verifying the authenticity of previous communications. | ||||||||||||||||||||||||||||||||||||||||||||||
| 43 | The Server instance contains all the logic and data necessary to | ||||||||||||||||||||||||||||||||||||||||||||||
| 44 | respond to | ||||||||||||||||||||||||||||||||||||||||||||||
| 45 | such requests; just pass it to the L</handleRequest> method. | ||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||
| 47 | =head2 OpenID Extensions | ||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||
| 49 | Do you want to provide other information for your users | ||||||||||||||||||||||||||||||||||||||||||||||
| 50 | in addition to authentication? Version 1.2 of the OpenID | ||||||||||||||||||||||||||||||||||||||||||||||
| 51 | protocol allows consumers to add extensions to their requests. | ||||||||||||||||||||||||||||||||||||||||||||||
| 52 | For example, with sites using the L<Simple Registration Extension|http://www.openidenabled.com/openid/simple-registration-extension/>, | ||||||||||||||||||||||||||||||||||||||||||||||
| 53 | a user can agree to have their nickname and e-mail address sent to a | ||||||||||||||||||||||||||||||||||||||||||||||
| 54 | site when they sign up. | ||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||
| 56 | Since extensions do not change the way OpenID authentication works, | ||||||||||||||||||||||||||||||||||||||||||||||
| 57 | code to handle extension requests may be completely separate from the | ||||||||||||||||||||||||||||||||||||||||||||||
| 58 | L</OpenIDRequest> class here. But you'll likely want data sent back by | ||||||||||||||||||||||||||||||||||||||||||||||
| 59 | your extension to be signed. L</OpenIDResponse> provides methods with | ||||||||||||||||||||||||||||||||||||||||||||||
| 60 | which you can add data to it which can be signed with the other data in | ||||||||||||||||||||||||||||||||||||||||||||||
| 61 | the OpenID signature. | ||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||
| 63 | For example: | ||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||
| 65 | # when request is a checkid_* request | ||||||||||||||||||||||||||||||||||||||||||||||
| 66 | response = request.answer(True) | ||||||||||||||||||||||||||||||||||||||||||||||
| 67 | # this will a signed 'openid.sreg.timezone' parameter to the response | ||||||||||||||||||||||||||||||||||||||||||||||
| 68 | response.addField('sreg', 'timezone', 'America/Los_Angeles') | ||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||
| 70 | =head2 Stores | ||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||
| 72 | The OpenID server needs to maintain state between requests in order | ||||||||||||||||||||||||||||||||||||||||||||||
| 73 | to function. Its mechanism for doing this is called a store. The | ||||||||||||||||||||||||||||||||||||||||||||||
| 74 | store interface is defined in L<Net::OpenID::JanRain::Stores>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 75 | Additionally, several concrete store implementations are provided, so that | ||||||||||||||||||||||||||||||||||||||||||||||
| 76 | most sites won't need to implement a custom store. For a store backed | ||||||||||||||||||||||||||||||||||||||||||||||
| 77 | by flat files on disk, see L<Net::OpenID::JanRain::Stores::FileStore>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 78 | For stores based on PostGreSQL, MySQL or SQLite, see the | ||||||||||||||||||||||||||||||||||||||||||||||
| 79 | L<Net::OpenID::JanRain::Stores::SQLStore|Net::OpenID::JanRain::Stores::SQLStore> | ||||||||||||||||||||||||||||||||||||||||||||||
| 80 | module. | ||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||
| 82 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||
| 84 | package Net::OpenID::JanRain::Server::Request; | ||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||
| 90 | =head1 Net::OpenID::JanRain::Server::Request | ||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||
| 92 | The parent class for several types of requests. None of these classes | ||||||||||||||||||||||||||||||||||||||||||||||
| 93 | are to be instantiated by the user, but this class will never | ||||||||||||||||||||||||||||||||||||||||||||||
| 94 | be encountered except as a parent. | ||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||
| 96 | =head2 Method | ||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||
| 98 | =head3 mode | ||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||
| 100 | Returns the C<openid.mode> parameter of this request. | ||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||
| 102 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 1 | my $errorClass = 'Net::OpenID::JanRain::Server::ProtocolError'; | |||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 34 | ▶ | sub mode { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mode: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 34 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 108 | 34 | return $self->{mode}; | |||||||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||
| 111 | package Net::OpenID::JanRain::Server::CheckAuthRequest; | ||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 1 | our @ISA = qw( Net::OpenID::JanRain::Server::Request ); | |||||||||||||||||||||||||||||||||||||||||||||
| 113 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 1 | ▶ | use Net::OpenID::JanRain::Util qw( hashToPairs ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 1 | ▶ | use constant { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 1 | OPENID_PREFIX => 'openid.', | |||||||||||||||||||||||||||||||||||||||||||||
| 121 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||||
| 123 | =head2 Net::OpenID::JanRain::Server::CheckAuthRequest | ||||||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||||||
| 125 | A request object for C<openid.mode=check_authentication>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 126 | This request is best handled by the L</handleRequest> method of | ||||||||||||||||||||||||||||||||||||||||||||||
| 127 | the L</Net::OpenID::JanRain::Server> object. | ||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||
| 129 | However, it does possess an C<answer> method which takes a | ||||||||||||||||||||||||||||||||||||||||||||||
| 130 | L</Net::OpenID::JanRain::Server::Signatory> object. | ||||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||
| 132 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | my ($caller, $assoc_handle, $sig, $signed) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | my $invalidate_handle = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | ▶ | my $class = ref($caller) || $caller; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
ref $caller || $caller
MC/DC0%0/2
ref $caller || $caller
ref $caller
$caller
Truth table0%0/3
A || B
A= ref $callerB= $caller
| |||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | my $self = { | |||||||||||||||||||||||||||||||||||||||||||||
| 141 | mode => 'check_authentication', | ||||||||||||||||||||||||||||||||||||||||||||||
| 142 | assoc_handle => $assoc_handle, | ||||||||||||||||||||||||||||||||||||||||||||||
| 143 | sig => $sig, | ||||||||||||||||||||||||||||||||||||||||||||||
| 144 | signed => $signed, | ||||||||||||||||||||||||||||||||||||||||||||||
| 145 | invalidate_handle => $invalidate_handle, | ||||||||||||||||||||||||||||||||||||||||||||||
| 146 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | bless($self, $class); | |||||||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 6 | ▶ | sub fromQuery { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fromQuery: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 6 | my ($caller, $query) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 6 | my $assoc_handle = $query->{OPENID_PREFIX . 'assoc_handle'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 155 | 6 | my $sig = $query->{OPENID_PREFIX . 'sig'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 156 | 6 | my $signed_list = $query->{OPENID_PREFIX . 'signed'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 157 | 6 | my $invalidate_handle = $query->{OPENID_PREFIX . 'invalidate_handle'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 6 | ▶ | unless (defined($assoc_handle) and | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
defined $assoc_handle and defined $sig and defined $signed_list
defined $assoc_handle and defined $sig
MC/DC33%1/3
defined $assoc_handle and defined $sig and defined $signed_list
defined $assoc_handle
defined $sig
defined $signed_list
Truth table50%2/4
A and B and C
A= defined $assoc_handleB= defined $sigC= defined $signed_list
| |||||||||||||||||||||||||||||||||||||||||||||||
| 160 | defined($sig) and | ||||||||||||||||||||||||||||||||||||||||||||||
| 161 | defined($signed_list)) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 1 | return $errorClass->new($query, "check_authentication request missing required parameters."); | |||||||||||||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 5 | my @signed_list = split ',', $signed_list; | |||||||||||||||||||||||||||||||||||||||||||||
| 166 | 5 | my %vq = %$query; | |||||||||||||||||||||||||||||||||||||||||||||
| 167 | 5 | $vq{OPENID_PREFIX . 'mode'} = 'id_res'; | |||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 5 | my $signed_pairs = hashToPairs(\%vq, \@signed_list, OPENID_PREFIX); | |||||||||||||||||||||||||||||||||||||||||||||
| 170 | 5 | ▶ | return $errorClass->new($query, "Query missing arg in signed list") unless $signed_pairs; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 4 | my $self = { | |||||||||||||||||||||||||||||||||||||||||||||
| 173 | mode => 'check_authentication', | ||||||||||||||||||||||||||||||||||||||||||||||
| 174 | assoc_handle => $assoc_handle, | ||||||||||||||||||||||||||||||||||||||||||||||
| 175 | signed => $signed_pairs, | ||||||||||||||||||||||||||||||||||||||||||||||
| 176 | sig => $sig, | ||||||||||||||||||||||||||||||||||||||||||||||
| 177 | invalidate_handle => $invalidate_handle, | ||||||||||||||||||||||||||||||||||||||||||||||
| 178 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 4 | bless($self); | |||||||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 5 | ▶ | sub answer { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
answer: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 5 | my ($self, $signatory) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 5 | my $is_valid = $signatory->verify($self->{assoc_handle}, $self->{sig}, $self->{signed}); | |||||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 5 | $signatory->invalidate($self->{assoc_handle}, 1); | |||||||||||||||||||||||||||||||||||||||||||||
| 189 | 5 | my $response = Net::OpenID::JanRain::Server::Response->new($self); | |||||||||||||||||||||||||||||||||||||||||||||
| 190 | 5 | ▶ | $response->addFields('',{'is_valid' => (($is_valid and "true") or "false")}); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%4/4
$is_valid && 'true' || 'false'
$is_valid and "true"
MC/DC100%1/1
$is_valid && 'true' || 'false'
$is_valid
Truth table100%2/2
A
A= $is_valid
| |||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 5 | ▶ | if ($self->{invalidate_handle}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 2 | my $assoc = $signatory->getAssociation($self->{invalidate_handle}, 0); | |||||||||||||||||||||||||||||||||||||||||||||
| 194 | 2 | ▶ | $response->addFields('',{'invalidate_handle' => $self->{invalidate_handle}}) unless $assoc; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 5 | return $response; | |||||||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||
| 200 | package Net::OpenID::JanRain::Server::AssociateRequest; | ||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 1 | our @ISA = qw( Net::OpenID::JanRain::Server::Request ); | |||||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 1 | ▶ | use Crypt::DH; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 1 | ▶ | use Net::OpenID::JanRain::Util qw( toBase64 fromBase64 ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 1 | ▶ | use Net::OpenID::JanRain::CryptUtil qw( base64ToNum | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 209 | numToBase64 | ||||||||||||||||||||||||||||||||||||||||||||||
| 210 | numToBytes | ||||||||||||||||||||||||||||||||||||||||||||||
| 211 | sha1 | ||||||||||||||||||||||||||||||||||||||||||||||
| 212 | DEFAULT_DH_MOD | ||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 1 | DEFAULT_DH_GEN ); | |||||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 1 | ▶ | use constant { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 1 | OPENID_PREFIX => 'openid.', | |||||||||||||||||||||||||||||||||||||||||||||
| 217 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||||||
| 219 | =head2 Net::OpenID::JanRain::Server::AssociateRequest | ||||||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||||||
| 221 | A request object for C<openid.mode=associate>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 222 | This request is best handled by the L</handleRequest> method of | ||||||||||||||||||||||||||||||||||||||||||||||
| 223 | the L</Net::OpenID::JanRain::Server> object. | ||||||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||||||
| 225 | However, it does possess an C<answer> method which takes an | ||||||||||||||||||||||||||||||||||||||||||||||
| 226 | L<Net::OpenID::JanRain::Association|Net::OpenID::JanRain::Association> | ||||||||||||||||||||||||||||||||||||||||||||||
| 227 | object. It also has accessor methods C<assoc_type> and C<session_type>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||||||
| 229 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | my ($caller, $session_type, $pubkey); | |||||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | ▶ | my $class = ref($caller) || $caller; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
ref $caller || $caller
MC/DC0%0/2
ref $caller || $caller
ref $caller
$caller
Truth table0%0/3
A || B
A= ref $callerB= $caller
| |||||||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | my $self; | |||||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | ▶ | if ($session_type eq 'DH-SHA1') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | $self = { | |||||||||||||||||||||||||||||||||||||||||||||
| 240 | mode => 'associate', | ||||||||||||||||||||||||||||||||||||||||||||||
| 241 | session_type => $session_type, | ||||||||||||||||||||||||||||||||||||||||||||||
| 242 | pubkey => $pubkey, | ||||||||||||||||||||||||||||||||||||||||||||||
| 243 | dh => Crypt::DH->new(p => DEFAULT_DH_MOD, | ||||||||||||||||||||||||||||||||||||||||||||||
| 244 | g => DEFAULT_DH_GEN ), | ||||||||||||||||||||||||||||||||||||||||||||||
| 245 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 247 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | $self = { | |||||||||||||||||||||||||||||||||||||||||||||
| 249 | session_type => $session_type, | ||||||||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | bless($self, $class); | |||||||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 5 | ▶ | sub fromQuery { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fromQuery: called CC=13 SCAR=32.4
| |||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 5 | my ($caller, $query) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 257 | 5 | ▶ | my $class = ref($caller) || $caller; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $caller || $caller
MC/DC0%0/2
ref $caller || $caller
ref $caller
$caller
Truth table33%1/3
A || B
A= ref $callerB= $caller
| |||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 5 | ▶ | my $assoc_type = $query->{OPENID_PREFIX . 'assoc_type'} || 'HMAC-SHA1'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$query->{'openid.assoc_type'} || 'HMAC-SHA1'
MC/DC100%1/1
$query->{'openid.assoc_type'} || 'HMAC-SHA1'
$query->{'openid.assoc_type'}
Truth table100%2/2
A
A= $query->{'openid.assoc_type'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 5 | ▶ | unless ($assoc_type eq 'HMAC-SHA1') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 1 | return $errorClass->new($query, "Unknown association type '$assoc_type'"); | |||||||||||||||||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 4 | my $session_type = $query->{OPENID_PREFIX . 'session_type'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 4 | my $self = {}; | |||||||||||||||||||||||||||||||||||||||||||||
| 269 | 4 | ▶ | unless ($session_type) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 1 | $session_type = 'plaintext'; | |||||||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 4 | ▶ | if ($session_type eq 'DH-SHA1') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 2 | my $raw_cpub = $query->{OPENID_PREFIX . 'dh_consumer_public'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 274 | 2 | ▶ | unless ($raw_cpub) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 1 | return $errorClass->new($query, | |||||||||||||||||||||||||||||||||||||||||||||
| 276 | 'DH-SHA1 associate request has no public key'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 1 | my $cpub = base64ToNum($raw_cpub); | |||||||||||||||||||||||||||||||||||||||||||||
| 279 | 1 | ▶ | unless (defined($cpub)) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 1 | return $errorClass->new($query, | |||||||||||||||||||||||||||||||||||||||||||||
| 281 | 'DH public key improperly encoded'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | my $dh_modulus = $query->{OPENID_PREFIX . 'dh_modulus'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | ▶ | if (defined($dh_modulus)) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | $dh_modulus = base64ToNum($dh_modulus); | |||||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | ▶ | unless (defined($dh_modulus)) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | return $errorClass->new($query, | |||||||||||||||||||||||||||||||||||||||||||||
| 289 | 'DH modulus improperly encoded'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 292 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | $dh_modulus = DEFAULT_DH_MOD; | |||||||||||||||||||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | my $dh_gen = $query->{OPENID_PREFIX . 'dh_gen'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | ▶ | if (defined($dh_gen)) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | $dh_gen = base64ToNum($dh_gen); | |||||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | ▶ | unless (defined($dh_gen)) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | return $errorClass->new($query, | |||||||||||||||||||||||||||||||||||||||||||||
| 300 | 'DH gen improperly encoded'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 303 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | $dh_gen = DEFAULT_DH_GEN; | |||||||||||||||||||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | $self = { | |||||||||||||||||||||||||||||||||||||||||||||
| 308 | mode => 'associate', | ||||||||||||||||||||||||||||||||||||||||||||||
| 309 | session_type => 'DH-SHA1', | ||||||||||||||||||||||||||||||||||||||||||||||
| 310 | assoc_type => $assoc_type, | ||||||||||||||||||||||||||||||||||||||||||||||
| 311 | pubkey => $cpub, | ||||||||||||||||||||||||||||||||||||||||||||||
| 312 | dh => Crypt::DH->new(g => $dh_gen, p => $dh_modulus), | ||||||||||||||||||||||||||||||||||||||||||||||
| 313 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 315 | elsif ($session_type eq 'plaintext') { | ||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 1 | $self = { | |||||||||||||||||||||||||||||||||||||||||||||
| 317 | mode => 'associate', | ||||||||||||||||||||||||||||||||||||||||||||||
| 318 | session_type => 'plaintext', | ||||||||||||||||||||||||||||||||||||||||||||||
| 319 | assoc_type => $assoc_type, | ||||||||||||||||||||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 322 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 1 | return $errorClass->new($query, "Unknown session type '$session_type'"); | |||||||||||||||||||||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 1 | bless($self, $class); | |||||||||||||||||||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 1 | ▶ | sub answer { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
answer: called CC=3 SCAR=14.2
| |||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 1 | my ($self, $assoc) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 1 | my $response = Net::OpenID::JanRain::Server::Response->new($self); | |||||||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 1 | $response->addFields('',{ | |||||||||||||||||||||||||||||||||||||||||||||
| 334 | assoc_handle => $assoc->handle, | ||||||||||||||||||||||||||||||||||||||||||||||
| 335 | expires_in => $assoc->expiresIn(), | ||||||||||||||||||||||||||||||||||||||||||||||
| 336 | assoc_type => 'HMAC-SHA1', | ||||||||||||||||||||||||||||||||||||||||||||||
| 337 | }); | ||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 1 | ▶ | if ($self->session_type eq 'DH-SHA1') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | my $dh = $self->{dh}; | |||||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | $dh->generate_keys; | |||||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | my $dh_secret = $dh->compute_secret($self->{pubkey}); | |||||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | my $enc_mac_key = $assoc->{secret} ^ sha1(numToBytes($dh_secret)); | |||||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | my $spub = $dh->pub_key; | |||||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | $response->addFields('',{ | |||||||||||||||||||||||||||||||||||||||||||||
| 345 | session_type => $self->session_type, | ||||||||||||||||||||||||||||||||||||||||||||||
| 346 | dh_server_public => numToBase64($spub), | ||||||||||||||||||||||||||||||||||||||||||||||
| 347 | enc_mac_key => toBase64($enc_mac_key), | ||||||||||||||||||||||||||||||||||||||||||||||
| 348 | }); | ||||||||||||||||||||||||||||||||||||||||||||||
| 349 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 350 | elsif ($self->session_type eq 'plaintext') { | ||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 1 | $response->addFields('',{mac_key => toBase64($assoc->secret)}); | |||||||||||||||||||||||||||||||||||||||||||||
| 352 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 353 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 354 | # XXX - kablooie | ||||||||||||||||||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 1 | return $response; | |||||||||||||||||||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 3 | ▶ | sub session_type { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
session_type: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 361 | 3 | return $self->{session_type}; | |||||||||||||||||||||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 1 | ▶ | sub assoc_type { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
assoc_type: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 366 | 1 | return $self->{assoc_type}; | |||||||||||||||||||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||||||
| 369 | package Net::OpenID::JanRain::Server::CheckIDRequest; | ||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 1 | our @ISA = qw( Net::OpenID::JanRain::Server::Request ); | |||||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 1 | ▶ | use URI; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 1 | ▶ | use constant { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 1 | OPENID_PREFIX => 'openid.', | |||||||||||||||||||||||||||||||||||||||||||||
| 378 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||||||
| 380 | =head2 Net::OpenID::JanRain::Server::CheckIDRequest | ||||||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||||||
| 382 | This object represents requests where C<openid.mode=checkid_setup> or | ||||||||||||||||||||||||||||||||||||||||||||||
| 383 | C<openid.mode=checkid_immediate>. It is returned by the L</decodeRequest> | ||||||||||||||||||||||||||||||||||||||||||||||
| 384 | method of L<Net::OpenID::JanRain::Server>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||||||||||
| 386 | =head3 Methods | ||||||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||||||
| 388 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | my ($caller, $identity, $return_to, $optional) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | my $trust_root = $optional->{trust_root}; | |||||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | my $immediate = $optional->{immediate}; | |||||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | my $assoc_handle = $optional->{assoc_handle}; | |||||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | ▶ | my $class = ref($caller) || $caller; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
ref $caller || $caller
MC/DC0%0/2
ref $caller || $caller
ref $caller
$caller
Truth table0%0/3
A || B
A= ref $callerB= $caller
| |||||||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | ▶ | my $self = { | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$trust_root || $return_to
MC/DC0%0/2
$trust_root || $return_to
$trust_root
$return_to
Truth table0%0/3
A || B
A= $trust_rootB= $return_to
| |||||||||||||||||||||||||||||||||||||||||||||||
| 398 | assoc_handle => $assoc_handle, | ||||||||||||||||||||||||||||||||||||||||||||||
| 399 | identity => $identity, | ||||||||||||||||||||||||||||||||||||||||||||||
| 400 | return_to => $return_to, | ||||||||||||||||||||||||||||||||||||||||||||||
| 401 | trust_root => $trust_root || $return_to, | ||||||||||||||||||||||||||||||||||||||||||||||
| 402 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | ▶ | if ($immediate) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | $self->{immediate} = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | $self->{mode} = 'checkid_immediate'; | |||||||||||||||||||||||||||||||||||||||||||||
| 406 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 407 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | $self->{immediate} = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | $self->{mode} = 'checkid_setup'; | |||||||||||||||||||||||||||||||||||||||||||||
| 410 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||||||||
| 412 | my ($tr_valid, $message) = | ||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 0 | checkTrustRoot($self->{trust_root}, $self->{return_to}); | |||||||||||||||||||||||||||||||||||||||||||||
| 414 | 0 | ▶ | unless ($tr_valid) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | carp $message; | |||||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 0 | bless($self, $class); | |||||||||||||||||||||||||||||||||||||||||||||
| 420 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 9 | ▶ | sub fromQuery { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fromQuery: called CC=8 SCAR=20.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 9 | my ($caller, $query) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 424 | 9 | ▶ | my $class = ref($caller) || $caller; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $caller || $caller
MC/DC0%0/2
ref $caller || $caller
ref $caller
$caller
Truth table33%1/3
A || B
A= ref $callerB= $caller
| |||||||||||||||||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 9 | my $mode = $query->{OPENID_PREFIX.'mode'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 427 | 9 | my $self; | |||||||||||||||||||||||||||||||||||||||||||||
| 428 | 9 | ▶ | if ($mode eq "checkid_immediate") { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 429 | $self = { | ||||||||||||||||||||||||||||||||||||||||||||||
| 430 | immediate => 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 431 | mode => 'checkid_immediate', | ||||||||||||||||||||||||||||||||||||||||||||||
| 432 | trust_root => $query->{OPENID_PREFIX.'trust_root'} | ||||||||||||||||||||||||||||||||||||||||||||||
| 433 | || $query->{OPENID_PREFIX.'return_to'}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 3 | ▶ | assoc_handle=> $query->{OPENID_PREFIX.'assoc_handle'}, | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$query->{'openid.trust_root'} || $query->{'openid.return_to'}
MC/DC50%1/2
$query->{'openid.trust_root'} || $query->{'openid.return_to'}
$query->{'openid.trust_root'}
$query->{'openid.return_to'}
Truth table66%2/3
A || B
A= $query->{'openid.trust_root'}B= $query->{'openid.return_to'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 435 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 436 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 437 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 438 | $self = { | ||||||||||||||||||||||||||||||||||||||||||||||
| 439 | immediate => 0, | ||||||||||||||||||||||||||||||||||||||||||||||
| 440 | mode => 'checkid_setup', | ||||||||||||||||||||||||||||||||||||||||||||||
| 441 | trust_root => $query->{OPENID_PREFIX.'trust_root'} | ||||||||||||||||||||||||||||||||||||||||||||||
| 442 | || $query->{OPENID_PREFIX.'return_to'}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 6 | ▶ | assoc_handle=> $query->{OPENID_PREFIX.'assoc_handle'}, | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$query->{'openid.trust_root'} || $query->{'openid.return_to'}
MC/DC100%2/2
$query->{'openid.trust_root'} || $query->{'openid.return_to'}
$query->{'openid.trust_root'}
$query->{'openid.return_to'}
Truth table100%3/3
A || B
A= $query->{'openid.trust_root'}B= $query->{'openid.return_to'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 444 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 445 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 9 | my @required = ('identity', 'return_to'); | |||||||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 9 | for my $field (@required) { | |||||||||||||||||||||||||||||||||||||||||||||
| 449 | 16 | my $value = $query->{OPENID_PREFIX.$field}; | |||||||||||||||||||||||||||||||||||||||||||||
| 450 | 16 | ▶ | unless ($value) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 4 | return $errorClass->new($query, "$field is a required field for a $mode request"); | |||||||||||||||||||||||||||||||||||||||||||||
| 452 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 12 | $self->{$field} = $value; | |||||||||||||||||||||||||||||||||||||||||||||
| 454 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||||||
| 456 | my ($tr_valid, $message) = | ||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 5 | checkTrustRoot($self->{trust_root}, $self->{return_to}); | |||||||||||||||||||||||||||||||||||||||||||||
| 458 | 5 | ▶ | return $errorClass->new($query, $message) unless $tr_valid; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 4 | bless($self, $class); | |||||||||||||||||||||||||||||||||||||||||||||
| 461 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||||||||||||
| 463 | =head4 answer | ||||||||||||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||||||||||||
| 465 | $response = $request->answer($allow, $server_url); | ||||||||||||||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||||||||||||
| 467 | =over | ||||||||||||||||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||||||||||||||||
| 469 | =item $allow | ||||||||||||||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||||||||||||||
| 471 | A boolean value: if true, sends an C<id_res> response. If false, | ||||||||||||||||||||||||||||||||||||||||||||||
| 472 | sends a C<cancel> response if the request is not immediate, and | ||||||||||||||||||||||||||||||||||||||||||||||
| 473 | C<setup_needed> if it is immediate. | ||||||||||||||||||||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||||||||||||||||||||
| 475 | =item $server_url | ||||||||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||||||
| 477 | This argument is required if the request is immediate, and should be the | ||||||||||||||||||||||||||||||||||||||||||||||
| 478 | URL of the server endpoint, used to construct the setup URL. | ||||||||||||||||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||||||||||||||||
| 480 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||||||||||||||||||||
| 482 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 2 | ▶ | sub answer { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
answer: called CC=4 SCAR=15.7
| |||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 486 | 2 | my $allow = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 487 | 2 | my $server_url = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 2 | my $response = Net::OpenID::JanRain::Server::Response->new($self); | |||||||||||||||||||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 2 | ▶ | if($allow) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 1 | $response->addFields('',{ | |||||||||||||||||||||||||||||||||||||||||||||
| 493 | mode => 'id_res', | ||||||||||||||||||||||||||||||||||||||||||||||
| 494 | identity => $self->identity, | ||||||||||||||||||||||||||||||||||||||||||||||
| 495 | return_to => $self->return_to, | ||||||||||||||||||||||||||||||||||||||||||||||
| 496 | }, 1); | ||||||||||||||||||||||||||||||||||||||||||||||
| 497 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 498 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 1 | ▶ | if ($self->immediate) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 0 | ▶ | croak('server_url is required for allow=false in immediate mode') | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 501 | unless $server_url; | ||||||||||||||||||||||||||||||||||||||||||||||
| 502 | # Make a new request just like me, but with immediate=False. | ||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 0 | my $setup_request = Net::OpenID::JanRain::Server::CheckIDRequest->new( | |||||||||||||||||||||||||||||||||||||||||||||
| 504 | $self->identity, $self->return_to, $self->trust_root, | ||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 0, $self->assoc_handle); | ||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 0 | my $setup_url = $setup_request->encodeToURL($server_url); | |||||||||||||||||||||||||||||||||||||||||||||
| 507 | 0 | $response->addFields('',{ mode => 'id_res', | |||||||||||||||||||||||||||||||||||||||||||||
| 508 | user_setup_url => $setup_url | ||||||||||||||||||||||||||||||||||||||||||||||
| 509 | }, 0); # unsigned | ||||||||||||||||||||||||||||||||||||||||||||||
| 510 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 511 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 1 | $response->addFields('',{mode => 'cancel'},0); # unsigned | |||||||||||||||||||||||||||||||||||||||||||||
| 513 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 514 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 2 | return $response; | |||||||||||||||||||||||||||||||||||||||||||||
| 516 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||||||||||||||||||||
| 518 | =head3 encodeToURL | ||||||||||||||||||||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||||||||||||||||||||
| 520 | Takes the server endpoint URL and returns a URL which would generate this | ||||||||||||||||||||||||||||||||||||||||||||||
| 521 | request. | ||||||||||||||||||||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||||||||||||||||||||
| 523 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 0 | ▶ | sub encodeToURL { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
encodeToURL: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 0 | my ($self, $server_url) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 0 | my $q = { | |||||||||||||||||||||||||||||||||||||||||||||
| 529 | OPENID_PREFIX.'mode' => $self->mode, | ||||||||||||||||||||||||||||||||||||||||||||||
| 530 | OPENID_PREFIX.'identity' => $self->identity, | ||||||||||||||||||||||||||||||||||||||||||||||
| 531 | OPENID_PREFIX.'return_to' => $self->return_to | ||||||||||||||||||||||||||||||||||||||||||||||
| 532 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 0 | ▶ | $q->{OPENID_PREFIX.'trust_root'} = $self->trust_root if $self->trust_root; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 0 | ▶ | $q->{OPENID_PREFIX.'assoc_handle'} = $self->assoc_handle if $self->assoc_handle; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 535 | |||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 0 | return appendArgs($server_url, $q); | |||||||||||||||||||||||||||||||||||||||||||||
| 537 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||||||||||||||||||||
| 539 | =head3 getCancelURL | ||||||||||||||||||||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||||||||||||||||||||
| 541 | Returns a URL to redirect the user to send a cancel message to the consumer. | ||||||||||||||||||||||||||||||||||||||||||||||
| 542 | Calling this method will cause croakage if the request is in immediate mode. | ||||||||||||||||||||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||||||||||||||||||||
| 544 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 0 | ▶ | sub getCancelURL { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getCancelURL: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 548 | |||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 0 | ▶ | croak('Cancel is not an appropriate response to an immediate mode request') if $self->immediate; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 550 | |||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 0 | return appendArgs($self->return_to, {OPENID_PREFIX.'mode'=>'cancel'}); | |||||||||||||||||||||||||||||||||||||||||||||
| 552 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||||||||||||||||||||
| 554 | =head3 checkTrustRoot | ||||||||||||||||||||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||||||||||||||||||||
| 556 | $is_return_to_valid_against_trust_root = checkTrustRoot($trust_root, $return_to); | ||||||||||||||||||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||||||||||||||||||
| 558 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||||||||||||||||
| 560 | # in Util now, maybe should be removed? | ||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 5 | ▶ | sub checkTrustRoot { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
checkTrustRoot: called CC=7 SCAR=20.1
| |||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 5 | my ($trust_root, $return_to) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 5 | my $rt = URI->new($return_to); | |||||||||||||||||||||||||||||||||||||||||||||
| 565 | 5 | my $tr = URI->new($trust_root); | |||||||||||||||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 5 | ▶ | return 0, "return_to URL invalid against trust_root: scheme" | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 568 | unless $rt->scheme eq $tr->scheme; | ||||||||||||||||||||||||||||||||||||||||||||||
| 569 | |||||||||||||||||||||||||||||||||||||||||||||||
| 570 | # Check the host | ||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 5 | my $trh = $tr->host; | |||||||||||||||||||||||||||||||||||||||||||||
| 572 | 5 | ▶ | if($trh =~ s/^\*\.//) { # wildcard trust root | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 1 | ▶ | return 0, "return_to URL invalid against trust_root: wchost" | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$rt->host =~ /\w*\.?$trh/ and $rt->port == $tr->port
MC/DC0%0/2
$rt->host =~ /\w*\.?$trh/ and $rt->port == $tr->port
$rt->host =~ /\w*\.?$trh/
$rt->port == $tr->port
Truth table33%1/3
A and B
A= $rt->host =~ /\w*\.?$trh/B= $rt->port == $tr->port
| |||||||||||||||||||||||||||||||||||||||||||||||
| 574 | unless ($rt->host =~ /\w*\.?$trh/ and $rt->port == $tr->port); | ||||||||||||||||||||||||||||||||||||||||||||||
| 575 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 576 | else { # no wildcard | ||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 4 | ▶ | return 0, "return_to URL invalid against trust_root: host" | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 578 | unless $tr->host_port eq $rt->host_port; | ||||||||||||||||||||||||||||||||||||||||||||||
| 579 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||||||||||||||||||||
| 581 | # Check the path and query | ||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 4 | my $trp = $tr->path_query; | |||||||||||||||||||||||||||||||||||||||||||||
| 583 | 4 | ▶ | return 0, "return_to URL invalid against trust_root: path" | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 584 | unless $rt->path_query =~ /^$trp/; | ||||||||||||||||||||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||||||||||||||||||||
| 586 | # success | ||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 4 | return 1, "return_to URL valid against trust_root"; | |||||||||||||||||||||||||||||||||||||||||||||
| 588 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||||||||||||||||||||
| 590 | =head3 Accessor Methods | ||||||||||||||||||||||||||||||||||||||||||||||
| 591 | |||||||||||||||||||||||||||||||||||||||||||||||
| 592 | =over | ||||||||||||||||||||||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||||||||||||||||||||
| 594 | =item C<trust_root> | ||||||||||||||||||||||||||||||||||||||||||||||
| 595 | |||||||||||||||||||||||||||||||||||||||||||||||
| 596 | =item C<identity> | ||||||||||||||||||||||||||||||||||||||||||||||
| 597 | |||||||||||||||||||||||||||||||||||||||||||||||
| 598 | =item C<return_to> | ||||||||||||||||||||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||||||||||||||||||||
| 600 | =item C<immediate> | ||||||||||||||||||||||||||||||||||||||||||||||
| 601 | |||||||||||||||||||||||||||||||||||||||||||||||
| 602 | =item C<assoc_handle> | ||||||||||||||||||||||||||||||||||||||||||||||
| 603 | |||||||||||||||||||||||||||||||||||||||||||||||
| 604 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 605 | |||||||||||||||||||||||||||||||||||||||||||||||
| 606 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 607 | |||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 3 | ▶ | sub trust_root { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
trust_root: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 609 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 610 | 3 | return $self->{trust_root}; | |||||||||||||||||||||||||||||||||||||||||||||
| 611 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 612 | |||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 4 | ▶ | sub return_to { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
return_to: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 4 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 615 | 4 | return $self->{return_to}; | |||||||||||||||||||||||||||||||||||||||||||||
| 616 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 617 | |||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 2 | ▶ | sub identity { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
identity: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 620 | 2 | return $self->{identity}; | |||||||||||||||||||||||||||||||||||||||||||||
| 621 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 622 | |||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 3 | ▶ | sub immediate { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
immediate: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 625 | 3 | return $self->{immediate}; | |||||||||||||||||||||||||||||||||||||||||||||
| 626 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 627 | |||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 1 | ▶ | sub assoc_handle { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
assoc_handle: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 630 | 1 | return $self->{assoc_handle}; | |||||||||||||||||||||||||||||||||||||||||||||
| 631 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 632 | |||||||||||||||||||||||||||||||||||||||||||||||
| 633 | package Net::OpenID::JanRain::Server::Response; | ||||||||||||||||||||||||||||||||||||||||||||||
| 634 | |||||||||||||||||||||||||||||||||||||||||||||||
| 635 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 1 | ▶ | use Net::OpenID::JanRain::Util qw( hashToKV ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 639 | |||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 1 | ▶ | use constant { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 1 | OPENID_PREFIX => 'openid.', | |||||||||||||||||||||||||||||||||||||||||||||
| 642 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||||||
| 643 | |||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 1 | ▶ | use Net::OpenID::JanRain::Util qw( appendArgs ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 645 | |||||||||||||||||||||||||||||||||||||||||||||||
| 646 | =head1 Net::OpenID::JanRain::Server::Response | ||||||||||||||||||||||||||||||||||||||||||||||
| 647 | |||||||||||||||||||||||||||||||||||||||||||||||
| 648 | This object is returned by the C<answer> methods of | ||||||||||||||||||||||||||||||||||||||||||||||
| 649 | L</Net::OpenID::JanRain::Server::Request> objects. | ||||||||||||||||||||||||||||||||||||||||||||||
| 650 | |||||||||||||||||||||||||||||||||||||||||||||||
| 651 | =head2 Methods | ||||||||||||||||||||||||||||||||||||||||||||||
| 652 | |||||||||||||||||||||||||||||||||||||||||||||||
| 653 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 654 | |||||||||||||||||||||||||||||||||||||||||||||||
| 655 | 8 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.4
| |||||||||||||||||||||||||||||||||||||||||||||||
| 656 | 8 | my ($caller, $request) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 657 | |||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 8 | ▶ | my $class = ref($caller) || $caller; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $caller || $caller
MC/DC0%0/2
ref $caller || $caller
ref $caller
$caller
Truth table33%1/3
A || B
A= ref $callerB= $caller
| |||||||||||||||||||||||||||||||||||||||||||||||
| 659 | |||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 8 | my $self = { | |||||||||||||||||||||||||||||||||||||||||||||
| 661 | request => $request, | ||||||||||||||||||||||||||||||||||||||||||||||
| 662 | fields => {}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 663 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 664 | |||||||||||||||||||||||||||||||||||||||||||||||
| 665 | 8 | bless($self, $class); | |||||||||||||||||||||||||||||||||||||||||||||
| 666 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 667 | |||||||||||||||||||||||||||||||||||||||||||||||
| 668 | =head3 whichEncoding | ||||||||||||||||||||||||||||||||||||||||||||||
| 669 | |||||||||||||||||||||||||||||||||||||||||||||||
| 670 | Returns 'url' if the response should be returned in a redirect URL, | ||||||||||||||||||||||||||||||||||||||||||||||
| 671 | and 'kvform' if the response should be returned as a plaintext KV form | ||||||||||||||||||||||||||||||||||||||||||||||
| 672 | response. | ||||||||||||||||||||||||||||||||||||||||||||||
| 673 | |||||||||||||||||||||||||||||||||||||||||||||||
| 674 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 675 | |||||||||||||||||||||||||||||||||||||||||||||||
| 676 | 6 | ▶ | sub whichEncoding { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
whichEncoding: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 6 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 678 | 6 | ▶ | if($self->request->mode eq 'checkid_immediate' or $self->request->mode eq 'checkid_setup') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->request->mode eq "checkid_immediate" or $self->request->mode eq "checkid_setup"
MC/DC50%1/2
$self->request->mode eq "checkid_immediate" or $self->request->mode eq "checkid_setup"
$self->request->mode eq "checkid_immediate"
$self->request->mode eq "checkid_setup"
Truth table66%2/3
A or B
A= $self->request->mode eq "checkid_immediate"B= $self->request->mode eq "checkid_setup"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 679 | 4 | return 'url'; | |||||||||||||||||||||||||||||||||||||||||||||
| 680 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 681 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 2 | return 'kvform'; | |||||||||||||||||||||||||||||||||||||||||||||
| 683 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 684 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 685 | |||||||||||||||||||||||||||||||||||||||||||||||
| 686 | =head3 signed | ||||||||||||||||||||||||||||||||||||||||||||||
| 687 | |||||||||||||||||||||||||||||||||||||||||||||||
| 688 | Returns a boolean value indicating whether the response should be signed. | ||||||||||||||||||||||||||||||||||||||||||||||
| 689 | |||||||||||||||||||||||||||||||||||||||||||||||
| 690 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 691 | |||||||||||||||||||||||||||||||||||||||||||||||
| 692 | 5 | ▶ | sub signed { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
signed: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 693 | 5 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 694 | |||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 5 | return $self->{signed}; | |||||||||||||||||||||||||||||||||||||||||||||
| 696 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 697 | |||||||||||||||||||||||||||||||||||||||||||||||
| 698 | =head3 encodeToURL | ||||||||||||||||||||||||||||||||||||||||||||||
| 699 | |||||||||||||||||||||||||||||||||||||||||||||||
| 700 | Returns a URL for redirecting the user to send the response. | ||||||||||||||||||||||||||||||||||||||||||||||
| 701 | |||||||||||||||||||||||||||||||||||||||||||||||
| 702 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 703 | |||||||||||||||||||||||||||||||||||||||||||||||
| 704 | 2 | ▶ | sub encodeToURL { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
encodeToURL: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 705 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 706 | 2 | my $fields = {}; | |||||||||||||||||||||||||||||||||||||||||||||
| 707 | 2 | ▶ | while (my ($key, $value) = each %{$self->{fields}}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 708 | 7 | my $gnocchi = OPENID_PREFIX.$key; | |||||||||||||||||||||||||||||||||||||||||||||
| 709 | 7 | $fields->{$gnocchi} = $value; | |||||||||||||||||||||||||||||||||||||||||||||
| 710 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 711 | 2 | return appendArgs($self->request->return_to, $fields); | |||||||||||||||||||||||||||||||||||||||||||||
| 712 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 713 | |||||||||||||||||||||||||||||||||||||||||||||||
| 714 | =head3 encodeToKVForm | ||||||||||||||||||||||||||||||||||||||||||||||
| 715 | |||||||||||||||||||||||||||||||||||||||||||||||
| 716 | Returns a KV form string to put in the body of the HTTP response. | ||||||||||||||||||||||||||||||||||||||||||||||
| 717 | |||||||||||||||||||||||||||||||||||||||||||||||
| 718 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 719 | |||||||||||||||||||||||||||||||||||||||||||||||
| 720 | 1 | ▶ | sub encodeToKVForm { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
encodeToKVForm: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 721 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 722 | 1 | return hashToKV($self->fields); | |||||||||||||||||||||||||||||||||||||||||||||
| 723 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 724 | |||||||||||||||||||||||||||||||||||||||||||||||
| 725 | =head3 addField | ||||||||||||||||||||||||||||||||||||||||||||||
| 726 | |||||||||||||||||||||||||||||||||||||||||||||||
| 727 | $response->addField($namespace, $key, $value, $signed); | ||||||||||||||||||||||||||||||||||||||||||||||
| 728 | |||||||||||||||||||||||||||||||||||||||||||||||
| 729 | Adds an OpenID field to the response, possibly in an extension namespace. | ||||||||||||||||||||||||||||||||||||||||||||||
| 730 | |||||||||||||||||||||||||||||||||||||||||||||||
| 731 | =head4 Arguments | ||||||||||||||||||||||||||||||||||||||||||||||
| 732 | |||||||||||||||||||||||||||||||||||||||||||||||
| 733 | =over | ||||||||||||||||||||||||||||||||||||||||||||||
| 734 | |||||||||||||||||||||||||||||||||||||||||||||||
| 735 | =item namespace | ||||||||||||||||||||||||||||||||||||||||||||||
| 736 | |||||||||||||||||||||||||||||||||||||||||||||||
| 737 | The namespace to put the field in. '' or undef will put the field in the | ||||||||||||||||||||||||||||||||||||||||||||||
| 738 | root openid namespace. | ||||||||||||||||||||||||||||||||||||||||||||||
| 739 | |||||||||||||||||||||||||||||||||||||||||||||||
| 740 | =item key | ||||||||||||||||||||||||||||||||||||||||||||||
| 741 | |||||||||||||||||||||||||||||||||||||||||||||||
| 742 | =item value | ||||||||||||||||||||||||||||||||||||||||||||||
| 743 | |||||||||||||||||||||||||||||||||||||||||||||||
| 744 | =item signed | ||||||||||||||||||||||||||||||||||||||||||||||
| 745 | |||||||||||||||||||||||||||||||||||||||||||||||
| 746 | Whether this field should be signed. Defaults to true if the response | ||||||||||||||||||||||||||||||||||||||||||||||
| 747 | is to a C<checkid_setup> or C<checkid_immediate> request, and false | ||||||||||||||||||||||||||||||||||||||||||||||
| 748 | otherwise. | ||||||||||||||||||||||||||||||||||||||||||||||
| 749 | |||||||||||||||||||||||||||||||||||||||||||||||
| 750 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 751 | |||||||||||||||||||||||||||||||||||||||||||||||
| 752 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 753 | |||||||||||||||||||||||||||||||||||||||||||||||
| 754 | 15 | ▶ | sub addField { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
addField: called CC=6 SCAR=18.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 755 | 15 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 756 | 15 | my $namespace = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 757 | 15 | my $key = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 758 | 15 | my $value = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 759 | 15 | my $signed = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 760 | 15 | ▶ | $signed = ($self->request->mode eq 'checkid_setup' or $self->request->mode eq 'checkid_immediate') unless defined($signed); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->request->mode eq 'checkid_setup' || $self->request->mode eq 'checkid_immediate'
MC/DC0%0/2
$self->request->mode eq 'checkid_setup' || $self->request->mode eq 'checkid_immediate'
$self->request->mode eq 'checkid_setup'
$self->request->mode eq 'checkid_immediate'
Truth table33%1/3
A || B
A= $self->request->mode eq 'checkid_setup'B= $self->request->mode eq 'checkid_immediate'
| |||||||||||||||||||||||||||||||||||||||||||||||
| 761 | |||||||||||||||||||||||||||||||||||||||||||||||
| 762 | 15 | ▶ | $key = "$namespace.".$key if $namespace; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 763 | 15 | $self->{fields}->{$key} = $value; | |||||||||||||||||||||||||||||||||||||||||||||
| 764 | |||||||||||||||||||||||||||||||||||||||||||||||
| 765 | |||||||||||||||||||||||||||||||||||||||||||||||
| 766 | 15 | ▶ | if($signed) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 767 | 3 | ▶ | $self->{signed} = [] unless defined($self->{signed}); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 768 | 3 | push @{$self->{signed}}, $key; | |||||||||||||||||||||||||||||||||||||||||||||
| 769 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 770 | |||||||||||||||||||||||||||||||||||||||||||||||
| 771 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 772 | |||||||||||||||||||||||||||||||||||||||||||||||
| 773 | =head3 addFields | ||||||||||||||||||||||||||||||||||||||||||||||
| 774 | |||||||||||||||||||||||||||||||||||||||||||||||
| 775 | $response->addFields($namespace, \%fields, $signed); | ||||||||||||||||||||||||||||||||||||||||||||||
| 776 | |||||||||||||||||||||||||||||||||||||||||||||||
| 777 | Much like C<addField>, but takes a hash reference containing a number | ||||||||||||||||||||||||||||||||||||||||||||||
| 778 | key/value pairs. | ||||||||||||||||||||||||||||||||||||||||||||||
| 779 | |||||||||||||||||||||||||||||||||||||||||||||||
| 780 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 781 | |||||||||||||||||||||||||||||||||||||||||||||||
| 782 | 11 | ▶ | sub addFields { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
addFields: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 783 | 11 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 784 | 11 | my $namespace = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 785 | 11 | my $fields = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 786 | 11 | my $signed = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 787 | |||||||||||||||||||||||||||||||||||||||||||||||
| 788 | 11 | ▶ | while (my ($key, $value) = each %$fields) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 789 | 15 | $self->addField($namespace, $key, $value, $signed); | |||||||||||||||||||||||||||||||||||||||||||||
| 790 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 791 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 792 | |||||||||||||||||||||||||||||||||||||||||||||||
| 793 | =head3 fields | ||||||||||||||||||||||||||||||||||||||||||||||
| 794 | |||||||||||||||||||||||||||||||||||||||||||||||
| 795 | An accessor method for the fields hash ref. | ||||||||||||||||||||||||||||||||||||||||||||||
| 796 | |||||||||||||||||||||||||||||||||||||||||||||||
| 797 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 798 | |||||||||||||||||||||||||||||||||||||||||||||||
| 799 | 13 | ▶ | sub fields { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fields: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 800 | 13 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 801 | 13 | return $self->{fields}; | |||||||||||||||||||||||||||||||||||||||||||||
| 802 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 803 | |||||||||||||||||||||||||||||||||||||||||||||||
| 804 | =head3 request | ||||||||||||||||||||||||||||||||||||||||||||||
| 805 | |||||||||||||||||||||||||||||||||||||||||||||||
| 806 | Returns the request this response is responding to. | ||||||||||||||||||||||||||||||||||||||||||||||
| 807 | |||||||||||||||||||||||||||||||||||||||||||||||
| 808 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 809 | |||||||||||||||||||||||||||||||||||||||||||||||
| 810 | 35 | ▶ | sub request { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
request: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 811 | 35 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 812 | 35 | return $self->{request}; | |||||||||||||||||||||||||||||||||||||||||||||
| 813 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 814 | |||||||||||||||||||||||||||||||||||||||||||||||
| 815 | |||||||||||||||||||||||||||||||||||||||||||||||
| 816 | package Net::OpenID::JanRain::Server::WebResponse; | ||||||||||||||||||||||||||||||||||||||||||||||
| 817 | |||||||||||||||||||||||||||||||||||||||||||||||
| 818 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 819 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 820 | |||||||||||||||||||||||||||||||||||||||||||||||
| 821 | =head1 Net::OpenID::JanRain::Server::WebResponse | ||||||||||||||||||||||||||||||||||||||||||||||
| 822 | |||||||||||||||||||||||||||||||||||||||||||||||
| 823 | This object is meant to be easily encoded into an HTTP response in your | ||||||||||||||||||||||||||||||||||||||||||||||
| 824 | application. | ||||||||||||||||||||||||||||||||||||||||||||||
| 825 | |||||||||||||||||||||||||||||||||||||||||||||||
| 826 | =head2 Accessor Methods | ||||||||||||||||||||||||||||||||||||||||||||||
| 827 | |||||||||||||||||||||||||||||||||||||||||||||||
| 828 | =over | ||||||||||||||||||||||||||||||||||||||||||||||
| 829 | |||||||||||||||||||||||||||||||||||||||||||||||
| 830 | =item code | ||||||||||||||||||||||||||||||||||||||||||||||
| 831 | |||||||||||||||||||||||||||||||||||||||||||||||
| 832 | The HTTP code to use on your response. | ||||||||||||||||||||||||||||||||||||||||||||||
| 833 | |||||||||||||||||||||||||||||||||||||||||||||||
| 834 | =item headers | ||||||||||||||||||||||||||||||||||||||||||||||
| 835 | |||||||||||||||||||||||||||||||||||||||||||||||
| 836 | A hash reference of headers to put on your response. | ||||||||||||||||||||||||||||||||||||||||||||||
| 837 | |||||||||||||||||||||||||||||||||||||||||||||||
| 838 | =item body | ||||||||||||||||||||||||||||||||||||||||||||||
| 839 | |||||||||||||||||||||||||||||||||||||||||||||||
| 840 | The body of the response. | ||||||||||||||||||||||||||||||||||||||||||||||
| 841 | |||||||||||||||||||||||||||||||||||||||||||||||
| 842 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 843 | |||||||||||||||||||||||||||||||||||||||||||||||
| 844 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 845 | |||||||||||||||||||||||||||||||||||||||||||||||
| 846 | 3 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.4
| |||||||||||||||||||||||||||||||||||||||||||||||
| 847 | 3 | my ($caller, $code, $headers, $body) = @_; #XXX optionals | |||||||||||||||||||||||||||||||||||||||||||||
| 848 | |||||||||||||||||||||||||||||||||||||||||||||||
| 849 | 3 | ▶ | my $class = ref($caller) || $caller; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $caller || $caller
MC/DC0%0/2
ref $caller || $caller
ref $caller
$caller
Truth table33%1/3
A || B
A= ref $callerB= $caller
| |||||||||||||||||||||||||||||||||||||||||||||||
| 850 | |||||||||||||||||||||||||||||||||||||||||||||||
| 851 | 3 | my $self = { | |||||||||||||||||||||||||||||||||||||||||||||
| 852 | code => $code, | ||||||||||||||||||||||||||||||||||||||||||||||
| 853 | headers => $headers, | ||||||||||||||||||||||||||||||||||||||||||||||
| 854 | body => $body, | ||||||||||||||||||||||||||||||||||||||||||||||
| 855 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 856 | |||||||||||||||||||||||||||||||||||||||||||||||
| 857 | 3 | bless($self,$class); | |||||||||||||||||||||||||||||||||||||||||||||
| 858 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 859 | |||||||||||||||||||||||||||||||||||||||||||||||
| 860 | 2 | ▶ | sub code { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
code: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 861 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 862 | 2 | return $self->{code}; | |||||||||||||||||||||||||||||||||||||||||||||
| 863 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 864 | |||||||||||||||||||||||||||||||||||||||||||||||
| 865 | 1 | ▶ | sub headers { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
headers: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 866 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 867 | 1 | return $self->{headers}; | |||||||||||||||||||||||||||||||||||||||||||||
| 868 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 869 | |||||||||||||||||||||||||||||||||||||||||||||||
| 870 | 2 | ▶ | sub body { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
body: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 871 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 872 | 2 | return $self->{body}; | |||||||||||||||||||||||||||||||||||||||||||||
| 873 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 874 | |||||||||||||||||||||||||||||||||||||||||||||||
| 875 | package Net::OpenID::JanRain::Server::ProtocolError; | ||||||||||||||||||||||||||||||||||||||||||||||
| 876 | |||||||||||||||||||||||||||||||||||||||||||||||
| 877 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 878 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 879 | 1 | ▶ | use constant { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 880 | 1 | OPENID_PREFIX => 'openid.', | |||||||||||||||||||||||||||||||||||||||||||||
| 881 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||||||
| 882 | |||||||||||||||||||||||||||||||||||||||||||||||
| 883 | 1 | ▶ | use Net::OpenID::JanRain::Util qw( appendArgs hashToKV ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 884 | |||||||||||||||||||||||||||||||||||||||||||||||
| 885 | =head1 Net::OpenID::JanRain::Server::ProtocolError | ||||||||||||||||||||||||||||||||||||||||||||||
| 886 | |||||||||||||||||||||||||||||||||||||||||||||||
| 887 | Objects of this class are returned by XXX when the consumer sends us an | ||||||||||||||||||||||||||||||||||||||||||||||
| 888 | improper request. It may be encoded to a web response in the same manner | ||||||||||||||||||||||||||||||||||||||||||||||
| 889 | that a L</Net::OpenID::JanRain::Server::Response> object is encoded. | ||||||||||||||||||||||||||||||||||||||||||||||
| 890 | |||||||||||||||||||||||||||||||||||||||||||||||
| 891 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 892 | |||||||||||||||||||||||||||||||||||||||||||||||
| 893 | 13 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=11.7
| |||||||||||||||||||||||||||||||||||||||||||||||
| 894 | 13 | my $caller = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 895 | 13 | my $query = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 896 | 13 | my $text = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 897 | 13 | ▶ | my $class = ref($caller) || $caller; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $caller || $caller
MC/DC0%0/2
ref $caller || $caller
ref $caller
$caller
Truth table33%1/3
A || B
A= ref $callerB= $caller
| |||||||||||||||||||||||||||||||||||||||||||||||
| 898 | |||||||||||||||||||||||||||||||||||||||||||||||
| 899 | 13 | my $self = {query => $query}; | |||||||||||||||||||||||||||||||||||||||||||||
| 900 | 13 | ▶ | if ($text) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 901 | 13 | $self->{text} = $text; | |||||||||||||||||||||||||||||||||||||||||||||
| 902 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 903 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 904 | 0 | warn "Error without text"; | |||||||||||||||||||||||||||||||||||||||||||||
| 905 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 906 | |||||||||||||||||||||||||||||||||||||||||||||||
| 907 | 13 | bless($self, $class); | |||||||||||||||||||||||||||||||||||||||||||||
| 908 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 909 | |||||||||||||||||||||||||||||||||||||||||||||||
| 910 | =head3 text | ||||||||||||||||||||||||||||||||||||||||||||||
| 911 | |||||||||||||||||||||||||||||||||||||||||||||||
| 912 | Returns a string describing the error. | ||||||||||||||||||||||||||||||||||||||||||||||
| 913 | |||||||||||||||||||||||||||||||||||||||||||||||
| 914 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 915 | |||||||||||||||||||||||||||||||||||||||||||||||
| 916 | 5 | ▶ | sub text { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
text: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 917 | 5 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 918 | 5 | return $self->{text}; | |||||||||||||||||||||||||||||||||||||||||||||
| 919 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 920 | |||||||||||||||||||||||||||||||||||||||||||||||
| 921 | =head3 query | ||||||||||||||||||||||||||||||||||||||||||||||
| 922 | |||||||||||||||||||||||||||||||||||||||||||||||
| 923 | returns the query that led to the error. | ||||||||||||||||||||||||||||||||||||||||||||||
| 924 | |||||||||||||||||||||||||||||||||||||||||||||||
| 925 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 926 | |||||||||||||||||||||||||||||||||||||||||||||||
| 927 | 0 | ▶ | sub query { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
query: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 928 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 929 | 0 | return $self->{query}; | |||||||||||||||||||||||||||||||||||||||||||||
| 930 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 931 | |||||||||||||||||||||||||||||||||||||||||||||||
| 932 | =head3 hasReturnTo | ||||||||||||||||||||||||||||||||||||||||||||||
| 933 | |||||||||||||||||||||||||||||||||||||||||||||||
| 934 | Do we have a return_to URL to send the error back to the server? | ||||||||||||||||||||||||||||||||||||||||||||||
| 935 | (only relevant when the c<whichEncoding> method returns 'url') | ||||||||||||||||||||||||||||||||||||||||||||||
| 936 | |||||||||||||||||||||||||||||||||||||||||||||||
| 937 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 938 | |||||||||||||||||||||||||||||||||||||||||||||||
| 939 | 2 | ▶ | sub hasReturnTo { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
hasReturnTo: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 940 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 941 | 2 | ▶ | $self->{query} and return 1 if $self->{query}->{OPENID_PREFIX.'return_to'}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition75%3/4
$self->{'query'}{'openid.return_to'} && ($self->{'query'} && (return 1))
$self->{"query"} and return 1
MC/DC0%0/2
$self->{'query'}{'openid.return_to'} && ($self->{'query'} && (return 1))
$self->{'query'}{'openid.return_to'}
$self->{"query"}
Truth table33%1/3
A && B
A= $self->{'query'}{'openid.return_to'}B= $self->{"query"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 942 | 1 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 943 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 944 | |||||||||||||||||||||||||||||||||||||||||||||||
| 945 | =head3 encodeToURL | ||||||||||||||||||||||||||||||||||||||||||||||
| 946 | |||||||||||||||||||||||||||||||||||||||||||||||
| 947 | Generates and returns a URL for redirecting the user to alert the consumer | ||||||||||||||||||||||||||||||||||||||||||||||
| 948 | of the error. | ||||||||||||||||||||||||||||||||||||||||||||||
| 949 | |||||||||||||||||||||||||||||||||||||||||||||||
| 950 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 951 | |||||||||||||||||||||||||||||||||||||||||||||||
| 952 | 0 | ▶ | sub encodeToURL { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
encodeToURL: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 953 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 954 | 0 | my $return_to = $self->{query}->{OPENID_PREFIX.'return_to'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 955 | |||||||||||||||||||||||||||||||||||||||||||||||
| 956 | 0 | ▶ | unless ($return_to) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 957 | 0 | carp("OpenID ProtocolError has no return_to URL to encode onto"); | |||||||||||||||||||||||||||||||||||||||||||||
| 958 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 959 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 960 | |||||||||||||||||||||||||||||||||||||||||||||||
| 961 | return appendArgs($return_to, {'openid.mode' => "error", | ||||||||||||||||||||||||||||||||||||||||||||||
| 962 | 0 | 'openid.error' => $self->{text}}); | |||||||||||||||||||||||||||||||||||||||||||||
| 963 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 964 | |||||||||||||||||||||||||||||||||||||||||||||||
| 965 | =head3 encodeToKVForm | ||||||||||||||||||||||||||||||||||||||||||||||
| 966 | |||||||||||||||||||||||||||||||||||||||||||||||
| 967 | Generates and returns a KV form string for returning in the body of the | ||||||||||||||||||||||||||||||||||||||||||||||
| 968 | response to the consumer. | ||||||||||||||||||||||||||||||||||||||||||||||
| 969 | |||||||||||||||||||||||||||||||||||||||||||||||
| 970 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 971 | |||||||||||||||||||||||||||||||||||||||||||||||
| 972 | 0 | ▶ | sub encodeToKVForm { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
encodeToKVForm: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 973 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 974 | |||||||||||||||||||||||||||||||||||||||||||||||
| 975 | 0 | return hashToKV({mode=>'error', error=>$self->text}); | |||||||||||||||||||||||||||||||||||||||||||||
| 976 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 977 | |||||||||||||||||||||||||||||||||||||||||||||||
| 978 | =head3 fields | ||||||||||||||||||||||||||||||||||||||||||||||
| 979 | |||||||||||||||||||||||||||||||||||||||||||||||
| 980 | Returns a hash ref of the response fields. | ||||||||||||||||||||||||||||||||||||||||||||||
| 981 | |||||||||||||||||||||||||||||||||||||||||||||||
| 982 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 983 | |||||||||||||||||||||||||||||||||||||||||||||||
| 984 | 0 | ▶ | sub fields { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fields: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 985 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 986 | 0 | return {mode=>'error', error=>$self->text}; | |||||||||||||||||||||||||||||||||||||||||||||
| 987 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 988 | |||||||||||||||||||||||||||||||||||||||||||||||
| 989 | =head3 whichEncoding | ||||||||||||||||||||||||||||||||||||||||||||||
| 990 | |||||||||||||||||||||||||||||||||||||||||||||||
| 991 | Returns a string, either 'url', or 'kvform', based on how the error | ||||||||||||||||||||||||||||||||||||||||||||||
| 992 | should be encoded for transmission. | ||||||||||||||||||||||||||||||||||||||||||||||
| 993 | |||||||||||||||||||||||||||||||||||||||||||||||
| 994 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 995 | |||||||||||||||||||||||||||||||||||||||||||||||
| 996 | 8 | ▶ | sub whichEncoding { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
whichEncoding: called CC=5 SCAR=16.2
| |||||||||||||||||||||||||||||||||||||||||||||||
| 997 | 8 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 998 | |||||||||||||||||||||||||||||||||||||||||||||||
| 999 | 8 | ▶ | return undef unless $self->{query}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | 8 | my $mode = $self->{query}->{OPENID_PREFIX.'mode'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 1002 | 8 | my $return_to = $self->{query}->{OPENID_PREFIX.'return_to'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 1003 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | 8 | ▶ | if(($mode eq 'checkid_setup' or $mode eq 'checkid_immediate') and | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$mode eq "checkid_setup" || $mode eq "checkid_immediate" and $self->hasReturnTo
$mode eq "checkid_setup" or $mode eq "checkid_immediate"
MC/DC66%2/3
$mode eq "checkid_setup" || $mode eq "checkid_immediate" and $self->hasReturnTo
$mode eq "checkid_setup"
$mode eq "checkid_immediate"
$self->hasReturnTo
Truth table60%3/5
A or B and C
A= $mode eq "checkid_setup"B= $mode eq "checkid_immediate"C= $self->hasReturnTo
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | $self->hasReturnTo()) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | 1 | return 'url'; | |||||||||||||||||||||||||||||||||||||||||||||
| 1007 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | 7 | return 'kvform'; | |||||||||||||||||||||||||||||||||||||||||||||
| 1009 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | package Net::OpenID::JanRain::Server::Signatory; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | 1 | ▶ | use Net::OpenID::JanRain::Util qw( toBase64 ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | 1 | ▶ | use Net::OpenID::JanRain::CryptUtil qw( randomString ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | 1 | my $SECRET_LIFETIME = 14 * 24 * 60 * 60; # seconds in a fortnight | |||||||||||||||||||||||||||||||||||||||||||||
| 1022 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | # keys have a bogus server URL in them because the filestore | ||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | # really does expect that key to be a URL. This seems a little | ||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | # silly for the server store, since I expect there to be only one | ||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | # server URL. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | 1 | my $_normal_key = 'http://localhost/|normal'; | |||||||||||||||||||||||||||||||||||||||||||||
| 1028 | 1 | my $_dumb_key = 'http://localhost/|dumb'; | |||||||||||||||||||||||||||||||||||||||||||||
| 1029 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | =head1 Net::OpenID::JanRain::Server::Signatory | ||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | This object signs responses and checks signatures. One is contained | ||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | inside every C<Net::OpenID::JanRain::Server> object. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | If you use the | ||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | L</encodeResponse> method of the C<Net::OpenID::JanRain::Server> object, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | you won't have to know how this object works. All the object state is | ||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | in the OpenID store. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | 2 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=11.1
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | 2 | my ($caller, $store) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 1044 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1045 | 2 | ▶ | my $class = ref($caller) || $caller; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $caller || $caller
MC/DC0%0/2
ref $caller || $caller
ref $caller
$caller
Truth table33%1/3
A || B
A= ref $callerB= $caller
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1046 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | 2 | ▶ | unless ($store->isa('Net::OpenID::JanRain::Stores')) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | 1 | carp "Need an instance of Net::OpenID::JanRain::Stores"; | |||||||||||||||||||||||||||||||||||||||||||||
| 1049 | 1 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 1050 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1051 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1052 | 1 | my $self = {store => $store}; | |||||||||||||||||||||||||||||||||||||||||||||
| 1053 | 1 | bless($self, $class); | |||||||||||||||||||||||||||||||||||||||||||||
| 1054 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1055 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | =head3 verify | ||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | $is_valid = $signatory->verify($assoc_handle, $sig, $signed_pairs); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1062 | 5 | ▶ | sub verify { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
verify: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1063 | 5 | my ($self, $assoc_handle, $sig, $signed_pairs) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 1064 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1065 | 5 | my $assoc = $self->getAssociation($assoc_handle, 1); | |||||||||||||||||||||||||||||||||||||||||||||
| 1066 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1067 | 5 | ▶ | return 0 unless ($assoc); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1068 | 1 | my $expected_sig = toBase64($assoc->signPairs($signed_pairs)); | |||||||||||||||||||||||||||||||||||||||||||||
| 1069 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1070 | 1 | return $sig eq $expected_sig; | |||||||||||||||||||||||||||||||||||||||||||||
| 1071 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1072 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1073 | =head3 sign | ||||||||||||||||||||||||||||||||||||||||||||||
| 1074 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1075 | $signatory->sign($response); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1076 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1077 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 1078 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1079 | 1 | ▶ | sub sign { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sign: called CC=3 SCAR=13.2
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1080 | 1 | my ($self, $response) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 1081 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1082 | 1 | my $assoc_handle = $response->request->assoc_handle; | |||||||||||||||||||||||||||||||||||||||||||||
| 1083 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1084 | 1 | my $assoc; | |||||||||||||||||||||||||||||||||||||||||||||
| 1085 | 1 | ▶ | if ($assoc_handle) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1086 | 0 | $assoc = $self->getAssociation($assoc_handle, 0); | |||||||||||||||||||||||||||||||||||||||||||||
| 1087 | 0 | ▶ | unless ($assoc) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1088 | # We don't have that association. Send the invalidate handle | ||||||||||||||||||||||||||||||||||||||||||||||
| 1089 | # message back, and fall back on dumb mode. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1090 | 0 | $response->addFields('',{invalidate_handle => $assoc_handle}); | |||||||||||||||||||||||||||||||||||||||||||||
| 1091 | 0 | $assoc = $self->createAssociation(1); | |||||||||||||||||||||||||||||||||||||||||||||
| 1092 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1093 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1094 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1095 | 1 | $assoc = $self->createAssociation(1); | |||||||||||||||||||||||||||||||||||||||||||||
| 1096 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1097 | 1 | $response->addFields('', {assoc_handle => $assoc->handle}, 0); | |||||||||||||||||||||||||||||||||||||||||||||
| 1098 | 1 | $assoc->addSignature($response->{fields}, $response->signed); | |||||||||||||||||||||||||||||||||||||||||||||
| 1099 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1100 | 1 | return $response; | |||||||||||||||||||||||||||||||||||||||||||||
| 1101 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1102 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1103 | =head3 createAssociation | ||||||||||||||||||||||||||||||||||||||||||||||
| 1104 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1105 | $assoc = $signatory->createAssociation($dumbp); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1106 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1107 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 1108 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1109 | 7 | ▶ | sub createAssociation { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
createAssociation: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1110 | 7 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 1111 | 7 | my $dumb = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 1112 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1113 | 7 | my $assoc_type = 'HMAC-SHA1'; | |||||||||||||||||||||||||||||||||||||||||||||
| 1114 | 7 | my $secret = randomString(20); | |||||||||||||||||||||||||||||||||||||||||||||
| 1115 | 7 | my $uniq = toBase64(randomString(4)); | |||||||||||||||||||||||||||||||||||||||||||||
| 1116 | 7 | my $now = time; | |||||||||||||||||||||||||||||||||||||||||||||
| 1117 | 7 | my $handle = "_${assoc_type}_${now}_${uniq}_"; | |||||||||||||||||||||||||||||||||||||||||||||
| 1118 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1119 | 7 | ▶ | $handle = "_d$handle" if $dumb; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1120 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1121 | 7 | my $assoc = Net::OpenID::JanRain::Association->fromExpiresIn( | |||||||||||||||||||||||||||||||||||||||||||||
| 1122 | $SECRET_LIFETIME, $handle, $secret, $assoc_type); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1123 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1124 | 7 | ▶ | if ($dumb) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1125 | 4 | $self->{store}->storeAssociation($_dumb_key, $assoc); | |||||||||||||||||||||||||||||||||||||||||||||
| 1126 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1127 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1128 | 3 | $self->{store}->storeAssociation($_normal_key, $assoc); | |||||||||||||||||||||||||||||||||||||||||||||
| 1129 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1130 | 7 | return $assoc; | |||||||||||||||||||||||||||||||||||||||||||||
| 1131 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1132 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1133 | =head3 getAssociation | ||||||||||||||||||||||||||||||||||||||||||||||
| 1134 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1135 | $assoc = $signatory->getAssociation($assoc_handle, $dumb); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1136 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1137 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 1138 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1139 | 12 | ▶ | sub getAssociation { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getAssociation: called CC=5 SCAR=17.4
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1140 | 12 | my ($self, $assoc_handle, $dumb) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 1141 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1142 | 12 | ▶ | unless (defined($assoc_handle)) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1143 | 0 | carp("assoc_handle must be defined"); | |||||||||||||||||||||||||||||||||||||||||||||
| 1144 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 1145 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1146 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1147 | 12 | my $key; | |||||||||||||||||||||||||||||||||||||||||||||
| 1148 | 12 | ▶ | if ($dumb) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1149 | 8 | $key = $_dumb_key; | |||||||||||||||||||||||||||||||||||||||||||||
| 1150 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1151 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1152 | 4 | $key = $_normal_key; | |||||||||||||||||||||||||||||||||||||||||||||
| 1153 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1154 | 12 | my $store = $self->{store}; | |||||||||||||||||||||||||||||||||||||||||||||
| 1155 | 12 | my $assoc = $store->getAssociation($key, $assoc_handle); | |||||||||||||||||||||||||||||||||||||||||||||
| 1156 | 12 | ▶ | if (defined($assoc) and $assoc->expiresIn == 0) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $assoc and $assoc->expiresIn == 0
MC/DC0%0/2
defined $assoc and $assoc->expiresIn == 0
defined $assoc
$assoc->expiresIn == 0
Truth table66%2/3
A and B
A= defined $assocB= $assoc->expiresIn == 0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1157 | # oid_log("requested association $assoc_handle is expired"); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1158 | 0 | $store->removeAssociation($key, $assoc_handle); | |||||||||||||||||||||||||||||||||||||||||||||
| 1159 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 1160 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1161 | 12 | return $assoc; | |||||||||||||||||||||||||||||||||||||||||||||
| 1162 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1163 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1164 | =head3 invalidate | ||||||||||||||||||||||||||||||||||||||||||||||
| 1165 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1166 | $signatory->invalidate($assoc_handle, $dumb); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1167 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1168 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 1169 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1170 | 5 | ▶ | sub invalidate { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
invalidate: called CC=2 SCAR=7.6
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1171 | 5 | my ($self, $assoc_handle, $dumb) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 1172 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1173 | 5 | ▶ | if ($dumb) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1174 | 5 | $self->{store}->removeAssociation($_dumb_key, $assoc_handle); | |||||||||||||||||||||||||||||||||||||||||||||
| 1175 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1176 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1177 | 0 | $self->{store}->removeAssociation($_normal_key, $assoc_handle); | |||||||||||||||||||||||||||||||||||||||||||||
| 1178 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1179 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1180 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1181 | package Net::OpenID::JanRain::Server; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1182 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1183 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1184 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1185 | 1 | ▶ | use Net::OpenID::JanRain::Util qw( appendArgs hashToKV ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1186 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1187 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1188 | 1 | ▶ | use constant { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1189 | 1 | OPENID_PREFIX => 'openid.', | |||||||||||||||||||||||||||||||||||||||||||||
| 1190 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||||||
| 1191 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1192 | 1 | my $signatoryClass='Net::OpenID::JanRain::Server::Signatory'; | |||||||||||||||||||||||||||||||||||||||||||||
| 1193 | 1 | my $webResponseClass='Net::OpenID::JanRain::Server::WebResponse'; | |||||||||||||||||||||||||||||||||||||||||||||
| 1194 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1195 | =head1 Net::OpenID::JanRain::Server | ||||||||||||||||||||||||||||||||||||||||||||||
| 1196 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1197 | This object handles requests for an OpenID server. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1198 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1199 | Queries in hash-ref form may be turned into | ||||||||||||||||||||||||||||||||||||||||||||||
| 1200 | L</Net::OpenID::JanRain::Server::Request> objects with the | ||||||||||||||||||||||||||||||||||||||||||||||
| 1201 | L</decodeRequest> method. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1202 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1203 | Requests which are not C<checkid> requests may be passed to the | ||||||||||||||||||||||||||||||||||||||||||||||
| 1204 | L<handleRequest> method, and a response will be returned. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1205 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1206 | L</Net::OpenID::JanRain::Server::Response> objects may be transformed | ||||||||||||||||||||||||||||||||||||||||||||||
| 1207 | into L</Net::OpenID::JanRain::Server::WebResponse> objects with the | ||||||||||||||||||||||||||||||||||||||||||||||
| 1208 | L<endodeResponse> method, which will also sign the responses if necessary. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1209 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1210 | =head2 Methods | ||||||||||||||||||||||||||||||||||||||||||||||
| 1211 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1212 | =head3 new | ||||||||||||||||||||||||||||||||||||||||||||||
| 1213 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1214 | $server = new Net::OpenID::JanRain::Server($store); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1215 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1216 | Instantiate this object with an instance of C<Net::OpenID::JanRain::Stores>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1217 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1218 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 1219 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1220 | 2 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=11.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1221 | 2 | my ($caller, $store) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 1222 | 2 | ▶ | my $class = ref($caller) || $caller; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $caller || $caller
MC/DC0%0/2
ref $caller || $caller
ref $caller
$caller
Truth table33%1/3
A || B
A= ref $callerB= $caller
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1223 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1224 | 2 | my $signatory = $signatoryClass->new($store); | |||||||||||||||||||||||||||||||||||||||||||||
| 1225 | 2 | ▶ | unless (defined($signatory)) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1226 | 1 | carp "Failed to instantiate signatory"; | |||||||||||||||||||||||||||||||||||||||||||||
| 1227 | 1 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 1228 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1229 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1230 | 1 | my $self = { | |||||||||||||||||||||||||||||||||||||||||||||
| 1231 | ### store => $store, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1232 | signatory => $signatory | ||||||||||||||||||||||||||||||||||||||||||||||
| 1233 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1234 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1235 | 1 | bless($self, $class); | |||||||||||||||||||||||||||||||||||||||||||||
| 1236 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1237 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1238 | =head3 handleRequest | ||||||||||||||||||||||||||||||||||||||||||||||
| 1239 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1240 | Call this method on a L</Net::OpenID::JanRain::Server::Request> object | ||||||||||||||||||||||||||||||||||||||||||||||
| 1241 | that is not a L</Net::OpenID::JanRain::Server::CheckIDRequest> and | ||||||||||||||||||||||||||||||||||||||||||||||
| 1242 | the appropriate L</Net::OpenID::JanRain::Server::Response> object will | ||||||||||||||||||||||||||||||||||||||||||||||
| 1243 | be returned. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1244 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1245 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 1246 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1247 | 2 | ▶ | sub handleRequest { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handleRequest: called CC=3 SCAR=15.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1248 | 2 | my ($self, $request) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 1249 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1250 | 2 | my $mode = $request->mode; | |||||||||||||||||||||||||||||||||||||||||||||
| 1251 | 2 | ▶ | if ($mode eq 'check_authentication') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1252 | 2 | return $self->openid_check_authentication($request); | |||||||||||||||||||||||||||||||||||||||||||||
| 1253 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1254 | elsif ($mode eq 'associate') { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1255 | 0 | return $self->openid_associate($request); | |||||||||||||||||||||||||||||||||||||||||||||
| 1256 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1257 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1258 | 0 | warn "No handler for mode $mode"; | |||||||||||||||||||||||||||||||||||||||||||||
| 1259 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 1260 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1261 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1262 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1263 | =head3 signatory | ||||||||||||||||||||||||||||||||||||||||||||||
| 1264 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1265 | An accessor method to get the signatory object used by the server. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1266 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1267 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 1268 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1269 | 9 | ▶ | sub signatory { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
signatory: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1270 | 9 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 1271 | 9 | return $self->{signatory}; | |||||||||||||||||||||||||||||||||||||||||||||
| 1272 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1273 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1274 | 2 | ▶ | sub openid_check_authentication { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
openid_check_authentication: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1275 | 2 | my ($self, $request) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 1276 | 2 | return $request->answer($self->{signatory}); | |||||||||||||||||||||||||||||||||||||||||||||
| 1277 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1278 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1279 | 0 | ▶ | sub openid_associate { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
openid_associate: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1280 | 0 | my ($self, $request) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 1281 | 0 | my $signatory = $self->{signatory}; | |||||||||||||||||||||||||||||||||||||||||||||
| 1282 | 0 | my $assoc = $signatory->createAssociation(0); | |||||||||||||||||||||||||||||||||||||||||||||
| 1283 | 0 | return $request->answer($assoc); | |||||||||||||||||||||||||||||||||||||||||||||
| 1284 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1285 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1286 | =head3 decodeRequest | ||||||||||||||||||||||||||||||||||||||||||||||
| 1287 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1288 | $response = $server->decodeRequest(\%query); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1289 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1290 | This method takes a hash ref of an OpenID query and returns an | ||||||||||||||||||||||||||||||||||||||||||||||
| 1291 | L</Net::OpenID::JanRain::Server::Request> object. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1292 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1293 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 1294 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1295 | 24 | ▶ | sub decodeRequest { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
decodeRequest: called CC=10 SCAR=23.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1296 | 24 | my ($self, $query) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 1297 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1298 | 24 | ▶ | return undef unless %$query; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1299 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1300 | 23 | my $oidp = 'openid.'; | |||||||||||||||||||||||||||||||||||||||||||||
| 1301 | 23 | $oidp =~ s/\./\\./; # escape the dang . | |||||||||||||||||||||||||||||||||||||||||||||
| 1302 | 23 | my $myquery = {}; | |||||||||||||||||||||||||||||||||||||||||||||
| 1303 | 23 | ▶ | while(my ($k, $v) = each %$query) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1304 | 69 | ▶ | $myquery->{$k} = $v if $k =~ /^$oidp/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1305 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1306 | 23 | ▶ | return undef unless %$myquery; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1307 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1308 | 22 | my $mode = $myquery->{OPENID_PREFIX.'mode'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 1309 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1310 | 22 | ▶ | return $errorClass->new($query, "Query is missing mode") unless $mode; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1311 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1312 | 21 | ▶ | if($mode eq 'checkid_setup' or $mode eq 'checkid_immediate') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition100%3/3
$mode eq "checkid_setup" or $mode eq "checkid_immediate"
MC/DC100%2/2
$mode eq "checkid_setup" or $mode eq "checkid_immediate"
$mode eq "checkid_setup"
$mode eq "checkid_immediate"
Truth table100%3/3
A or B
A= $mode eq "checkid_setup"B= $mode eq "checkid_immediate"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1313 | 9 | return Net::OpenID::JanRain::Server::CheckIDRequest->fromQuery($query); | |||||||||||||||||||||||||||||||||||||||||||||
| 1314 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1315 | elsif($mode eq 'check_authentication') { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1316 | 6 | return Net::OpenID::JanRain::Server::CheckAuthRequest->fromQuery($query); | |||||||||||||||||||||||||||||||||||||||||||||
| 1317 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1318 | elsif($mode eq 'associate') { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1319 | 5 | return Net::OpenID::JanRain::Server::AssociateRequest->fromQuery($query); | |||||||||||||||||||||||||||||||||||||||||||||
| 1320 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1321 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1322 | 1 | return $errorClass->new($query, "Unknown mode $mode"); | |||||||||||||||||||||||||||||||||||||||||||||
| 1323 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1324 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1325 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1326 | =head3 encodeResponse | ||||||||||||||||||||||||||||||||||||||||||||||
| 1327 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1328 | $web_response = $server->encodeResponse($response); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1329 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1330 | This method takes a L</Net::OpenID::JanRain::Server::Response> object | ||||||||||||||||||||||||||||||||||||||||||||||
| 1331 | and returns the appropriate L</Net::OpenID::JanRain::Server::WebResponse> | ||||||||||||||||||||||||||||||||||||||||||||||
| 1332 | object. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1333 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1334 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 1335 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1336 | 3 | ▶ | sub encodeResponse { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
encodeResponse: called CC=5 SCAR=16.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1337 | 3 | my ($self, $response) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 1338 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1339 | 3 | my $encode_as = $response->whichEncoding(); | |||||||||||||||||||||||||||||||||||||||||||||
| 1340 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1341 | 3 | ▶ | if ($encode_as eq 'kvform') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1342 | 1 | my $wr = $webResponseClass->new(200, {}, $response->encodeToKVForm); | |||||||||||||||||||||||||||||||||||||||||||||
| 1343 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1344 | elsif($encode_as eq 'url') { | ||||||||||||||||||||||||||||||||||||||||||||||
| 1345 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1346 | 2 | ▶ | if ($response->signed) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1347 | 1 | ▶ | unless ($response->fields->{sig}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1348 | 1 | my $signatory = $self->{signatory}; | |||||||||||||||||||||||||||||||||||||||||||||
| 1349 | 1 | $signatory->sign($response); | |||||||||||||||||||||||||||||||||||||||||||||
| 1350 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1351 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1352 | 2 | my $wr = $webResponseClass->new(302, | |||||||||||||||||||||||||||||||||||||||||||||
| 1353 | {Location => $response->encodeToURL}, undef); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1354 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1355 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1356 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1357 | |||||||||||||||||||||||||||||||||||||||||||||||