Skip to content

Commit 6f79cbc

Browse files
committed
Fix several issues
1 parent 8cca70e commit 6f79cbc

File tree

5 files changed

+14
-17
lines changed

5 files changed

+14
-17
lines changed

src/Type/AnyURIListValue.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use SimpleSAML\SAML2\Assert\Assert;
88
use SimpleSAML\SAML2\Constants as C;
9+
use SimpleSAML\SAML2\Exception\ProtocolViolationException;
910
use SimpleSAML\SAML2\Type\SAMLAnyURIValue;
1011
use SimpleSAML\XMLSchema\Exception\SchemaViolationException;
1112
use SimpleSAML\XMLSchema\Type\Interface\ListTypeInterface;
@@ -33,8 +34,10 @@ class AnyURIListValue extends SAMLAnyURIValue implements ListTypeInterface
3334
*/
3435
protected function validateValue(string $value): void
3536
{
36-
$uris = preg_split('/[\s]+/', $this->sanitizeValue($value), C::UNBOUNDED_LIMIT);
37+
$sanitized = $this->sanitizeValue($value);
38+
Assert::stringNotEmpty($sanitized, ProtocolViolationException::class);
3739

40+
$uris = preg_split('/[\s]+/', $sanitized, C::UNBOUNDED_LIMIT);
3841
Assert::allValidAnyURI($uris, SchemaViolationException::class);
3942
}
4043

src/XML/EncryptedElementTrait.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,14 @@ trait EncryptedElementTrait
3131
* Constructor for encrypted elements.
3232
*
3333
* @param \SimpleSAML\XMLSecurity\XML\xenc\EncryptedData $encryptedData The EncryptedData object.
34-
* @param \SimpleSAML\XMLSecurity\XML\xenc\EncryptedKey[] $decryptionKeys The EncryptedKey objects.
34+
* @param \SimpleSAML\XMLSecurity\XML\xenc\EncryptedKey[] $encryptedKey The EncryptedKey objects.
3535
*/
3636
final public function __construct(
3737
protected EncryptedData $encryptedData,
38-
protected array $decryptionKeys = [],
38+
array $encryptedKey = [],
3939
) {
40-
Assert::allIsInstanceOf($decryptionKeys, EncryptedKey::class, ProtocolViolationException::class);
40+
Assert::allIsInstanceOf($encryptedKey, EncryptedKey::class, ProtocolViolationException::class);
41+
$this->encryptedKey = $encryptedKey;
4142

4243
/**
4344
* 6.2: The <EncryptedData> element's Type attribute SHOULD be used and, if it is
@@ -74,9 +75,9 @@ public function getEncryptionBackend(): ?EncryptionBackend
7475
}
7576

7677

77-
public function getDecryptionKeys(): array
78+
public function getEncryptedKeys(): array
7879
{
79-
return $this->decryptionKeys;
80+
return $this->encryptedKey;
8081
}
8182

8283

@@ -118,7 +119,7 @@ public function toXML(?DOMElement $parent = null): DOMElement
118119
{
119120
$e = $this->instantiateParentElement($parent);
120121
$this->encryptedData->toXML($e);
121-
foreach ($this->getDecryptionKeys() as $key) {
122+
foreach ($this->getEncryptedKeys() as $key) {
122123
$key->toXML($e);
123124
}
124125
return $e;

tests/SAML2/Type/AnyURIListValueTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use PHPUnit\Framework\Attributes\DataProvider;
99
use PHPUnit\Framework\Attributes\Group;
1010
use PHPUnit\Framework\TestCase;
11+
use SimpleSAML\SAML2\Exception\ProtocolViolationException;
1112
use SimpleSAML\SAML2\Type\AnyURIListValue;
1213
use SimpleSAML\XMLSchema\Exception\SchemaViolationException;
1314

@@ -30,7 +31,7 @@ public function testAnyURIList(bool $shouldPass, string $anyURIList): void
3031
try {
3132
AnyURIListValue::fromString($anyURIList);
3233
$this->assertTrue($shouldPass);
33-
} catch (SchemaViolationException $e) {
34+
} catch (ProtocolViolationException|SchemaViolationException $e) {
3435
$this->assertFalse($shouldPass);
3536
}
3637
}
@@ -55,7 +56,7 @@ public static function provideAnyURIList(): array
5556
'single' => [true, "urn:x-simplesamlphp:namespace"],
5657
'multiple' => [true, 'urn:x-simplesamlphp:namespace urn:x-ssp:ns'],
5758
'normalization' => [true, "urn:x-simplesamlphp:namespace \n urn:x-ssp:ns"],
58-
'empty' => [true, ''],
59+
'empty' => [false, ''],
5960
];
6061
}
6162
}

tests/SAML2/XML/md/IDPSSODescriptorTest.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,10 +217,6 @@ public function testMarshallingWithEmptySingleSignOnService(): void
217217
public function testMarshallingWithoutProtocolSupportThrowsException(): void
218218
{
219219
$this->expectException(ProtocolViolationException::class);
220-
$this->expectExceptionMessage(
221-
'SAML v2.0 entities MUST include the SAML protocol namespace URI '
222-
. 'in their protocolSupportEnumeration attribute',
223-
);
224220

225221
new IDPSSODescriptor(
226222
[

tests/resources/xml/saml_EncryptedID.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,5 @@
1818
<xenc:CipherData>
1919
<xenc:CipherValue>he5ZBjtfp/1/Y3PgE/CWspDPADig9vuZ7yZyYXDQ1wA/HBTPCldtL/p6UT5RCAFYUwN6kp3jnHkhK1yMjrI1SMw0n5NEc2wO9N5inQIeQOZ8XD9yD9M5fHvWz2ByNMGlB35RWMnBRHzDi1PRV7Irwcs9WoiODh3i6j2vYXP7cAo=</xenc:CipherValue>
2020
</xenc:CipherData>
21-
<xenc:ReferenceList>
22-
<xenc:DataReference URI="#Encrypted_DATA_ID"/>
23-
</xenc:ReferenceList>
24-
<xenc:CarriedKeyName>Name of the key</xenc:CarriedKeyName>
2521
</xenc:EncryptedKey>
2622
</saml:EncryptedID>

0 commit comments

Comments
 (0)