1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the LightSAML-IDP package. |
5
|
|
|
* |
6
|
|
|
* (c) Milos Tomic <[email protected]> |
7
|
|
|
* |
8
|
|
|
* This source file is subject to the GPL-3 license that is bundled |
9
|
|
|
* with this source code in the file LICENSE. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace LightSaml\Idp\Action\Assertion\Outbound; |
13
|
|
|
|
14
|
|
|
use LightSaml\Action\Assertion\AbstractAssertionAction; |
15
|
|
|
use LightSaml\Context\Profile\AssertionContext; |
16
|
|
|
use LightSaml\Model\Assertion\AttributeStatement; |
17
|
|
|
use LightSaml\Provider\Attribute\AttributeValueProviderInterface; |
18
|
|
|
use Psr\Log\LoggerInterface; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Creates AttributeStatement and sets attribute values provided by given attribute value provider. |
22
|
|
|
*/ |
23
|
|
|
class AttributeAction extends AbstractAssertionAction |
24
|
|
|
{ |
25
|
|
|
/** @var AttributeValueProviderInterface */ |
26
|
|
|
protected $attributeValueProvider; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @param LoggerInterface $logger |
30
|
|
|
* @param AttributeValueProviderInterface $attributeValueProvider |
31
|
|
|
*/ |
32
|
|
|
public function __construct(LoggerInterface $logger, AttributeValueProviderInterface $attributeValueProvider) |
33
|
|
|
{ |
34
|
|
|
parent::__construct($logger); |
35
|
|
|
|
36
|
|
|
$this->attributeValueProvider = $attributeValueProvider; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @param AssertionContext $context |
41
|
|
|
* |
42
|
|
|
* @return void |
43
|
|
|
*/ |
44
|
|
|
protected function doExecute(AssertionContext $context) |
45
|
|
|
{ |
46
|
|
|
$attributes = $this->attributeValueProvider->getValues($context); |
47
|
|
|
if ($attributes) { |
|
|
|
|
48
|
|
|
$attributeStatement = new AttributeStatement(); |
49
|
|
|
$context->getAssertion()->addItem($attributeStatement); |
50
|
|
|
foreach ($attributes as $attribute) { |
51
|
|
|
$attributeStatement->addAttribute($attribute); |
52
|
|
|
} |
53
|
|
|
} |
54
|
|
|
} |
55
|
|
|
} |
56
|
|
|
|
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)
or! empty(...)
instead.