Skip to content

Commit e41f71c

Browse files
committed
Updated safety for final classes. Updated CI processes.
1 parent 09000d8 commit e41f71c

File tree

8 files changed

+67
-39
lines changed

8 files changed

+67
-39
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ jobs:
2222
phpstan:
2323
name: PHPStan
2424
runs-on: ubuntu-latest
25-
# This workflow is only of value to the andrew-svirin/ebics-client-php repository and
25+
# This workflow is only of value to the ebics-api/ebics-client-php repository and
2626
# would always fail in forks
27-
if: github.repository == 'andrew-svirin/ebics-client-php'
27+
if: github.repository == 'ebics-api/ebics-client-php'
2828
steps:
2929
- uses: actions/checkout@v2
3030
- name: Setup PHP
@@ -40,9 +40,9 @@ jobs:
4040
phpcs:
4141
name: PHPCS
4242
runs-on: ubuntu-latest
43-
# This workflow is only of value to the andrew-svirin/ebics-client-php repository and
43+
# This workflow is only of value to the ebics-api/ebics-client-php repository and
4444
# would always fail in forks
45-
if: github.repository == 'andrew-svirin/ebics-client-php'
45+
if: github.repository == 'ebics-api/ebics-client-php'
4646
steps:
4747
- uses: actions/checkout@v2
4848
- name: Setup PHP
@@ -58,9 +58,9 @@ jobs:
5858
phpunit:
5959
name: PHPUnit
6060
runs-on: ubuntu-latest
61-
# This workflow is only of value to the andrew-svirin/ebics-client-php repository and
61+
# This workflow is only of value to ebics-api/ebics-client-php repository and
6262
# would always fail in forks
63-
if: github.repository == 'andrew-svirin/ebics-client-php'
63+
if: github.repository == 'ebics-api/ebics-client-php'
6464
steps:
6565
- uses: actions/checkout@v2
6666
- name: Setup PHP

src/Models/CertificateX509.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* @license http://www.opensource.org/licenses/mit-license.html MIT License
1212
* @author Andrew Svirin
1313
*/
14-
class CertificateX509 extends X509
14+
final class CertificateX509 extends X509
1515
{
1616
/**
1717
* Get Certificate serialNumber.

src/Models/Crypt/X509.php

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ class X509 implements X509Interface
150150
/**
151151
* Default Constructor.
152152
*/
153-
public function __construct()
153+
final public function __construct()
154154
{
155155
// Explicitly Tagged Module, 1988 Syntax
156156
// http://tools.ietf.org/html/rfc5280#appendix-A.1
@@ -832,31 +832,31 @@ public function __construct()
832832
];
833833
}
834834

835-
public function saveX509CurrentCert()
835+
final public function saveX509CurrentCert()
836836
{
837837
return $this->saveX509($this->currentCert);
838838
}
839839

840-
public function setStartDate($date)
840+
final public function setStartDate($date)
841841
{
842842
$date = new DateTime($date, new DateTimeZone(@date_default_timezone_get()));
843843

844844
$this->startDate = $date->format('D, d M Y H:i:s O');
845845
}
846846

847-
public function setEndDate($date)
847+
final public function setEndDate($date)
848848
{
849849
$date = new DateTime($date, new DateTimeZone(@date_default_timezone_get()));
850850

851851
$this->endDate = $date->format('D, d M Y H:i:s O');
852852
}
853853

854-
public function setSerialNumber($serial, $base = -256)
854+
final public function setSerialNumber($serial, $base = -256)
855855
{
856856
$this->serialNumber = new BigInteger($serial, $base);
857857
}
858858

859-
public function sign(
859+
final public function sign(
860860
$issuer,
861861
$subject,
862862
$signatureAlgorithm = 'sha1WithRSAEncryption'
@@ -988,7 +988,7 @@ public function sign(
988988
return $result;
989989
}
990990

991-
public function loadX509($cert)
991+
final public function loadX509($cert)
992992
{
993993
$asn1 = new ASN1();
994994

@@ -1067,7 +1067,7 @@ private function removeExtension(string $id, string $path = null): bool
10671067
return $result;
10681068
}
10691069

1070-
public function saveX509($cert)
1070+
final public function saveX509($cert)
10711071
{
10721072
if (!is_array($cert) || !isset($cert['tbsCertificate'])) {
10731073
return false;
@@ -1134,13 +1134,13 @@ public function saveX509($cert)
11341134
'-----END CERTIFICATE-----';
11351135
}
11361136

1137-
public function setPublicKey($key)
1137+
final public function setPublicKey($key)
11381138
{
11391139
$key->setPublicKey();
11401140
$this->publicKey = $key;
11411141
}
11421142

1143-
public function getPublicKey(): ?RSAInterface
1143+
final public function getPublicKey(): ?RSAInterface
11441144
{
11451145
if (isset($this->publicKey)) {
11461146
return $this->publicKey;
@@ -1178,17 +1178,17 @@ public function getPublicKey(): ?RSAInterface
11781178
return $publicKey;
11791179
}
11801180

1181-
public function setPrivateKey($key)
1181+
final public function setPrivateKey($key)
11821182
{
11831183
$this->privateKey = $key;
11841184
}
11851185

1186-
public function getPrivateKey(): ?RSAInterface
1186+
final public function getPrivateKey(): ?RSAInterface
11871187
{
11881188
return $this->privateKey;
11891189
}
11901190

1191-
public function setDN($dn, $type = 'utf8String'): bool
1191+
final public function setDN($dn, $type = 'utf8String'): bool
11921192
{
11931193
$this->dn = null;
11941194

@@ -1227,20 +1227,20 @@ public function setDN($dn, $type = 'utf8String'): bool
12271227
return true;
12281228
}
12291229

1230-
public function getDN()
1230+
final public function getDN()
12311231
{
12321232
return is_array($this->currentCert) && isset($this->currentCert['tbsCertList']) ?
12331233
$this->currentCert['tbsCertList']['issuer'] : $this->dn;
12341234
}
12351235

1236-
public function setDomain()
1236+
final public function setDomain()
12371237
{
12381238
$this->domains = func_get_args();
12391239
$this->removeDNProp('id-at-commonName');
12401240
$this->setDNProp('id-at-commonName', $this->domains[0]);
12411241
}
12421242

1243-
public function setKeyIdentifier($value)
1243+
final public function setKeyIdentifier($value)
12441244
{
12451245
if (empty($value)) {
12461246
unset($this->currentKeyIdentifier);
@@ -1249,7 +1249,7 @@ public function setKeyIdentifier($value)
12491249
}
12501250
}
12511251

1252-
public function computeKeyIdentifier($key = null): string
1252+
final public function computeKeyIdentifier($key = null): string
12531253
{
12541254
if (is_null($key)) {
12551255
$key = $this;
@@ -1273,7 +1273,7 @@ public function computeKeyIdentifier($key = null): string
12731273
return $hash;
12741274
}
12751275

1276-
public function formatSubjectPublicKey(): ?array
1276+
final public function formatSubjectPublicKey(): ?array
12771277
{
12781278
if ($this->publicKey instanceof RSAInterface) {
12791279
// the following two return statements do the same thing. i dunno.. i just prefer the later for some reason.
@@ -1332,7 +1332,7 @@ private function timeField(string $date): array
13321332
}
13331333
}
13341334

1335-
public function getAttribute($id, $disposition = self::ATTR_ALL, $csr = null)
1335+
final public function getAttribute($id, $disposition = self::ATTR_ALL, $csr = null)
13361336
{
13371337
if (empty($csr)) {
13381338
$csr = $this->currentCert;
@@ -1528,7 +1528,7 @@ private function reformatKey(string $algorithm, string $key): string
15281528
}
15291529
}
15301530

1531-
public function setExtension($id, $value, $critical = false, $replace = true, string $path = null): bool
1531+
final public function setExtension($id, $value, $critical = false, $replace = true, string $path = null): bool
15321532
{
15331533
$extensions = &$this->extensions($this->currentCert, $path, true);
15341534

@@ -1853,7 +1853,7 @@ private function removeDNProp(string $propName)
18531853
}
18541854
}
18551855

1856-
public function getIssuerDNProp($propName, $withType = false)
1856+
final public function getIssuerDNProp($propName, $withType = false)
18571857
{
18581858
switch (true) {
18591859
case !isset($this->currentCert) || !is_array($this->currentCert):

src/Models/X509/BankX509Generator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* @license http://www.opensource.org/licenses/mit-license.html MIT License
1212
* @author Andrew Svirin
1313
*/
14-
final class BankX509Generator extends AbstractX509Generator
14+
final class BankX509Generator extends X509Generator
1515
{
1616
/**
1717
* Set certificate options by Bank.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* @license http://www.opensource.org/licenses/mit-license.html MIT License
2020
* @author Guillaume Sainthillier, Andrew Svirin
2121
*/
22-
abstract class AbstractX509Generator implements X509GeneratorInterface
22+
abstract class X509Generator implements X509GeneratorInterface
2323
{
2424
private DateTimeInterface $x509StartDate;
2525
private DateTimeInterface $x509EndDate;

tests/EbicsClientV25Test.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,6 @@ public function testHPB(int $credentialsId, array $codes)
215215
*/
216216
public function testSPR(int $credentialsId, array $codes)
217217
{
218-
$this->markTestSkipped('Avoid keyring suspension.');
219-
220218
$client = $this->setupClientV25($credentialsId, $codes['SPR']['fake']);
221219

222220
$this->assertExceptionCode($codes['SPR']['code']);
@@ -1079,7 +1077,7 @@ public function serversDataProvider()
10791077
'HIA' => ['code' => null, 'fake' => false],
10801078
'H3K' => ['code' => null, 'fake' => false],
10811079
'HPB' => ['code' => null, 'fake' => false],
1082-
'SPR' => ['code' => null, 'fake' => false],
1080+
'SPR' => ['code' => null, 'fake' => true],
10831081
'HPD' => ['code' => null, 'fake' => false],
10841082
'HKD' => ['code' => null, 'fake' => false],
10851083
'HTD' => ['code' => null, 'fake' => false],
@@ -1124,7 +1122,7 @@ public function serversDataProvider()
11241122
'HIA' => ['code' => null, 'fake' => false],
11251123
'H3K' => ['code' => null, 'fake' => false],
11261124
'HPB' => ['code' => null, 'fake' => false],
1127-
'SPR' => ['code' => null, 'fake' => false],
1125+
'SPR' => ['code' => null, 'fake' => true],
11281126
'HPD' => ['code' => null, 'fake' => false],
11291127
'HKD' => ['code' => null, 'fake' => false],
11301128
'HTD' => ['code' => null, 'fake' => false],
@@ -1170,7 +1168,7 @@ public function serversDataProvider()
11701168
'HIA' => ['code' => null, 'fake' => false],
11711169
'H3K' => ['code' => null, 'fake' => false],
11721170
'HPB' => ['code' => null, 'fake' => false],
1173-
'SPR' => ['code' => null, 'fake' => false],
1171+
'SPR' => ['code' => null, 'fake' => true],
11741172
'HPD' => ['code' => null, 'fake' => false],
11751173
'HKD' => ['code' => null, 'fake' => false],
11761174
'HTD' => ['code' => null, 'fake' => false],
@@ -1215,7 +1213,7 @@ public function serversDataProvider()
12151213
'HIA' => ['code' => null, 'fake' => false],
12161214
'H3K' => ['code' => null, 'fake' => false],
12171215
'HPB' => ['code' => null, 'fake' => false],
1218-
'SPR' => ['code' => null, 'fake' => false],
1216+
'SPR' => ['code' => null, 'fake' => true],
12191217
'HPD' => ['code' => null, 'fake' => false],
12201218
'HKD' => ['code' => null, 'fake' => false],
12211219
'HTD' => ['code' => null, 'fake' => false],
@@ -1260,7 +1258,7 @@ public function serversDataProvider()
12601258
'HIA' => ['code' => null, 'fake' => false],
12611259
'H3K' => ['code' => null, 'fake' => false],
12621260
'HPB' => ['code' => null, 'fake' => false],
1263-
'SPR' => ['code' => null, 'fake' => false],
1261+
'SPR' => ['code' => null, 'fake' => true],
12641262
'HPD' => ['code' => null, 'fake' => false],
12651263
'HKD' => ['code' => null, 'fake' => false],
12661264
'HTD' => ['code' => null, 'fake' => false],

tests/EbicsClientV30Test.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -942,7 +942,7 @@ public function serversDataProvider()
942942
'HEV' => ['code' => null, 'fake' => false],
943943
'INI' => ['code' => null, 'fake' => false],
944944
'HIA' => ['code' => null, 'fake' => false],
945-
'SPR' => ['code' => null, 'fake' => false],
945+
'SPR' => ['code' => null, 'fake' => true],
946946
'H3K' => ['code' => null, 'fake' => false],
947947
'HPB' => ['code' => null, 'fake' => false],
948948
'HKD' => ['code' => null, 'fake' => false],
@@ -972,7 +972,7 @@ public function serversDataProvider()
972972
'HEV' => ['code' => null, 'fake' => false],
973973
'INI' => ['code' => null, 'fake' => false],
974974
'HIA' => ['code' => null, 'fake' => false],
975-
'SPR' => ['code' => null, 'fake' => false],
975+
'SPR' => ['code' => null, 'fake' => true],
976976
'HPB' => ['code' => null, 'fake' => false],
977977
'HKD' => ['code' => null, 'fake' => false],
978978
'HVU' => ['code' => '090003', 'fake' => false],

tests/_fixtures/spr.xml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ebicsResponse xmlns="urn:org:ebics:H004" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Version="H004" Revision="1" xsi:schemaLocation="urn:org:ebics:H004 ebics_response_H004.xsd">
3+
<header authenticate="true">
4+
<static/>
5+
<mutable>
6+
<TransactionPhase>Initialisation</TransactionPhase>
7+
<OrderID>N00H</OrderID>
8+
<ReturnCode>000000</ReturnCode>
9+
<ReportText>[EBICS_OK] OK</ReportText>
10+
</mutable>
11+
</header>
12+
<AuthSignature>
13+
<ds:SignedInfo>
14+
<ds:CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
15+
<ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/>
16+
<ds:Reference URI="#xpointer(//*[@authenticate='true'])">
17+
<ds:Transforms>
18+
<ds:Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
19+
</ds:Transforms>
20+
<ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
21+
<ds:DigestValue>VAdswYY2sfaZpgvCXgAc0czpDfoYer36xs/kDBUoSc8=</ds:DigestValue>
22+
</ds:Reference>
23+
</ds:SignedInfo>
24+
<ds:SignatureValue>Zclq6omfrN9vLUsUgfQybFFnAUoR2y2fXMLs6/qk4VQaxZY8JdP+XhwVYZX1IJz6wwfhdlQP8lpQfJZyyrziv4fnrRNjfWQooP4zL/Gubom6CAjzhZAowv0ORBFHqjh0WTNoUnzCxKbqSaPpptB/seO/preJ2ddkECnjC3jM3+M41W1ga4uiv1FzxHl79LvhmhALjSxRVDwNJX6pK8JmNqYtsbk5KM5Hwdyjzm1OwJnq/HTrX36llhkdU+mwCh2YFZzU4qoybNgIsYmEClV3wYi759xmQ88alHforXHQztG2DtguA4HJaBEw+4ElCT5ZNPt/rpZt59WRgIWpaaHAsA==</ds:SignatureValue>
25+
</AuthSignature>
26+
<body>
27+
<ReturnCode authenticate="true">000000</ReturnCode>
28+
<TimestampBankParameter authenticate="true">2021-09-27T19:03:59.709Z</TimestampBankParameter>
29+
</body>
30+
</ebicsResponse>

0 commit comments

Comments
 (0)