|
6 | 6 |
|
7 | 7 | use SoapInterop\Tests\Support\InteropTestCase; |
8 | 8 | use SoapInterop\Tests\Support\Oracle; |
| 9 | +use Soap\Psr18WsseMiddleware\KeyStore\ClientCertificate; |
9 | 10 | use Soap\Psr18WsseMiddleware\WSSecurity\Outbound; |
| 11 | +use Soap\Psr18WsseMiddleware\WSSecurity\Part; |
10 | 12 | use Soap\Psr18WsseMiddleware\WSSecurity\SecurityProfile; |
11 | 13 | use Soap\Psr18WsseMiddleware\WSSecurity\SoapVersion; |
12 | 14 | use Soap\Psr18WsseMiddleware\WSSecurity\WsseContext; |
@@ -37,6 +39,26 @@ public function test_php_username_token_password_digest_is_accepted_by_wss4j(): |
37 | 39 | self::assertValid($response, 'WSS4J should validate a PasswordDigest UsernameToken'); |
38 | 40 | } |
39 | 41 |
|
| 42 | + /** |
| 43 | + * A signed UsernameToken must reach WSS4J before the ds:Signature that references it: the receiver |
| 44 | + * processes the header top-down and cannot resolve a reference to a token it has not read yet. |
| 45 | + */ |
| 46 | + public function test_php_signed_username_token_is_accepted_by_wss4j(): void |
| 47 | + { |
| 48 | + $document = Document::fromXmlString(Oracle::sampleEnvelope()); |
| 49 | + $context = new WsseContext($document, SoapVersion::Soap12, new SecurityProfile()); |
| 50 | + |
| 51 | + (new Outbound\Timestamp())($context); |
| 52 | + (new Outbound\Username('interop-user', 'interop-secret', false))($context); |
| 53 | + (new Outbound\Signature( |
| 54 | + ClientCertificate::fromFile(Oracle::certPath('php-client.pem')), |
| 55 | + ))->withParts([Part::body(), Part::timestamp(), Part::usernameToken()])($context); |
| 56 | + |
| 57 | + $response = Oracle::post('/verify?ut=true&user=interop-user&pass=interop-secret', $document->toXmlString()); |
| 58 | + |
| 59 | + self::assertValid($response, 'WSS4J should validate a signed UsernameToken'); |
| 60 | + } |
| 61 | + |
40 | 62 | private function phpUsername(bool $digest): string |
41 | 63 | { |
42 | 64 | $document = Document::fromXmlString(Oracle::sampleEnvelope()); |
|
0 commit comments