| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Net::ACME::Authorization; | 
| 2 |  |  |  |  |  |  |  | 
| 3 |  |  |  |  |  |  | =pod | 
| 4 |  |  |  |  |  |  |  | 
| 5 |  |  |  |  |  |  | =encoding utf-8 | 
| 6 |  |  |  |  |  |  |  | 
| 7 |  |  |  |  |  |  | =head1 NAME | 
| 8 |  |  |  |  |  |  |  | 
| 9 |  |  |  |  |  |  | Net::ACME::Authorization - fulfilled ACME authorization object | 
| 10 |  |  |  |  |  |  |  | 
| 11 |  |  |  |  |  |  | =head1 SYNOPSIS | 
| 12 |  |  |  |  |  |  |  | 
| 13 |  |  |  |  |  |  | use Net::ACME::Authorization (); | 
| 14 |  |  |  |  |  |  |  | 
| 15 |  |  |  |  |  |  | my $authz = Net::ACME::Authorization->new( | 
| 16 |  |  |  |  |  |  | status => 'valid',  #or “invalid” | 
| 17 |  |  |  |  |  |  | challenges => [ @list_of_challenge_objects ], | 
| 18 |  |  |  |  |  |  | ); | 
| 19 |  |  |  |  |  |  |  | 
| 20 |  |  |  |  |  |  | my @challenge_objs = $authz->challenges(); | 
| 21 |  |  |  |  |  |  |  | 
| 22 |  |  |  |  |  |  | my $payload; | 
| 23 |  |  |  |  |  |  | while (!$cert) { | 
| 24 |  |  |  |  |  |  | if ($need_retry->is_time_to_poll()) { | 
| 25 |  |  |  |  |  |  | $cert = $need_retry->poll(); | 
| 26 |  |  |  |  |  |  | } | 
| 27 |  |  |  |  |  |  |  | 
| 28 |  |  |  |  |  |  | sleep 1; | 
| 29 |  |  |  |  |  |  | } | 
| 30 |  |  |  |  |  |  |  | 
| 31 |  |  |  |  |  |  | =cut | 
| 32 |  |  |  |  |  |  |  | 
| 33 |  |  |  |  |  |  | #NOTE: For now, this assumes a domain name. | 
| 34 |  |  |  |  |  |  | #Might be useful moving forward to separate out other types | 
| 35 |  |  |  |  |  |  | #of authz as per ACME spec expansion. (As of April 2016 only | 
| 36 |  |  |  |  |  |  | #domain names are handled.) | 
| 37 |  |  |  |  |  |  |  | 
| 38 | 8 |  |  | 8 |  | 118772 | use strict; | 
|  | 8 |  |  |  |  | 22 |  | 
|  | 8 |  |  |  |  | 230 |  | 
| 39 | 8 |  |  | 8 |  | 40 | use warnings; | 
|  | 8 |  |  |  |  | 15 |  | 
|  | 8 |  |  |  |  | 230 |  | 
| 40 |  |  |  |  |  |  |  | 
| 41 | 8 |  |  | 8 |  | 450 | use Call::Context (); | 
|  | 8 |  |  |  |  | 416 |  | 
|  | 8 |  |  |  |  | 130 |  | 
| 42 |  |  |  |  |  |  |  | 
| 43 | 8 |  |  | 8 |  | 2360 | use Net::ACME::Utils (); | 
|  | 8 |  |  |  |  | 26 |  | 
|  | 8 |  |  |  |  | 150 |  | 
| 44 | 8 |  |  | 8 |  | 50 | use Net::ACME::X (); | 
|  | 8 |  |  |  |  | 15 |  | 
|  | 8 |  |  |  |  | 2024 |  | 
| 45 |  |  |  |  |  |  |  | 
| 46 |  |  |  |  |  |  | my $CHALLENGE_CLASS = 'Net::ACME::Challenge'; | 
| 47 |  |  |  |  |  |  |  | 
| 48 |  |  |  |  |  |  | sub new { | 
| 49 | 4 |  |  | 4 | 0 | 2151 | my ( $class, %opts ) = @_; | 
| 50 |  |  |  |  |  |  |  | 
| 51 |  |  |  |  |  |  | my $self = { | 
| 52 |  |  |  |  |  |  | _status => $opts{'status'} || die('Need “status”!'), | 
| 53 | 4 |  | 50 |  |  | 20 | _challenges => $opts{'challenges'}, | 
| 54 |  |  |  |  |  |  | }; | 
| 55 |  |  |  |  |  |  |  | 
| 56 | 4 | 50 |  |  |  | 13 | if ( $opts{'challenges'} ) { | 
| 57 | 4 |  |  |  |  | 7 | for my $c ( 0 .. $#{ $opts{'challenges'} } ) { | 
|  | 4 |  |  |  |  | 15 |  | 
| 58 | 4 |  |  |  |  | 10 | my $challenge = $opts{'challenges'}[$c]; | 
| 59 |  |  |  |  |  |  |  | 
| 60 | 4 | 100 |  |  |  | 15 | if ( !Net::ACME::Utils::thing_isa($challenge, $CHALLENGE_CLASS) ) { | 
| 61 | 1 |  |  |  |  | 7 | die Net::ACME::X::create( 'InvalidParameter', "“challenges” index $c ($challenge) is not an instance of “$CHALLENGE_CLASS”!" ); | 
| 62 |  |  |  |  |  |  | } | 
| 63 |  |  |  |  |  |  | } | 
| 64 |  |  |  |  |  |  | } | 
| 65 |  |  |  |  |  |  |  | 
| 66 | 3 |  |  |  |  | 18 | return bless $self, $class; | 
| 67 |  |  |  |  |  |  | } | 
| 68 |  |  |  |  |  |  |  | 
| 69 |  |  |  |  |  |  | sub status { | 
| 70 | 3 |  |  | 3 | 0 | 6252 | my ($self) = @_; | 
| 71 | 3 |  |  |  |  | 20 | return $self->{'_status'}; | 
| 72 |  |  |  |  |  |  | } | 
| 73 |  |  |  |  |  |  |  | 
| 74 |  |  |  |  |  |  | sub challenges { | 
| 75 | 4 |  |  | 4 | 0 | 8129 | my ($self) = @_; | 
| 76 |  |  |  |  |  |  |  | 
| 77 | 4 |  |  |  |  | 17 | Call::Context::must_be_list(); | 
| 78 |  |  |  |  |  |  |  | 
| 79 | 3 |  |  |  |  | 81 | return @{ $self->{'_challenges'} }; | 
|  | 3 |  |  |  |  | 16 |  | 
| 80 |  |  |  |  |  |  | } | 
| 81 |  |  |  |  |  |  |  | 
| 82 |  |  |  |  |  |  | 1; |