Skip to content

Commit e880258

Browse files
committed
Removed Kernel::System::Crypt layer to use Kernel::System::Crypt::PGP and ::SMIME directly.
1 parent da21cd7 commit e880258

File tree

20 files changed

+327
-422
lines changed

20 files changed

+327
-422
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#5.0.0.beta1 20??-??-??
2+
- 2015-03-24 Removed Kernel::System::Crypt layer to use Kernel::System::Crypt::PGP and ::SMIME directly.
23
- 2015-03-20 Let LWP::UserAgent handle https-proxy commands, thanks to Michiel Beijen.
34
- 2015-03-20 Added possibility to specify minimum log level, thanks to Renée Bäcker.
45
- 2015-02-23 Added Ping() to Kernel::System::DB.pm API.

Kernel/Modules/AdminPGP.pm

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ package Kernel::Modules::AdminPGP;
1212
use strict;
1313
use warnings;
1414

15-
use Kernel::System::Crypt;
15+
use Kernel::System::Crypt::PGP;
1616

1717
sub new {
1818
my ( $Type, %Param ) = @_;
@@ -28,7 +28,7 @@ sub new {
2828
}
2929
}
3030

31-
$Self->{CryptObject} = Kernel::System::Crypt->new( %Param, CryptType => 'PGP' );
31+
$Self->{PGPObject} = Kernel::System::Crypt::PGP->new();
3232

3333
return $Self;
3434
}
@@ -91,12 +91,12 @@ sub Run {
9191
}
9292
my $Success = '';
9393
if ( $Type eq 'sec' ) {
94-
$Success = $Self->{CryptObject}->SecretKeyDelete( Key => $Key );
94+
$Success = $Self->{PGPObject}->SecretKeyDelete( Key => $Key );
9595
}
9696
else {
97-
$Success = $Self->{CryptObject}->PublicKeyDelete( Key => $Key );
97+
$Success = $Self->{PGPObject}->PublicKeyDelete( Key => $Key );
9898
}
99-
my @List = $Self->{CryptObject}->KeySearch( Search => $Param{Search} );
99+
my @List = $Self->{PGPObject}->KeySearch( Search => $Param{Search} );
100100
if (@List) {
101101
for my $Key (@List) {
102102
$Self->{LayoutObject}->Block(
@@ -176,7 +176,7 @@ sub Run {
176176
if ( !%Errors ) {
177177

178178
# add pgp key
179-
my $KeyAdd = $Self->{CryptObject}->KeyAdd( Key => $UploadStuff{Content} );
179+
my $KeyAdd = $Self->{PGPObject}->KeyAdd( Key => $UploadStuff{Content} );
180180

181181
if ($KeyAdd) {
182182
$Self->{LayoutObject}->Block( Name => 'Overview' );
@@ -185,7 +185,7 @@ sub Run {
185185
$Self->{LayoutObject}->Block( Name => 'ActionAdd' );
186186
$Self->{LayoutObject}->Block( Name => 'OverviewResult' );
187187

188-
my @List = $Self->{CryptObject}->KeySearch( Search => '' );
188+
my @List = $Self->{PGPObject}->KeySearch( Search => '' );
189189
if (@List) {
190190
for my $Key (@List) {
191191
$Self->{LayoutObject}->Block(
@@ -244,10 +244,10 @@ sub Run {
244244
}
245245
my $KeyString = '';
246246
if ( $Type eq 'sec' ) {
247-
$KeyString = $Self->{CryptObject}->SecretKeyGet( Key => $Key );
247+
$KeyString = $Self->{PGPObject}->SecretKeyGet( Key => $Key );
248248
}
249249
else {
250-
$KeyString = $Self->{CryptObject}->PublicKeyGet( Key => $Key );
250+
$KeyString = $Self->{PGPObject}->PublicKeyGet( Key => $Key );
251251
}
252252
return $Self->{LayoutObject}->Attachment(
253253
ContentType => 'text/plain',
@@ -274,13 +274,13 @@ sub Run {
274274
}
275275
my $Download = '';
276276
if ( $Type eq 'sec' ) {
277-
my @Result = $Self->{CryptObject}->PrivateKeySearch( Search => $Key );
277+
my @Result = $Self->{PGPObject}->PrivateKeySearch( Search => $Key );
278278
if ( $Result[0] ) {
279279
$Download = $Result[0]->{Fingerprint};
280280
}
281281
}
282282
else {
283-
my @Result = $Self->{CryptObject}->PublicKeySearch( Search => $Key );
283+
my @Result = $Self->{PGPObject}->PublicKeySearch( Search => $Key );
284284
if ( $Result[0] ) {
285285
$Download = $Result[0]->{Fingerprint};
286286
}
@@ -301,7 +301,7 @@ sub Run {
301301
my $Output .= $Self->{LayoutObject}->Header();
302302
$Output .= $Self->{LayoutObject}->NavigationBar();
303303

304-
if ( !$Self->{CryptObject} && $Self->{ConfigObject}->Get('PGP') ) {
304+
if ( !$Self->{PGPObject} && $Self->{ConfigObject}->Get('PGP') ) {
305305
$Output .= $Self->{LayoutObject}->Notify(
306306
Priority => 'Error',
307307
Data => $Self->{LayoutObject}->{LanguageObject}->Translate( "Cannot create %s!", "CryptObject" ),
@@ -319,8 +319,8 @@ sub Run {
319319
$Self->{LayoutObject}->Block( Name => 'OverviewResult' );
320320

321321
my @List = ();
322-
if ( $Self->{CryptObject} ) {
323-
@List = $Self->{CryptObject}->KeySearch( Search => $Param{Search} );
322+
if ( $Self->{PGPObject} ) {
323+
@List = $Self->{PGPObject}->KeySearch( Search => $Param{Search} );
324324
}
325325
if (@List) {
326326
for my $Key (@List) {
@@ -337,10 +337,10 @@ sub Run {
337337
);
338338
}
339339

340-
if ( $Self->{CryptObject} && $Self->{CryptObject}->Check() ) {
340+
if ( $Self->{PGPObject} && $Self->{PGPObject}->Check() ) {
341341
$Output .= $Self->{LayoutObject}->Notify(
342342
Priority => 'Error',
343-
Data => $Self->{LayoutObject}->{LanguageObject}->Translate( $Self->{CryptObject}->Check() ),
343+
Data => $Self->{LayoutObject}->{LanguageObject}->Translate( $Self->{PGPObject}->Check() ),
344344
);
345345
}
346346
$Output .= $Self->{LayoutObject}->Output(

Kernel/Modules/AdminQueue.pm

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ package Kernel::Modules::AdminQueue;
1313
use strict;
1414
use warnings;
1515

16-
use Kernel::System::Crypt;
16+
use Kernel::System::Crypt::PGP;
17+
use Kernel::System::Crypt::SMIME;
1718
use Kernel::System::Valid;
1819
use Kernel::System::Salutation;
1920
use Kernel::System::Signature;
@@ -68,10 +69,7 @@ sub Run {
6869

6970
%QueueData = $Self->{QueueObject}->QueueGet( ID => $QueueID );
7071

71-
my $CryptObjectPGP = Kernel::System::Crypt->new(
72-
%{$Self},
73-
CryptType => 'PGP',
74-
);
72+
my $CryptObjectPGP = Kernel::System::Crypt::PGP->new();
7573

7674
if ($CryptObjectPGP) {
7775

@@ -83,10 +81,7 @@ sub Run {
8381
}
8482
}
8583

86-
my $CryptObjectSMIME = Kernel::System::Crypt->new(
87-
%{$Self},
88-
CryptType => 'SMIME',
89-
);
84+
my $CryptObjectSMIME = Kernel::System::Crypt::SMIME->new();
9085

9186
if ($CryptObjectSMIME) {
9287

Kernel/Modules/AdminSMIME.pm

Lines changed: 39 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ package Kernel::Modules::AdminSMIME;
1212
use strict;
1313
use warnings;
1414

15-
use Kernel::System::Crypt;
15+
our $ObjectManagerDisabled = 1;
16+
1617
use Kernel::System::CustomerUser;
1718

1819
sub new {
@@ -32,7 +33,6 @@ sub new {
3233
}
3334
}
3435

35-
$Self->{CryptObject} = Kernel::System::Crypt->new( %Param, CryptType => 'SMIME' );
3636
$Self->{CustomerUserObject} = Kernel::System::CustomerUser->new(%Param);
3737

3838
return $Self;
@@ -54,6 +54,8 @@ sub Run {
5454
Value => $Param{Search},
5555
);
5656

57+
my $SMIMEObject = $Kernel::OM->Get('Kernel::System::Crypt::SMIME');
58+
5759
# ------------------------------------------------------------ #
5860
# delete cert
5961
# ------------------------------------------------------------ #
@@ -75,18 +77,18 @@ sub Run {
7577

7678
# remove private key
7779
if ( $Type eq 'key' ) {
78-
%Result = $Self->{CryptObject}->PrivateRemove( Filename => $Filename );
80+
%Result = $SMIMEObject->PrivateRemove( Filename => $Filename );
7981
push @Result, \%Result if %Result;
8082
}
8183

8284
# remove certificate and private key if exists
8385
else {
84-
my $Certificate = $Self->{CryptObject}->CertificateGet( Filename => $Filename );
85-
my %Attributes = $Self->{CryptObject}->CertificateAttributes(
86+
my $Certificate = $SMIMEObject->CertificateGet( Filename => $Filename );
87+
my %Attributes = $SMIMEObject->CertificateAttributes(
8688
Certificate => $Certificate,
8789
);
8890

89-
%Result = $Self->{CryptObject}->CertificateRemove( Filename => $Filename );
91+
%Result = $SMIMEObject->CertificateRemove( Filename => $Filename );
9092
push @Result, \%Result if %Result;
9193

9294
# delete certificate from customer preferences
@@ -121,7 +123,7 @@ sub Run {
121123
}
122124

123125
if ( defined $Attributes{Private} && $Attributes{Private} eq 'Yes' ) {
124-
%Result = $Self->{CryptObject}->PrivateRemove( Filename => $Filename );
126+
%Result = $SMIMEObject->PrivateRemove( Filename => $Filename );
125127
push @Result, \%Result if %Result;
126128
}
127129
}
@@ -178,7 +180,7 @@ sub Run {
178180
if ( !%Errors ) {
179181

180182
# add certificate
181-
my %Result = $Self->{CryptObject}->CertificateAdd( Certificate => $UploadStuff{Content} );
183+
my %Result = $SMIMEObject->CertificateAdd( Certificate => $UploadStuff{Content} );
182184
my @Result;
183185
push @Result, \%Result if %Result;
184186

@@ -245,7 +247,7 @@ sub Run {
245247
if ( !%Errors ) {
246248

247249
# add private key
248-
my %Result = $Self->{CryptObject}->PrivateAdd(
250+
my %Result = $SMIMEObject->PrivateAdd(
249251
Private => $UploadStuff{Content},
250252
Secret => $GetParam{Secret},
251253
);
@@ -290,8 +292,8 @@ sub Run {
290292
my $Hash = $Filename;
291293
$Hash =~ s{(.+)\.\d}{$1}xms;
292294

293-
my $Certificate = $Self->{CryptObject}->CertificateGet( Filename => $Filename );
294-
my %Attributes = $Self->{CryptObject}->CertificateAttributes( Certificate => $Certificate );
295+
my $Certificate = $SMIMEObject->CertificateGet( Filename => $Filename );
296+
my %Attributes = $SMIMEObject->CertificateAttributes( Certificate => $Certificate );
295297
return $Self->{LayoutObject}->Attachment(
296298
ContentType => 'text/plain',
297299
Content => $Attributes{Fingerprint},
@@ -321,12 +323,12 @@ sub Run {
321323
# download key
322324
if ( $Type eq 'key' ) {
323325
my $Secret;
324-
( $Download, $Secret ) = $Self->{CryptObject}->PrivateGet( Filename => $Filename );
326+
( $Download, $Secret ) = $SMIMEObject->PrivateGet( Filename => $Filename );
325327
}
326328

327329
# download certificate
328330
else {
329-
$Download = $Self->{CryptObject}->CertificateGet( Filename => $Filename );
331+
$Download = $SMIMEObject->CertificateGet( Filename => $Filename );
330332
}
331333
return $Self->{LayoutObject}->Attachment(
332334
ContentType => 'text/plain',
@@ -367,7 +369,7 @@ sub Run {
367369
}
368370

369371
# relation already exists?
370-
my $Exists = $Self->{CryptObject}->SignerCertRelationExists(
372+
my $Exists = $SMIMEObject->SignerCertRelationExists(
371373
CertFingerprint => $CertFingerprint,
372374
CAFingerprint => $CAFingerprint,
373375
);
@@ -393,7 +395,7 @@ sub Run {
393395
);
394396
}
395397
else {
396-
my $Result = $Self->{CryptObject}->SignerCertRelationAdd(
398+
my $Result = $SMIMEObject->SignerCertRelationAdd(
397399
CertFingerprint => $CertFingerprint,
398400
CAFingerprint => $CAFingerprint,
399401
UserID => $Self->{UserID},
@@ -436,7 +438,7 @@ sub Run {
436438
}
437439

438440
# relation exists?
439-
my $Exists = $Self->{CryptObject}->SignerCertRelationExists(
441+
my $Exists = $SMIMEObject->SignerCertRelationExists(
440442
CertFingerprint => $CertFingerprint,
441443
CAFingerprint => $CAFingerprint,
442444
);
@@ -457,7 +459,7 @@ sub Run {
457459
);
458460
}
459461
else {
460-
my $Success = $Self->{CryptObject}->SignerCertRelationDelete(
462+
my $Success = $SMIMEObject->SignerCertRelationDelete(
461463
CertFingerprint => $CertFingerprint,
462464
CAFingerprint => $CAFingerprint,
463465
UserID => $Self->{UserID},
@@ -584,7 +586,10 @@ sub _Overview {
584586
);
585587
}
586588
}
587-
if ( !$Self->{CryptObject} && $Self->{ConfigObject}->Get('SMIME') ) {
589+
590+
my $SMIMEObject = $Kernel::OM->Get('Kernel::System::Crypt::SMIME');
591+
592+
if ( !$SMIMEObject && $Self->{ConfigObject}->Get('SMIME') ) {
588593
$Output .= $Self->{LayoutObject}->Notify(
589594
Priority => 'Error',
590595
Data => $Self->{LayoutObject}->{LanguageObject}->Translate( "Cannot create %s!", "CryptObject" ),
@@ -593,10 +598,10 @@ sub _Overview {
593598
. 'Action=AdminSysConfig;Subaction=Edit;SysConfigGroup=Framework;SysConfigSubGroup=Crypt::SMIME',
594599
);
595600
}
596-
if ( $Self->{CryptObject} && $Self->{CryptObject}->Check() ) {
601+
if ( $SMIMEObject && $SMIMEObject->Check() ) {
597602
$Output .= $Self->{LayoutObject}->Notify(
598603
Priority => 'Error',
599-
Data => $Self->{LayoutObject}->{LanguageObject}->Translate("' . $Self->{CryptObject}->Check() . '"),
604+
Data => $Self->{LayoutObject}->{LanguageObject}->Translate("' . $SMIMEObject->Check() . '"),
600605
);
601606
}
602607

@@ -609,8 +614,8 @@ sub _Overview {
609614
}
610615

611616
my @List = ();
612-
if ( $Self->{CryptObject} ) {
613-
@List = $Self->{CryptObject}->Search();
617+
if ($SMIMEObject) {
618+
@List = $SMIMEObject->Search();
614619
}
615620
$Self->{LayoutObject}->Block(
616621
Name => 'OverviewResult',
@@ -673,24 +678,26 @@ sub _SignerCertificateOverview {
673678
);
674679
}
675680

676-
my @SignerCertResults = $Self->{CryptObject}->PrivateSearch(
681+
my $SMIMEObject = $Kernel::OM->Get('Kernel::System::Crypt::SMIME');
682+
683+
my @SignerCertResults = $SMIMEObject->PrivateSearch(
677684
Search => $Param{CertFingerprint},
678685
);
679686
my %SignerCert;
680687
%SignerCert = %{ $SignerCertResults[0] } if @SignerCertResults;
681688

682689
# get all certificates
683-
my @AvailableCerts = $Self->{CryptObject}->CertificateSearch();
690+
my @AvailableCerts = $SMIMEObject->CertificateSearch();
684691

685692
# get all relations for that certificate @ActualRelations
686-
my @ActualRelations = $Self->{CryptObject}->SignerCertRelationGet(
693+
my @ActualRelations = $SMIMEObject->SignerCertRelationGet(
687694
CertFingerprint => $Param{CertFingerprint},
688695
);
689696

690697
# get needed data from actual relations
691698
my @RelatedCerts;
692699
for my $RelatedCert (@ActualRelations) {
693-
my @Certificate = $Self->{CryptObject}->CertificateSearch(
700+
my @Certificate = $SMIMEObject->CertificateSearch(
694701
Search => $RelatedCert->{CAFingerprint},
695702
);
696703
push @RelatedCerts, $Certificate[0] if $Certificate[0];
@@ -792,7 +799,7 @@ sub _SignerCertificateOverview {
792799
);
793800
}
794801
}
795-
if ( !$Self->{CryptObject} && $Self->{ConfigObject}->Get('SMIME') ) {
802+
if ( !$SMIMEObject && $Self->{ConfigObject}->Get('SMIME') ) {
796803
$Output .= $Self->{LayoutObject}->Notify(
797804
Priority => 'Error',
798805
Data => $Self->{LayoutObject}->{LanguageObject}->Translate( "Cannot create %s!", "CryptObject" ),
@@ -801,10 +808,10 @@ sub _SignerCertificateOverview {
801808
. 'Action=AdminSysConfig;Subaction=Edit;SysConfigGroup=Framework;SysConfigSubGroup=Crypt::SMIME',
802809
);
803810
}
804-
if ( $Self->{CryptObject} && $Self->{CryptObject}->Check() ) {
811+
if ( $SMIMEObject && $SMIMEObject->Check() ) {
805812
$Output .= $Self->{LayoutObject}->Notify(
806813
Priority => 'Error',
807-
Data => $Self->{LayoutObject}->{LanguageObject}->Translate("' . $Self->{CryptObject}->Check() . '"),
814+
Data => $Self->{LayoutObject}->{LanguageObject}->Translate("' . $SMIMEObject->Check() . '"),
808815
);
809816
}
810817

@@ -828,8 +835,10 @@ sub _CertificateRead {
828835
Type => 'Small',
829836
);
830837

838+
my $SMIMEObject = $Kernel::OM->Get('Kernel::System::Crypt::SMIME');
839+
831840
# get the certificate content as plain text
832-
my $CertificateText = $Self->{CryptObject}->CertificateRead(%Param);
841+
my $CertificateText = $SMIMEObject->CertificateRead(%Param);
833842

834843
return if !$CertificateText;
835844

0 commit comments

Comments
 (0)