-
Notifications
You must be signed in to change notification settings - Fork 135
/
encryptedattribute.php
29 lines (24 loc) · 1.02 KB
/
encryptedattribute.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
#!/usr/bin/env php
<?php
require_once(dirname(__FILE__, 3) . '/vendor/autoload.php');
use SimpleSAML\SAML2\Compat\ContainerSingleton;
use SimpleSAML\SAML2\Compat\MockContainer;
use SimpleSAML\SAML2\XML\saml\Attribute;
use SimpleSAML\SAML2\XML\saml\AttributeValue;
use SimpleSAML\SAML2\XML\saml\EncryptedAttribute;
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::PUBLIC_KEY)
);
$attribute = new Attribute(
name: 'urn:encrypted:attribute',
attributeValue: [new AttributeValue('very secret data')],
);
$encAttribute = new EncryptedAttribute($attribute->encrypt($encryptor));
echo $encAttribute->toXML()->ownerDocument->saveXML();