Skip to content

Commit c07827f

Browse files
committed
Cover a signed UsernameToken in the PHP -> WSS4J direction
Pins that the token reaches the peer before the signature referencing it.
1 parent 0bbd523 commit c07827f

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

tests/Wsse/UsernameTokenInteropTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66

77
use SoapInterop\Tests\Support\InteropTestCase;
88
use SoapInterop\Tests\Support\Oracle;
9+
use Soap\Psr18WsseMiddleware\KeyStore\ClientCertificate;
910
use Soap\Psr18WsseMiddleware\WSSecurity\Outbound;
11+
use Soap\Psr18WsseMiddleware\WSSecurity\Part;
1012
use Soap\Psr18WsseMiddleware\WSSecurity\SecurityProfile;
1113
use Soap\Psr18WsseMiddleware\WSSecurity\SoapVersion;
1214
use Soap\Psr18WsseMiddleware\WSSecurity\WsseContext;
@@ -37,6 +39,26 @@ public function test_php_username_token_password_digest_is_accepted_by_wss4j():
3739
self::assertValid($response, 'WSS4J should validate a PasswordDigest UsernameToken');
3840
}
3941

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+
4062
private function phpUsername(bool $digest): string
4163
{
4264
$document = Document::fromXmlString(Oracle::sampleEnvelope());

0 commit comments

Comments
 (0)