| 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 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 39 | 8 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 40 | |||||||||||||
| 41 | 8 | ▶ | use Call::Context (); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 42 | |||||||||||||
| 43 | 8 | ▶ | use Net::ACME::Utils (); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 44 | 8 | ▶ | use Net::ACME::X (); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 45 | |||||||||||||
| 46 | 8 | my $CHALLENGE_CLASS = 'Net::ACME::Challenge'; | |||||||||||
| 47 | |||||||||||||
| 48 | sub new { | ||||||||||||
| 49 | 4 | ▶ | my ( $class, %opts ) = @_; | ||||||||||
|
Subroutine
new: called CC=5 SCAR=16.2
Pod
undocumented
| |||||||||||||
| 50 | |||||||||||||
| 51 | my $self = { | ||||||||||||
| 52 | _status => $opts{'status'} || die('Need “status”!'), | ||||||||||||
| 53 | 4 | ▶ | _challenges => $opts{'challenges'}, | ||||||||||
|
Condition50%1/2
$opts{'status'} || die("Need \342\200\234status\342\200\235!")
MC/DC0%0/1
$opts{'status'} || die("Need \342\200\234status\342\200\235!")
$opts{'status'}
Truth table50%1/2
A
A= $opts{'status'}
| |||||||||||||
| 54 | }; | ||||||||||||
| 55 | |||||||||||||
| 56 | 4 | ▶ | if ( $opts{'challenges'} ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 57 | 4 | for my $c ( 0 .. $#{ $opts{'challenges'} } ) { | |||||||||||
| 58 | 4 | my $challenge = $opts{'challenges'}[$c]; | |||||||||||
| 59 | |||||||||||||
| 60 | 4 | ▶ | if ( !Net::ACME::Utils::thing_isa($challenge, $CHALLENGE_CLASS) ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 61 | 1 | die Net::ACME::X::create( 'InvalidParameter', "“challenges” index $c ($challenge) is not an instance of “$CHALLENGE_CLASS”!" ); | |||||||||||
| 62 | } | ||||||||||||
| 63 | } | ||||||||||||
| 64 | } | ||||||||||||
| 65 | |||||||||||||
| 66 | 3 | return bless $self, $class; | |||||||||||
| 67 | } | ||||||||||||
| 68 | |||||||||||||
| 69 | sub status { | ||||||||||||
| 70 | 3 | ▶ | my ($self) = @_; | ||||||||||
|
Subroutine
status: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||
| 71 | 3 | return $self->{'_status'}; | |||||||||||
| 72 | } | ||||||||||||
| 73 | |||||||||||||
| 74 | sub challenges { | ||||||||||||
| 75 | 4 | ▶ | my ($self) = @_; | ||||||||||
|
Subroutine
challenges: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||
| 76 | |||||||||||||
| 77 | 4 | Call::Context::must_be_list(); | |||||||||||
| 78 | |||||||||||||
| 79 | 3 | return @{ $self->{'_challenges'} }; | |||||||||||
| 80 | } | ||||||||||||
| 81 | |||||||||||||
| 82 | 8 | 1; | |||||||||||