package Net::ACME2::Authorization; use strict; use warnings; =encoding utf-8 =head1 NAME Net::ACME2::Authorization =head1 DESCRIPTION The ACME Authorization object. =cut use parent qw( Net::ACME2::AccessorBase ); use Call::Context (); use Net::ACME2::Challenge (); #Pre-load challenge classes. use Net::ACME2::Challenge::http_01 (); use Net::ACME2::Challenge::dns_01 (); use Net::ACME2::Challenge::tls_alpn_01 (); use constant _ACCESSORS => ( 'id', 'expires', 'status', ); =head1 ACCESSORS These provide text strings as defined in the ACME specification. =over =item * B =item * B =item * B =back =head1 OTHER METHODS =head2 I->wildcard() Returns a Perl boolean that indicates whether the authorization is for a wildcard DNS name. =cut sub wildcard { my ($self) = @_; return !!$self->{'_wildcard'}; } =head2 I->identifier() The order’s identifier, as a hash reference. The content matches the ACME specification. (NB: Wildcard authorizations do B contain the leading C<*.> in the C.) =cut sub identifier { my ($self) = @_; return { %{ $self->{'_identifier'} } }; } =head2 I->challenges() The order’s challenges, as a list of L instances. (C challenges will be instances of L.) =cut sub challenges { my ($self) = @_; Call::Context::must_be_list(); my @challenges; for my $c ( @{ $self->{'_challenges'} } ) { my $class = 'Net::ACME2::Challenge'; my $module_leaf = $c->{'type'}; $module_leaf =~ tr<-><_>; $class .= "::$module_leaf"; #Ignore unrecognized challenges. next if !$class->can('new'); push @challenges, $class->new( %$c ); } return @challenges; } sub update { my ($self, $new_hr) = @_; for my $name ( 'status', 'challenges' ) { $self->{"_$name"} = $new_hr->{$name}; } return $self; } 1;