File tree Expand file tree Collapse file tree 5 files changed +22
-2
lines changed Expand file tree Collapse file tree 5 files changed +22
-2
lines changed Original file line number Diff line number Diff line change 20
20
use OCP \IL10N ;
21
21
use OCP \ITempManager ;
22
22
use phpseclib3 \File \ASN1 ;
23
+ use Psr \Log \LoggerInterface ;
23
24
24
25
class Pkcs12Handler extends SignEngineHandler {
25
26
use OrderCertificatesTrait;
@@ -37,8 +38,9 @@ public function __construct(
37
38
private IL10N $ l10n ,
38
39
private FooterHandler $ footerHandler ,
39
40
private ITempManager $ tempManager ,
41
+ private LoggerInterface $ logger ,
40
42
) {
41
- parent ::__construct ($ l10n , $ folderService );
43
+ parent ::__construct ($ l10n , $ folderService, $ logger );
42
44
}
43
45
44
46
/**
Original file line number Diff line number Diff line change 22
22
use OCP \Files \NotFoundException ;
23
23
use OCP \Files \NotPermittedException ;
24
24
use OCP \IL10N ;
25
+ use Psr \Log \LoggerInterface ;
25
26
26
27
abstract class SignEngineHandler implements ISignEngineHandler {
27
28
private File $ inputFile ;
@@ -35,6 +36,7 @@ abstract class SignEngineHandler implements ISignEngineHandler {
35
36
public function __construct (
36
37
private IL10N $ l10n ,
37
38
private readonly FolderService $ folderService ,
39
+ private LoggerInterface $ logger ,
38
40
) {
39
41
}
40
42
@@ -217,7 +219,9 @@ public function getLastSignedDate(): \DateTime {
217
219
}
218
220
219
221
// Prevent accepting certificates with future signing dates (possible clock issues)
220
- if ($ last ['signingTime ' ] > new \DateTime ()) {
222
+ $ dateTime = new \DateTime ();
223
+ if ($ last ['signingTime ' ] > $ dateTime ) {
224
+ $ this ->logger ->error ('We found Marty McFly ' , ['last_signature ' => $ last ['signingTime ' ], 'current_date_time ' => $ dateTime ]);
221
225
throw new \UnexpectedValueException ('Invalid signingTime in certificate chain. We found Marty McFly ' );
222
226
}
223
227
Original file line number Diff line number Diff line change 19
19
use OCP \L10N \IFactory as IL10NFactory ;
20
20
use PHPUnit \Framework \Attributes \DataProvider ;
21
21
use PHPUnit \Framework \MockObject \MockObject ;
22
+ use Psr \Log \LoggerInterface ;
22
23
23
24
final class Pkcs12HandlerTest extends \OCA \Libresign \Tests \Unit \TestCase {
24
25
protected Pkcs12Handler $ pkcs12Handler ;
@@ -27,6 +28,7 @@ final class Pkcs12HandlerTest extends \OCA\Libresign\Tests\Unit\TestCase {
27
28
private IL10N $ l10n ;
28
29
private FooterHandler &MockObject $ footerHandler ;
29
30
private ITempManager $ tempManager ;
31
+ private LoggerInterface &MockObject $ logger ;
30
32
private CertificateEngineFactory &MockObject $ certificateEngineFactory ;
31
33
32
34
public function setUp (): void {
@@ -36,6 +38,7 @@ public function setUp(): void {
36
38
$ this ->l10n = \OCP \Server::get (IL10NFactory::class)->get (Application::APP_ID );
37
39
$ this ->footerHandler = $ this ->createMock (FooterHandler::class);
38
40
$ this ->tempManager = \OCP \Server::get (ITempManager::class);
41
+ $ this ->logger = $ this ->createMock (LoggerInterface::class);
39
42
}
40
43
41
44
private function getHandler (array $ methods = []): Pkcs12Handler |MockObject {
@@ -48,6 +51,7 @@ private function getHandler(array $methods = []): Pkcs12Handler|MockObject {
48
51
$ this ->l10n ,
49
52
$ this ->footerHandler ,
50
53
$ this ->tempManager ,
54
+ $ this ->logger ,
51
55
])
52
56
->onlyMethods ($ methods )
53
57
->getMock ();
@@ -59,6 +63,7 @@ private function getHandler(array $methods = []): Pkcs12Handler|MockObject {
59
63
$ this ->l10n ,
60
64
$ this ->footerHandler ,
61
65
$ this ->tempManager ,
66
+ $ this ->logger ,
62
67
);
63
68
}
64
69
Original file line number Diff line number Diff line change 11
11
use OCP \IL10N ;
12
12
use OCP \L10N \IFactory as IL10NFactory ;
13
13
use PHPUnit \Framework \MockObject \MockObject ;
14
+ use Psr \Log \LoggerInterface ;
14
15
15
16
final class Pkcs7HandlerTest extends \OCA \Libresign \Tests \Unit \TestCase {
16
17
private IL10N $ l10n ;
17
18
private FolderService &MockObject $ folderService ;
19
+ private LoggerInterface &MockObject $ logger ;
18
20
public function setUp (): void {
19
21
parent ::setUp ();
20
22
$ this ->l10n = \OCP \Server::get (IL10NFactory::class)->get (\OCA \Libresign \AppInfo \Application::APP_ID );
21
23
$ this ->folderService = $ this ->createMock (\OCA \Libresign \Service \FolderService::class);
24
+ $ this ->logger = $ this ->createMock (LoggerInterface::class);
22
25
}
23
26
24
27
protected function getInstance (array $ methods = []): Pkcs7Handler |MockObject {
25
28
if (empty ($ methods )) {
26
29
return new Pkcs7Handler (
27
30
$ this ->l10n ,
28
31
$ this ->folderService ,
32
+ $ this ->logger ,
29
33
);
30
34
}
31
35
return $ this ->getMockBuilder (Pkcs7Handler::class)
32
36
->setConstructorArgs ([
33
37
$ this ->l10n ,
34
38
$ this ->folderService ,
39
+ $ this ->logger ,
35
40
])
36
41
->onlyMethods ($ methods )
37
42
->getMock ();
Original file line number Diff line number Diff line change 23
23
use OCP \L10N \IFactory as IL10NFactory ;
24
24
use PHPUnit \Framework \Attributes \DataProvider ;
25
25
use PHPUnit \Framework \MockObject \MockObject ;
26
+ use Psr \Log \LoggerInterface ;
26
27
27
28
final class PasswordTest extends \OCA \Libresign \Tests \Unit \TestCase {
28
29
private IdentifyService &MockObject $ identifyService ;
@@ -34,6 +35,7 @@ final class PasswordTest extends \OCA\Libresign\Tests\Unit\TestCase {
34
35
private IL10N $ l10n ;
35
36
private FooterHandler &MockObject $ footerHandler ;
36
37
private ITempManager $ tempManager ;
38
+ private LoggerInterface &MockObject $ logger ;
37
39
38
40
public function setUp (): void {
39
41
$ this ->identifyService = $ this ->createMock (IdentifyService::class);
@@ -44,6 +46,7 @@ public function setUp(): void {
44
46
$ this ->footerHandler = $ this ->createMock (FooterHandler::class);
45
47
$ this ->tempManager = \OCP \Server::get (ITempManager::class);
46
48
$ this ->userSession = $ this ->createMock (IUserSession::class);
49
+ $ this ->logger = $ this ->createMock (LoggerInterface::class);
47
50
$ this ->pkcs12Handler = $ this ->getPkcs12Instance ();
48
51
}
49
52
@@ -67,6 +70,7 @@ private function getPkcs12Instance(array $methods = []) {
67
70
$ this ->l10n ,
68
71
$ this ->footerHandler ,
69
72
$ this ->tempManager ,
73
+ $ this ->logger ,
70
74
])
71
75
->onlyMethods ($ methods )
72
76
->getMock ();
You can’t perform that action at this time.
0 commit comments