« lib/Mail/DMARC/Report/Send/HTTP.pm
↑ Summary
blib/lib/Mail/DMARC/Report/Aggregate/Record/Auth_Results/SPF.pm »
| 1 | package Mail::DMARC::Report::Aggregate::Record::Auth_Results::DKIM; | ||
| 2 | our $VERSION = '2.20260827'; | ||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | use feature 'signatures'; | ||
| 6 | no warnings 'experimental::args_array_with_signatures'; ## no critic (ProhibitNoWarnings) | ||
| 7 | |||
| 8 | use Carp; | ||
| 9 | |||
| 10 | sub new( $class, @args ) { | ||
| 11 | |||
| 12 | croak "missing arguments" if !@args; | ||
| 13 | |||
| 14 | my $self = bless {}, $class; | ||
| 15 | |||
| 16 | # a bare hash | ||
| 17 | return $self->_from_hash(@args) if @args > 1; | ||
| 18 | |||
| 19 | my $dkim = shift @args; | ||
| 20 | croak "dkim argument not a ref" if !ref $dkim; | ||
| 21 | |||
| 22 | return $dkim if ref $dkim eq $class; # been here before... | ||
| 23 | |||
| 24 | return $self->_from_hashref($dkim) if 'HASH' eq ref $dkim; | ||
| 25 | |||
| 26 | croak "invalid dkim argument"; | ||
| 27 | } | ||
| 28 | |||
| 29 | sub domain( $self, $value = undef ) { | ||
| 30 | return $self->{domain} if @_ == 1; | ||
| 31 | return $self->{domain} = $value; | ||
| 32 | } | ||
| 33 | |||
| 34 | sub selector( $self, $value = undef ) { | ||
| 35 | return $self->{selector} if @_ == 1; | ||
| 36 | return $self->{selector} = $value; | ||
| 37 | } | ||
| 38 | |||
| 39 | sub result( $self, $value = undef ) { | ||
| 40 | return $self->{result} if @_ == 1; | ||
| 41 | croak "invalid DKIM result" | ||
| 42 | if !grep { $_ eq $value } | ||
| 43 | qw/ pass fail neutral none permerror policy temperror /; | ||
| 44 | return $self->{result} = $value; | ||
| 45 | } | ||
| 46 | |||
| 47 | sub human_result( $self, $value = undef ) { | ||
| 48 | return $self->{human_result} if @_ == 1; | ||
| 49 | return $self->{human_result} = $value; | ||
| 50 | } | ||
| 51 | |||
| 52 | sub _from_hash( $self, %args ) { | ||
| 53 | |||
| 54 | foreach my $key ( keys %args ) { | ||
| 55 | $self->$key( $args{$key} ); | ||
| 56 | } | ||
| 57 | |||
| 58 | $self->is_valid; | ||
| 59 | return $self; | ||
| 60 | } | ||
| 61 | |||
| 62 | sub _from_hashref( $self, $dkim ) { | ||
| 63 | return $self->_from_hash( %{$dkim} ); | ||
| 64 | } | ||
| 65 | |||
| 66 | sub is_valid($self) { | ||
| 67 | |||
| 68 | foreach my $f (qw/ domain result /) { | ||
| 69 | if ( !defined $self->{$f} ) { | ||
| 70 | croak "DKIM value $f is required!"; | ||
| 71 | } | ||
| 72 | } | ||
| 73 | return; | ||
| 74 | } | ||
| 75 | |||
| 76 | 1; | ||
| 77 | |||
| 78 | __END__ | ||
| 79 | |||
| 80 | =pod | ||
| 81 | |||
| 82 | =head1 NAME | ||
| 83 | |||
| 84 | Mail::DMARC::Report::Aggregate::Record::Auth_Results::DKIM - auth_results/dkim section of a DMARC aggregate record | ||
| 85 | |||
| 86 | =head1 VERSION | ||
| 87 | |||
| 88 | version 2.20260827 | ||
| 89 | |||
| 90 | =head1 AUTHORS | ||
| 91 | |||
| 92 | =over 4 | ||
| 93 | |||
| 94 | =item * | ||
| 95 | |||
| 96 | Matt Simerson <msimerson@cpan.org> | ||
| 97 | |||
| 98 | =item * | ||
| 99 | |||
| 100 | Davide Migliavacca <shari@cpan.org> | ||
| 101 | |||
| 102 | =item * | ||
| 103 | |||
| 104 | Marc Bradshaw <marc@marcbradshaw.net> | ||
| 105 | |||
| 106 | =back | ||
| 107 | |||
| 108 | =head1 COPYRIGHT AND LICENSE | ||
| 109 | |||
| 110 | This software is copyright (c) 2026 by Matt Simerson. | ||
| 111 | |||
| 112 | This is free software; you can redistribute it and/or modify it under | ||
| 113 | the same terms as the Perl 5 programming language system itself. | ||
| 114 | |||
| 115 | =cut |