line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mail::BIMI::Record::Authority; |
2
|
|
|
|
|
|
|
# ABSTRACT: Class to model a BIMI authority |
3
|
|
|
|
|
|
|
our $VERSION = '3.20210301'; # VERSION |
4
|
30
|
|
|
30
|
|
452
|
use 5.20.0; |
|
30
|
|
|
|
|
104
|
|
5
|
30
|
|
|
30
|
|
156
|
use Moose; |
|
30
|
|
|
|
|
61
|
|
|
30
|
|
|
|
|
532
|
|
6
|
30
|
|
|
30
|
|
188402
|
use Mail::BIMI::Prelude; |
|
30
|
|
|
|
|
75
|
|
|
30
|
|
|
|
|
216
|
|
7
|
30
|
|
|
30
|
|
24106
|
use Mail::BIMI::VMC; |
|
30
|
|
|
|
|
176
|
|
|
30
|
|
|
|
|
18447
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
extends 'Mail::BIMI::Base'; |
10
|
|
|
|
|
|
|
with 'Mail::BIMI::Role::HasError'; |
11
|
|
|
|
|
|
|
has is_authority_valid => ( is => 'rw', lazy => 1, builder => '_build_is_authority_valid' ); |
12
|
|
|
|
|
|
|
has uri => ( is => 'rw', isa => 'Maybe[Str]', required => 1, |
13
|
|
|
|
|
|
|
documentation => 'inputs: URI of VMC', ); |
14
|
|
|
|
|
|
|
has is_valid => ( is => 'rw', lazy => 1, builder => '_build_is_valid', |
15
|
|
|
|
|
|
|
documentation => 'Is this Authority valid' ); |
16
|
|
|
|
|
|
|
has vmc => ( is => 'rw', lazy => 1, builder => '_build_vmc', |
17
|
|
|
|
|
|
|
documentation => 'Mail::BIMI::VMC object for this Authority' ); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
17
|
|
|
17
|
|
26
|
sub _build_is_authority_valid($self) { |
|
17
|
|
|
|
|
37
|
|
|
17
|
|
|
|
|
27
|
|
21
|
17
|
100
|
|
|
|
423
|
return 1 if !defined $self->uri; |
22
|
6
|
100
|
|
|
|
135
|
return 1 if $self->uri eq ''; |
23
|
2
|
100
|
|
|
|
45
|
return 1 if $self->uri eq 'self'; |
24
|
1
|
50
|
|
|
|
24
|
if ( ! ( $self->uri =~ /^https:\/\// ) ) { |
25
|
1
|
|
|
|
|
5
|
$self->add_error('INVALID_TRANSPORT_A'); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
1
|
50
|
|
|
|
23
|
return 0 if $self->errors->@*; |
29
|
0
|
|
|
|
|
0
|
return 1; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
102
|
|
|
102
|
1
|
205
|
sub is_relevant($self) { |
|
102
|
|
|
|
|
200
|
|
|
102
|
|
|
|
|
174
|
|
34
|
102
|
100
|
|
|
|
2726
|
return 0 if !defined $self->uri; |
35
|
24
|
100
|
|
|
|
536
|
return 0 if $self->uri eq ''; |
36
|
3
|
100
|
|
|
|
65
|
return 0 if $self->uri eq 'self'; |
37
|
1
|
50
|
|
|
|
23
|
return 0 if $self->bimi_object->options->no_validate_cert; |
38
|
1
|
|
|
|
|
5
|
$self->log_verbose('Authority is relevant'); |
39
|
1
|
|
|
|
|
5
|
return 1; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
3
|
|
|
3
|
|
6
|
sub _build_is_valid($self) { |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
5
|
|
43
|
3
|
100
|
|
|
|
112
|
return 0 if !$self->is_authority_valid; |
44
|
2
|
50
|
33
|
|
|
10
|
if ( $self->is_relevant && !$self->vmc->is_valid ) { |
45
|
0
|
|
|
|
|
0
|
$self->add_error_object( $self->vmc->errors ); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
2
|
50
|
|
|
|
50
|
return 0 if $self->errors->@*; |
49
|
2
|
|
|
|
|
19
|
$self->log_verbose('Authority is valid'); |
50
|
2
|
|
|
|
|
47
|
return 1; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
14
|
|
|
14
|
|
42
|
sub _build_vmc($self) { |
|
14
|
|
|
|
|
33
|
|
|
14
|
|
|
|
|
21
|
|
54
|
14
|
50
|
|
|
|
430
|
return if !$self->is_authority_valid; |
55
|
14
|
50
|
|
|
|
47
|
return if !$self->is_relevant; |
56
|
0
|
|
|
|
|
0
|
my $check_domain = $self->bimi_object->record->retrieved_domain; |
57
|
0
|
|
|
|
|
0
|
my $check_selector = $self->bimi_object->record->retrieved_selector; |
58
|
0
|
|
|
|
|
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
|
14
|
|
|
14
|
1
|
30
|
sub finish($self) { |
|
14
|
|
|
|
|
30
|
|
|
14
|
|
|
|
|
23
|
|
63
|
14
|
50
|
|
|
|
368
|
$self->vmc->finish if $self->vmc; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
1; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
__END__ |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=pod |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=encoding UTF-8 |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 NAME |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Mail::BIMI::Record::Authority - Class to model a BIMI authority |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 VERSION |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
version 3.20210301 |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 DESCRIPTION |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Class for representing, validating, and processing a BIMI authority attribute |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 INPUTS |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
These values are used as inputs for lookups and verifications, they are typically set by the caller based on values found in the message being processed |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head2 uri |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
is=rw required |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
URI of VMC |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
These values are derived from lookups and verifications made based upon the input values, it is however possible to override these with other values should you wish to, for example, validate a record before it is published in DNS, or validate an Indicator which is only available locally |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head2 errors |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
is=rw |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head2 is_authority_valid |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
is=rw |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head2 is_valid |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
is=rw |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Is this Authority valid |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head2 vmc |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
is=rw |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Mail::BIMI::VMC object for this Authority |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head2 warnings |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
is=rw |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 CONSUMES |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=over 4 |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=item * L<Mail::BIMI::Role::HasError> |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=back |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head1 EXTENDS |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=over 4 |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=item * L<Mail::BIMI::Base> |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=back |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head1 METHODS |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head2 I<is_relevant()> |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
Return true if this Authority is relevant to validation |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head2 I<finish()> |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Finish and clean up, write cache if enabled. |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head1 REQUIRES |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=over 4 |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=item * L<Mail::BIMI::Prelude|Mail::BIMI::Prelude> |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=item * L<Mail::BIMI::VMC|Mail::BIMI::VMC> |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=item * L<Moose|Moose> |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=back |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head1 AUTHOR |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
Marc Bradshaw <marc@marcbradshaw.net> |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
This software is copyright (c) 2020 by Marc Bradshaw. |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
171
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=cut |