Skip to content

Commit 609a995

Browse files
committed
example refactored
1 parent 3dc187f commit 609a995

File tree

3 files changed

+26
-39
lines changed

3 files changed

+26
-39
lines changed

examples/config.php

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
use AS2\PartnerInterface;
44

55
// local certificates
6-
// openssl_pkcs12_read(file_get_contents(__DIR__.'/data/phpas2.p12'), $certs, null);
7-
openssl_pkcs12_read(file_get_contents(__DIR__.'/data/key3.pfx'), $certs, 'test');
6+
openssl_pkcs12_read(file_get_contents(__DIR__.'/data/phpas2.p12'), $local, null);
7+
openssl_pkcs12_read(file_get_contents(__DIR__.'/data/key3.pfx'), $key3, 'test');
88

99
return [
1010
'storage_path' => __DIR__.'/tmp/storage',
11-
'log_path' => __DIR__.'/tmp/logs.txt',
12-
// 'log_path' => 'php://stdout',
11+
// 'log_path' => __DIR__.'/tmp/logs.txt',
12+
'log_path' => 'php://stdout',
1313
'partners' => [
1414

1515
// add your partners here ...
@@ -45,7 +45,7 @@
4545
'compression' => true,
4646
'signature_algorithm' => 'sha1',
4747
'encryption_algorithm' => '3des',
48-
'content_transfer_encoding' => 'binary',
48+
// 'content_transfer_encoding' => 'binary',
4949
'mdn_mode' => PartnerInterface::MDN_MODE_SYNC,
5050
'mdn_options' => 'signed-receipt-protocol=optional, pkcs7-signature; signed-receipt-micalg=optional, sha256',
5151
],
@@ -54,44 +54,31 @@
5454
/** @see http://mendelson-e-c.com/as2_software */
5555

5656
'id' => 'mycompanyAS2',
57+
// 'target_url' => 'http://127.0.0.1:8000',
5758
'target_url' => 'http://127.0.0.1:8080/as2/HttpReceiver',
58-
'certificate' => '-----BEGIN CERTIFICATE-----
59-
MIIC0DCCAjkCBEOO/bswDQYJKoZIhvcNAQEFBQAwga4xJjAkBgkqhkiG9w0BCQEWF3Jvc2V0dGFu
60-
ZXRAbWVuZGVsc29uLmRlMQswCQYDVQQGEwJERTEPMA0GA1UECBMGQmVybGluMQ8wDQYDVQQHEwZC
61-
ZXJsaW4xIjAgBgNVBAoTGW1lbmRlbHNvbi1lLWNvbW1lcmNlIEdtYkgxIjAgBgNVBAsTGW1lbmRl
62-
bHNvbi1lLWNvbW1lcmNlIEdtYkgxDTALBgNVBAMTBG1lbmQwHhcNMDUxMjAxMTM0MjE5WhcNMTkw
63-
ODEwMTM0MjE5WjCBrjEmMCQGCSqGSIb3DQEJARYXcm9zZXR0YW5ldEBtZW5kZWxzb24uZGUxCzAJ
64-
BgNVBAYTAkRFMQ8wDQYDVQQIEwZCZXJsaW4xDzANBgNVBAcTBkJlcmxpbjEiMCAGA1UEChMZbWVu
65-
ZGVsc29uLWUtY29tbWVyY2UgR21iSDEiMCAGA1UECxMZbWVuZGVsc29uLWUtY29tbWVyY2UgR21i
66-
SDENMAsGA1UEAxMEbWVuZDCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAvl9YOib23cCSOpkD
67-
DU+NRnMnB1G8AhViieKhw2h33895+IfrkCSaEL3PMi0wn55ddPRgdMi9mOWELU6ITkvSMMsjFgYY
68-
e+1ibQjfK3Tnw9g1te/O+7XvjZaboEb4Onjh+p6fVZ90WTg1ccU8sifKSPFTJ59d2HsjDMO1VWhD
69-
uYUCAwEAATANBgkqhkiG9w0BAQUFAAOBgQC8DiHP61jAADXRIfxoDvw0pFTMMTOVAa905GGy1P+Y
70-
4NC8I92PviobpmEq8Z2HsEi6iviVwODrPTSfm93mUWZ52EPXinlGYHRP0D/VxNOMvFi+mRyweLA5
71-
5rIFWk1PqdJRch9E3vTcjwRtCfPNdPQlynVwk0jeYKtEtQn2J9LLWg==
72-
-----END CERTIFICATE-----
73-
',
59+
'private_key' => isset($key3['pkey']) ? $key3['pkey'] : null,
60+
'certificate' => isset($key3['cert']) ? $key3['cert'] : null,
7461
'content_type' => 'application/EDI-Consent',
7562
'compression' => true,
7663
'signature_algorithm' => 'sha256',
7764
'encryption_algorithm' => '3des',
78-
'content_transfer_encoding' => 'binary',
65+
// 'content_transfer_encoding' => 'binary',
7966
'mdn_mode' => PartnerInterface::MDN_MODE_SYNC,
8067
'mdn_options' => 'signed-receipt-protocol=optional, pkcs7-signature; signed-receipt-micalg=optional, sha256',
8168
],
8269

8370
// local station
8471

8572
[
86-
'id' => 'mycompanyAS2',
73+
'id' => 'phpas2',
8774
'email' => 'phpas2@example.com',
8875
'target_url' => 'http://127.0.0.1:8000',
89-
'certificate' => isset($certs['cert']) ? $certs['cert'] : null,
90-
'private_key' => isset($certs['pkey']) ? $certs['pkey'] : null,
76+
'certificate' => isset($local['cert']) ? $local['cert'] : null,
77+
'private_key' => isset($local['pkey']) ? $local['pkey'] : null,
9178
// 'private_key_pass_phrase' => 'password',
9279
// 'content_type' => 'application/edi-x12',
9380
'content_type' => 'application/EDI-Consent',
94-
'compression' => false,
81+
'compression' => true,
9582
'signature_algorithm' => 'sha256',
9683
'encryption_algorithm' => '3des',
9784
'mdn_mode' => PartnerInterface::MDN_MODE_SYNC,

examples/outbound.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
$rawMessage = <<<MSG
1313
Content-type: Application/EDI-X12
14-
content-disposition: attachment; filename=payload
15-
content-id: <test@test.com>
14+
Content-disposition: attachment; filename=payload
15+
Content-id: <test@test.com>
1616
1717
ISA*00~
1818
MSG;

examples/server.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,25 @@
1212

1313
// $request = ServerRequest::fromGlobals();
1414
// $messageId = trim($request->getHeaderLine('message-id'), '<>');
15-
16-
//if (!$messageId) {
15+
//
16+
// if (!$messageId) {
1717
// throw new \RuntimeException('Message-ID required.');
18-
//}
19-
18+
// }
19+
//
2020
// $headers = '';
2121
// foreach ($request->getHeaders() as $name => $header) {
2222
// $headers .= $name .= ': '.implode(',', $header)."\r\n";
2323
// }
2424
// $headers .= "\r\n";
25-
25+
//
2626
// file_put_contents(__DIR__.'/tmp/data/inbound/'.$messageId.'.raw', $headers.file_get_contents('php://input'));
2727

2828
$server = new Server($manager, $storage);
2929

30-
//$message = file_get_contents('data/inbound/mendelson_opensource_AS2-1514912694550-2@mycompanyAS2_phpas2.raw');
31-
//$payload = \AS2\Utils::parseMessage($message);
32-
33-
//$serverRequest = new ServerRequest(
30+
// $message = file_get_contents(__DIR__ . '/tmp/data/inbound/mendelson_opensource_AS2-1593248663696-1@mycompanyAS2_phpas2.raw');
31+
// $payload = \AS2\Utils::parseMessage($message);
32+
//
33+
// $serverRequest = new ServerRequest(
3434
// 'POST',
3535
// 'http:://localhost',
3636
// $payload['headers'],
@@ -39,8 +39,8 @@
3939
// [
4040
// 'REMOTE_ADDR' => '127.0.0.1'
4141
// ]
42-
//);
43-
//$response = $server->execute($serverRequest);
42+
// );
43+
// $response = $server->execute($serverRequest);
4444

4545
$response = $server->execute();
4646

0 commit comments

Comments
 (0)