Lite/RelyingParty/CheckID/Request.pm

filter: Statementstmt 42.8% 27 / 63 Branchbran 0.0% 0 / 18 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 58.3% 7 / 12 Podpod 0.0% 0 / 4 totaltotal 35.0% 34 / 97 CC 10 SCAR 36.8
CC
10
Cov
33%
gen_params
90.0
should_send_redirect
6.0
add_extension
2.0
CRAP 39.8
« Lite/Provider/Handler/CheckID.pm ↑ Summary Lite/RelyingParty/Discover/Service/Builder.pm »
1 package OpenID::Lite::RelyingParty::CheckID::Request;
2  
3 1 ▶use Any::Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use URI;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use OpenID::Lite::Message;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use OpenID::Lite::Constants::Namespace qw(SPEC_2_0 IDENTIFIER_SELECT);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use OpenID::Lite::Constants::ModeType qw(CHECKID_SETUP CHECKID_IMMEDIATE);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use OpenID::Lite::Nonce;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 has 'anonymous' => (
11 is => 'rw',
12 isa => 'Bool',
13 default => 0,
14 );
15  
16 1 has 'service' => (
17 is => 'ro',
18 isa => 'OpenID::Lite::RelyingParty::Discover::Service',
19 required => 1,
20 );
21  
22 1 has 'association' => (
23 is => 'ro',
24 isa => 'OpenID::Lite::Association',
25 predicate => 'has_association',
26 );
27  
28 1 has '_params' => (
29 is => 'ro',
30 lazy_build => 1,
31 handles => {
32 _set_param => 'set',
33 _get_param => 'get',
34 },
35 );
36  
37 0 ▶sub add_extension {
Subroutine add_extension: not called CC=1 SCAR=6.9
Pod undocumented
38 0 my ( $self, $extension ) = @_;
39 # XXX: check service endpoint includes proper Type element for indicated
40 # extension.
41 # if ( $self->service->can_handle_extension($extension) ) {
42 0 $extension->append_to_params($self->_params);
43 # }
44 }
45  
46 0 ▶sub redirect_url {
Subroutine redirect_url: not called CC=1 SCAR=6.9
Pod undocumented
47 0 my ( $self, %args ) = @_;
48 0 $self->gen_params(%args);
49 0 my $url = $self->_params->to_url( $self->service->url );
50 0 return $url;
51 }
52  
53 0 ▶sub gen_params {
Subroutine gen_params: not called CC=9 SCAR=45.0
Pod undocumented
54 0 my ( $self, %args ) = @_;
55  
56 my $mode
57 = $args{immediate}
58 0 ▶ ? CHECKID_IMMEDIATE
Branch: 1 branch
BranchTrueFalseTotal
$args{'immediate'} ? : 0 0 0
59 : CHECKID_SETUP;
60 0 $self->_set_param( mode => $mode );
61  
62 0 my $realm = $args{realm};
63 0 ▶ my $realm_key
Branch: 1 branch
BranchTrueFalseTotal
$self->service->requires_compatibility_mode ? : 0 0 0
64 = $self->service->requires_compatibility_mode
65 ? 'trust_root'
66 : 'realm';
67 0 $self->_set_param( $realm_key, $realm );
68  
69 0 ▶ if ( exists $args{return_to} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $args{"return_to"}) 0 0 0
70 0 my $return_to = URI->new( $args{return_to} );
71 0 ▶ if ( $self->service->requires_compatibility_mode ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->service->requires_compatibility_mode) 0 0 0
72 0 $return_to->query_form(
73 rp_nonce => OpenID::Lite::Nonce->gen_nonce(),
74 openid1_claimed_id => $self->service->claimed_identifier,
75 );
76 }
77 0 $self->_set_param( return_to => $return_to->as_string );
78 }
79  
80 # identity setting
81 0 ▶ unless ( $self->anonymous ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->anonymous) 0 0 0
82 0 my ( $identity, $claimed_id );
83 0 ▶ if ( $self->service->is_op_identifier ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->service->is_op_identifier) { } 0 0 0
84 0 $identity = $claimed_id = IDENTIFIER_SELECT;
85 }
86 else {
87 0 $identity = $self->service->find_local_identifier;
88 0 $claimed_id = $self->service->claimed_identifier;
89 }
90 0 $self->_set_param( identity => $identity );
91 0 ▶ unless ( $self->service->requires_compatibility_mode ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->service->requires_compatibility_mode) 0 0 0
92 0 $self->_set_param( claimed_id => $claimed_id );
93 }
94 }
95  
96 # association setting
97 0 ▶ if ( $self->has_association ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_association) 0 0 0
98 0 $self->_set_param( assoc_handle => $self->association->handle );
99 }
100  
101 }
102  
103 0 ▶sub should_send_redirect {
Subroutine should_send_redirect: not called CC=2 SCAR=17.9
Pod undocumented
104 0 my ( $self, %args ) = @_;
105 0 ▶ return 1 if $self->service->requires_compatibility_mode;
Branch: 1 branch
BranchTrueFalseTotal
if $self->service->requires_compatibility_mode 0 0 0
106 0 my $url = $self->redirect_url(%args);
107 0 return length($url) < 2048;
108 }
109  
110 0 ▶sub _build__params {
Subroutine _build__params: not called CC=1 SCAR=6.9
111 0 my $self = shift;
112 0 my $params = OpenID::Lite::Message->new;
113 0 $params->set( ns => $self->service->preferred_namespace );
114 0 return $params;
115 }
116  
117 1 ▶no Any::Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
118 1 __PACKAGE__->meta->make_immutable;
119 1 1;
« Lite/Provider/Handler/CheckID.pm ↑ Summary Lite/RelyingParty/Discover/Service/Builder.pm »