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.20210512'; # VERSION |
4
|
29
|
|
|
29
|
|
451
|
use 5.20.0; |
|
29
|
|
|
|
|
113
|
|
5
|
29
|
|
|
29
|
|
173
|
use Moose; |
|
29
|
|
|
|
|
62
|
|
|
29
|
|
|
|
|
266
|
|
6
|
29
|
|
|
29
|
|
200579
|
use Mail::BIMI::Prelude; |
|
29
|
|
|
|
|
79
|
|
|
29
|
|
|
|
|
256
|
|
7
|
29
|
|
|
29
|
|
25485
|
use Mail::BIMI::VMC; |
|
29
|
|
|
|
|
206
|
|
|
29
|
|
|
|
|
20366
|
|
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
|
8
|
|
|
8
|
|
16
|
sub _build_is_authority_valid($self) { |
|
8
|
|
|
|
|
24
|
|
|
8
|
|
|
|
|
17
|
|
21
|
8
|
100
|
|
|
|
224
|
return 1 if !defined $self->uri; |
22
|
3
|
100
|
|
|
|
68
|
return 1 if $self->uri eq ''; |
23
|
2
|
100
|
|
|
|
46
|
return 1 if $self->uri eq 'self'; |
24
|
1
|
50
|
|
|
|
23
|
if ( ! ( $self->uri =~ /^https:\/\// ) ) { |
25
|
1
|
|
|
|
|
6
|
$self->add_error('INVALID_TRANSPORT_A'); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
1
|
50
|
|
|
|
24
|
return 0 if $self->errors->@*; |
29
|
0
|
|
|
|
|
0
|
return 1; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
75
|
|
|
75
|
1
|
170
|
sub is_relevant($self) { |
|
75
|
|
|
|
|
169
|
|
|
75
|
|
|
|
|
143
|
|
34
|
75
|
100
|
|
|
|
2328
|
return 0 if !defined $self->uri; |
35
|
9
|
100
|
|
|
|
235
|
return 0 if $self->uri eq ''; |
36
|
3
|
100
|
|
|
|
68
|
return 0 if $self->uri eq 'self'; |
37
|
1
|
50
|
|
|
|
22
|
return 0 if $self->bimi_object->options->no_validate_cert; |
38
|
1
|
|
|
|
|
4
|
$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
|
|
|
|
|
4
|
|
43
|
3
|
100
|
|
|
|
81
|
return 0 if !$self->is_authority_valid; |
44
|
2
|
50
|
33
|
|
|
6
|
if ( $self->is_relevant && !$self->vmc->is_valid ) { |
45
|
0
|
|
|
|
|
0
|
$self->add_error_object( $self->vmc->errors ); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
2
|
50
|
|
|
|
49
|
return 0 if $self->errors->@*; |
49
|
2
|
|
|
|
|
14
|
$self->log_verbose('Authority is valid'); |
50
|
2
|
|
|
|
|
47
|
return 1; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
5
|
|
|
5
|
|
13
|
sub _build_vmc($self) { |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
10
|
|
54
|
5
|
50
|
|
|
|
180
|
return if !$self->is_authority_valid; |
55
|
5
|
50
|
|
|
|
25
|
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
|
5
|
|
|
5
|
1
|
14
|
sub finish($self) { |
|
5
|
|
|
|
|
14
|
|
|
5
|
|
|
|
|
10
|
|
63
|
5
|
50
|
|
|
|
154
|
$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.20210512 |
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 |