+ Crypt => {
+ Type => 'HASH',
+ PostLoadCheck => sub {
+ my $self = shift;
+ require RT::Crypt;
+
+ for my $proto (RT::Crypt->EnabledProtocols) {
+ my $opt = $self->Get($proto);
+ if (not RT::Crypt->LoadImplementation($proto)) {
+ $RT::Logger->error("You enabled $proto, but we couldn't load module RT::Crypt::$proto");
+ $opt->{'Enable'} = 0;
+ } elsif (not RT::Crypt->LoadImplementation($proto)->Probe) {
+ $opt->{'Enable'} = 0;
+ } elsif ($META{$proto}{'PostLoadCheck'}) {
+ $META{$proto}{'PostLoadCheck'}->( $self, $self->Get( $proto ) );
+ }
+
+ }
+
+ my $opt = $self->Get('Crypt');
+ my @enabled = RT::Crypt->EnabledProtocols;
+ my %enabled;
+ $enabled{$_} = 1 for @enabled;
+ $opt->{'Enable'} = scalar @enabled;
+ $opt->{'Incoming'} = [ $opt->{'Incoming'} ]
+ if $opt->{'Incoming'} and not ref $opt->{'Incoming'};
+ if ( $opt->{'Incoming'} && @{ $opt->{'Incoming'} } ) {
+ $RT::Logger->warning("$_ explicitly set as incoming Crypt plugin, but not marked Enabled; removing")
+ for grep {not $enabled{$_}} @{$opt->{'Incoming'}};
+ $opt->{'Incoming'} = [ grep {$enabled{$_}} @{$opt->{'Incoming'}} ];
+ } else {
+ $opt->{'Incoming'} = \@enabled;
+ }
+ if ( $opt->{'Outgoing'} ) {
+ if (not $enabled{$opt->{'Outgoing'}}) {
+ $RT::Logger->warning($opt->{'Outgoing'}.
+ " explicitly set as outgoing Crypt plugin, but not marked Enabled; "
+ . (@enabled ? "using $enabled[0]" : "removing"));
+ }
+ $opt->{'Outgoing'} = $enabled[0] unless $enabled{$opt->{'Outgoing'}};
+ } else {
+ $opt->{'Outgoing'} = $enabled[0];
+ }
+ },
+ },
+ SMIME => {
+ Type => 'HASH',
+ PostLoadCheck => sub {
+ my $self = shift;
+ my $opt = $self->Get('SMIME');
+ return unless $opt->{'Enable'};
+
+ if (exists $opt->{Keyring}) {
+ unless ( File::Spec->file_name_is_absolute( $opt->{Keyring} ) ) {
+ $opt->{Keyring} = File::Spec->catfile( $RT::BasePath, $opt->{Keyring} );
+ }
+ unless (-d $opt->{Keyring} and -r _) {
+ $RT::Logger->info(
+ "RT's SMIME libraries couldn't successfully read your".
+ " configured SMIME keyring directory (".$opt->{Keyring}
+ .").");
+ delete $opt->{Keyring};
+ }
+ }
+
+ if (defined $opt->{CAPath}) {
+ if (-d $opt->{CAPath} and -r _) {
+ # directory, all set
+ } elsif (-f $opt->{CAPath} and -r _) {
+ # file, all set
+ } else {
+ $RT::Logger->warn(
+ "RT's SMIME libraries could not read your configured CAPath (".$opt->{CAPath}.")"
+ );
+ delete $opt->{CAPath};
+ }
+ }
+ },
+ },
+ GnuPG => {
+ Type => 'HASH',