1package Net::ACME2::Authorization; 2 3use strict; 4use warnings; 5 6=encoding utf-8 7 8=head1 NAME 9 10Net::ACME2::Authorization 11 12=head1 DESCRIPTION 13 14The ACME Authorization object. 15 16=cut 17 18use parent qw( Net::ACME2::AccessorBase ); 19 20use Call::Context (); 21 22use Net::ACME2::Challenge (); 23 24#Pre-load challenge classes. 25use Net::ACME2::Challenge::http_01 (); 26use Net::ACME2::Challenge::dns_01 (); 27use Net::ACME2::Challenge::tls_alpn_01 (); 28 29use constant _ACCESSORS => ( 30 'id', 31 'expires', 32 'status', 33); 34 35=head1 ACCESSORS 36 37These provide text strings as defined in the ACME specification. 38 39=over 40 41=item * B<id()> 42 43=item * B<status()> 44 45=item * B<expires()> 46 47=back 48 49=head1 OTHER METHODS 50 51=head2 I<OBJ>->wildcard() 52 53Returns a Perl boolean that indicates whether the authorization is 54for a wildcard DNS name. 55 56=cut 57 58sub wildcard { 59 my ($self) = @_; 60 61 return !!$self->{'_wildcard'}; 62} 63 64=head2 I<OBJ>->identifier() 65 66The order’s identifier, as a hash reference. 67The content matches the ACME specification. (NB: Wildcard 68authorizations do B<NOT> contain the leading C<*.> in the 69C<value>.) 70 71=cut 72 73sub identifier { 74 my ($self) = @_; 75 76 return { %{ $self->{'_identifier'} } }; 77} 78 79=head2 I<OBJ>->challenges() 80 81The order’s challenges, as a list of L<Net::ACME2::Challenge> 82instances. (C<http-01> challenges will be instances of 83L<Net::ACME2::Challenge::http_01>.) 84 85=cut 86 87sub challenges { 88 my ($self) = @_; 89 90 Call::Context::must_be_list(); 91 92 my @challenges; 93 94 for my $c ( @{ $self->{'_challenges'} } ) { 95 my $class = 'Net::ACME2::Challenge'; 96 97 my $module_leaf = $c->{'type'}; 98 $module_leaf =~ tr<-><_>; 99 $class .= "::$module_leaf"; 100 101 #Ignore unrecognized challenges. 102 next if !$class->can('new'); 103 104 push @challenges, $class->new( %$c ); 105 } 106 107 return @challenges; 108} 109 110sub update { 111 my ($self, $new_hr) = @_; 112 113 for my $name ( 'status', 'challenges' ) { 114 $self->{"_$name"} = $new_hr->{$name}; 115 } 116 117 return $self; 118} 119 1201; 121