ResolveEndpointSloAction::getDescriptorType()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 11
rs 10
cc 3
nc 3
nop 1
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\Context\Profile\ProfileContext;
15
use LightSaml\Error\LightSamlContextException;
16
use LightSaml\Model\Metadata\IdpSsoDescriptor;
17
use LightSaml\Model\Metadata\SingleLogoutService;
18
use LightSaml\Model\Metadata\SpSsoDescriptor;
19
20
class ResolveEndpointSloAction extends ResolveEndpointBaseAction
21
{
22
    protected function getServiceType(ProfileContext $context)
23
    {
24
        return SingleLogoutService::class;
25
    }
26
27
    protected function getDescriptorType(ProfileContext $context)
28
    {
29
        $ssoSessionState = $context->getLogoutSsoSessionState();
30
        $ownEntityId = $context->getOwnEntityDescriptor()->getEntityID();
31
32
        if ($ssoSessionState->getIdpEntityId() == $ownEntityId) {
33
            return SpSsoDescriptor::class;
34
        } elseif ($ssoSessionState->getSpEntityId() == $ownEntityId) {
35
            return IdpSsoDescriptor::class;
36
        } else {
37
            throw new LightSamlContextException($context, 'Unable to resolve logout target descriptor type');
38
        }
39
    }
40
}
41