| 1 | package Mail::BIMI::Record::Authority; | ||||||||||||||||||||||||||||
| 2 | # ABSTRACT: Class to model a BIMI authority | ||||||||||||||||||||||||||||
| 3 | 29 | our $VERSION = '3.20261116'; # VERSION | |||||||||||||||||||||||||||
| 4 | 29 | ▶ | use 5.20.0; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 29 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 29 | ▶ | use Mail::BIMI::Prelude; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 29 | ▶ | use Mail::BIMI::VMC; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 29 | extends 'Mail::BIMI::Base'; | |||||||||||||||||||||||||||
| 10 | 29 | with 'Mail::BIMI::Role::HasError'; | |||||||||||||||||||||||||||
| 11 | 29 | has is_authority_valid => ( is => 'rw', lazy => 1, builder => '_build_is_authority_valid' ); | |||||||||||||||||||||||||||
| 12 | 29 | has uri => ( is => 'rw', isa => 'Maybe[Str]', required => 1, | |||||||||||||||||||||||||||
| 13 | documentation => 'inputs: URI of VMC', ); | ||||||||||||||||||||||||||||
| 14 | 29 | has is_valid => ( is => 'rw', lazy => 1, builder => '_build_is_valid', | |||||||||||||||||||||||||||
| 15 | documentation => 'Is this Authority valid' ); | ||||||||||||||||||||||||||||
| 16 | 29 | has vmc => ( is => 'rw', lazy => 1, builder => '_build_vmc', | |||||||||||||||||||||||||||
| 17 | documentation => 'Mail::BIMI::VMC object for this Authority' ); | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 8 | ▶ | sub _build_is_authority_valid($self) { | ||||||||||||||||||||||||||
|
Subroutine
_build_is_authority_valid: called CC=6 SCAR=18.2
| |||||||||||||||||||||||||||||
| 21 | 8 | ▶ | return 1 if !defined $self->uri; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 22 | 3 | ▶ | return 1 if $self->uri eq ''; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 23 | 2 | ▶ | return 1 if $self->uri eq 'self'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 24 | 1 | ▶ | if ( ! ( $self->uri =~ /^https:\/\// ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 25 | 1 | $self->add_error('INVALID_TRANSPORT_A'); | |||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 1 | ▶ | return 0 if $self->errors->@*; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 29 | 0 | return 1; | |||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 77 | ▶ | sub is_relevant($self) { | ||||||||||||||||||||||||||
|
Subroutine
is_relevant: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||
| 34 | 77 | ▶ | return 0 if !defined $self->uri; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 35 | 11 | ▶ | return 0 if $self->uri eq ''; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 36 | 3 | ▶ | return 0 if $self->uri eq 'self'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 37 | 1 | ▶ | return 0 if $self->bimi_object->options->no_validate_cert; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 38 | 1 | $self->log_verbose('Authority is relevant'); | |||||||||||||||||||||||||||
| 39 | 1 | return 1; | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 3 | ▶ | sub _build_is_valid($self) { | ||||||||||||||||||||||||||
|
Subroutine
_build_is_valid: called CC=5 SCAR=17.8
| |||||||||||||||||||||||||||||
| 43 | 3 | ▶ | return 0 if !$self->is_authority_valid; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 44 | 2 | ▶ | if ( $self->is_relevant && !$self->vmc->is_valid ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->is_relevant and not $self->vmc->is_valid
MC/DC0%0/2
$self->is_relevant and not $self->vmc->is_valid
$self->is_relevant
not $self->vmc->is_valid
Truth table33%1/3
A and not(B)
A= $self->is_relevantB= not $self->vmc->is_valid
| |||||||||||||||||||||||||||||
| 45 | 0 | $self->add_error_object( $self->vmc->errors ); | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 2 | ▶ | return 0 if $self->errors->@*; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 49 | 2 | $self->log_verbose('Authority is valid'); | |||||||||||||||||||||||||||
| 50 | 2 | return 1; | |||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 5 | ▶ | sub _build_vmc($self) { | ||||||||||||||||||||||||||
|
Subroutine
_build_vmc: called CC=3 SCAR=15.1
| |||||||||||||||||||||||||||||
| 54 | 5 | ▶ | return if !$self->is_authority_valid; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 55 | 5 | ▶ | return if !$self->is_relevant; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 56 | 0 | my $check_domain = $self->bimi_object->record->retrieved_domain; | |||||||||||||||||||||||||||
| 57 | 0 | my $check_selector = $self->bimi_object->record->retrieved_selector; | |||||||||||||||||||||||||||
| 58 | 0 | return Mail::BIMI::VMC->new( check_domain => $check_domain, check_selector => $check_selector, uri => $self->uri, bimi_object => $self->bimi_object ); | |||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 5 | ▶ | sub finish($self) { | ||||||||||||||||||||||||||
|
Subroutine
finish: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||
| 63 | 5 | ▶ | $self->vmc->finish if $self->vmc; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 29 | 1; | |||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | __END__ | ||||||||||||||||||||||||||||