6 my $template = RT::Template->new( RT->SystemUser );
7 $template->Load("Error: bad GnuPG data");
8 unless ($template->id) {
9 RT->Logger->error( "Couldn't find 'Error: bad GnuPG data' template to rename" );
13 my ($ok, $msg) = $template->SetName("Error: bad encrypted data");
14 RT->Logger->error( "Couldn't rename 'Error: bad GnuPG data' template: $msg")
17 ($ok, $msg) = $template->SetDescription("Inform user that a message he sent has invalid encryption data");
18 RT->Logger->error( "Couldn't update 'Error: bad encrypted data' template description: $msg")
21 my $content = $template->Content;
22 $content =~ s/GnuPG signature/signature/g;
23 ($ok, $msg) = $template->SetContent( $content );
24 RT->Logger->error( "Couldn't update 'Error: bad encrypted data' template content: $msg")
28 my $type = RT::User->new( $RT::SystemUser )->CustomFieldLookupType;
29 my $cf = RT::CustomField->new( $RT::SystemUser );
30 $cf->LoadByCols( Name => 'SMIME Key', LookupType => $type );
31 $cf->LoadByCols( Name => 'PublicKey', LookupType => $type ) unless $cf->id;
33 $RT::Logger->debug("You don't have an 'SMIME Key' or 'PublicKey' user CF -- nothing to do.");
37 my $users = RT::Users->new( RT->SystemUser );
38 $users->LimitCustomField(
39 CUSTOMFIELD => $cf->id,
43 while (my $u = $users->Next) {
44 $u->SetSMIMECertificate(
45 $u->FirstCustomFieldValue( $cf->id ),
49 my $ocfs = $cf->AddedTo;
50 while (my $ocf = $ocfs->Next) {
51 my ($ok, $msg) = $ocf->Delete;
52 RT->Logger->error( "Couldn't delete OCF ".$ocf->id." while deleting ".$cf->Name." CF: $msg")
56 my ($ok, $msg) = $cf->Delete;
57 RT->Logger->error( "Couldn't delete ".$cf->Name." CF: $msg")
61 $RT::Logger->info("Going to delete all SMIMEKeyNotAfter attributes");
62 my $attrs = RT::Attributes->new( $RT::SystemUser );
63 $attrs->Limit( FIELD => 'ObjectType', VALUE => 'RT::User' );
64 $attrs->Limit( FIELD => 'Name', VALUE => 'SMIMEKeyNotAfter' );
65 while ( my $attr = $attrs->Next ) {
66 my ($status, $msg) = $attr->Delete;
68 $RT::Logger->error("Couldn't delete attribute: $msg");
77 Name => "Error: unencrypted message", # loc
79 "Inform user that their unencrypted mail has been rejected", # loc
80 Content => q{Subject: RT requires that all incoming mail be encrypted
82 You received this message because RT received mail from you that was not encrypted. As such, it has been rejected.