-
Notifications
You must be signed in to change notification settings - Fork 135
/
logoutrequest.php
39 lines (32 loc) · 1.33 KB
/
logoutrequest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env php
<?php
require_once(dirname(__FILE__, 3) . '/vendor/autoload.php');
use DateTimeImmutable;
use DateTimeZone;
use SimpleSAML\SAML2\Compat\ContainerSingleton;
use SimpleSAML\SAML2\Compat\MockContainer;
use SimpleSAML\SAML2\XML\saml\EncryptedID;
use SimpleSAML\SAML2\XML\saml\Issuer;
use SimpleSAML\SAML2\XML\saml\NameID;
use SimpleSAML\SAML2\XML\samlp\LogoutRequest;
use SimpleSAML\SAML2\XML\samlp\SessionIndex;
use SimpleSAML\XMLSecurity\Alg\KeyTransport\KeyTransportAlgorithmFactory;
use SimpleSAML\XMLSecurity\Constants as C;
use SimpleSAML\XMLSecurity\TestUtils\PEMCertificatesMock;
$container = new MockContainer();
$container->setBlacklistedAlgorithms(null);
ContainerSingleton::setContainer($container);
$encryptor = (new KeyTransportAlgorithmFactory())->getAlgorithm(
C::KEY_TRANSPORT_OAEP,
PEMCertificatesMock::getPublicKey(PEMCertificatesMock::SELFSIGNED_PUBLIC_KEY)
);
$nid = new NameID('very secret');
$eid = new EncryptedID($nid->encrypt($encryptor));
$logoutRequest = new LogoutRequest(
identifier: $eid,
issueInstant: new DateTimeImmutable('now', new DateTimeZone('Z')),
sessionIndexes: [new SessionIndex('SomeSessionIndex1'), new SessionIndex('SomeSessionIndex2')],
issuer: new Issuer('urn:test:TheIssuer')
);
$logoutRequest = $logoutRequest->toXML();
echo $logoutRequest->ownerDocument->saveXML();