|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the LightSAML-Core package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Milos Tomic <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* This source file is subject to the MIT license that is bundled |
|
9
|
|
|
* with this source code in the file LICENSE. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace LightSaml\Action\Profile\Outbound\Message; |
|
13
|
|
|
|
|
14
|
|
|
use LightSaml\Action\Profile\AbstractProfileAction; |
|
15
|
|
|
use LightSaml\Binding\BindingFactoryInterface; |
|
16
|
|
|
use LightSaml\Context\Profile\Helper\LogHelper; |
|
17
|
|
|
use LightSaml\Context\Profile\ProfileContext; |
|
18
|
|
|
use Psr\Log\LoggerInterface; |
|
19
|
|
|
|
|
20
|
|
|
class SendMessageAction extends AbstractProfileAction |
|
21
|
|
|
{ |
|
22
|
|
|
/** @var BindingFactoryInterface */ |
|
23
|
|
|
protected $bindingFactory; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* @param LoggerInterface $logger |
|
27
|
|
|
* @param BindingFactoryInterface $bindingFactory |
|
28
|
|
|
*/ |
|
29
|
3 |
|
public function __construct(LoggerInterface $logger, BindingFactoryInterface $bindingFactory) |
|
30
|
|
|
{ |
|
31
|
3 |
|
parent::__construct($logger); |
|
32
|
|
|
|
|
33
|
3 |
|
$this->bindingFactory = $bindingFactory; |
|
34
|
3 |
|
} |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* @param ProfileContext $context |
|
38
|
|
|
* |
|
39
|
|
|
* @return void |
|
40
|
|
|
*/ |
|
41
|
2 |
|
public function doExecute(ProfileContext $context) |
|
42
|
|
|
{ |
|
43
|
2 |
|
$binding = $this->bindingFactory->create($context->getEndpoint()->getBinding()); |
|
44
|
|
|
|
|
45
|
2 |
|
$outboundContext = $context->getOutboundContext(); |
|
46
|
|
|
|
|
47
|
2 |
|
$context->getHttpResponseContext()->setResponse( |
|
48
|
2 |
|
$binding->send($outboundContext) |
|
|
|
|
|
|
49
|
|
|
); |
|
50
|
|
|
|
|
51
|
2 |
|
$this->logger->info( |
|
52
|
2 |
|
'Sending message', |
|
53
|
2 |
|
LogHelper::getActionContext($context, $this, array( |
|
54
|
2 |
|
'message' => $outboundContext->getSerializationContext()->getDocument()->saveXML(), |
|
55
|
|
|
)) |
|
56
|
|
|
); |
|
57
|
2 |
|
} |
|
58
|
|
|
} |
|
59
|
|
|
|
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: