-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
182 additions
and
0 deletions.
There are no files selected for viewing
98 changes: 98 additions & 0 deletions
98
src/LightSaml/Logout/Action/Profile/Outbound/LogoutRequest/ResolveLogoutPartyAction.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the LightSAML-Logout package. | ||
* | ||
* (c) Milos Tomic <[email protected]> | ||
* | ||
* This source file is subject to the GPL-3 license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace LightSaml\Logout\Action\Profile\Outbound\LogoutRequest; | ||
|
||
use LightSaml\Action\Profile\AbstractProfileAction; | ||
use LightSaml\Context\Profile\ProfileContext; | ||
use LightSaml\Error\LightSamlContextException; | ||
use LightSaml\Meta\TrustOptions\TrustOptions; | ||
use LightSaml\Store\EntityDescriptor\EntityDescriptorStoreInterface; | ||
use LightSaml\Store\TrustOptions\TrustOptionsStoreInterface; | ||
|
||
class ResolveLogoutPartyAction extends AbstractProfileAction | ||
{ | ||
/** @var EntityDescriptorStoreInterface */ | ||
private $idpEntityDescriptorStore; | ||
|
||
/** @var EntityDescriptorStoreInterface */ | ||
private $spEntityDescriptorStore; | ||
|
||
/** @var TrustOptionsStoreInterface */ | ||
protected $trustOptionsProvider; | ||
|
||
/** | ||
* @param EntityDescriptorStoreInterface $idpEntityDescriptorStore | ||
* @param EntityDescriptorStoreInterface $spEntityDescriptorStore | ||
* @param TrustOptionsStoreInterface $trustOptionsProvider | ||
*/ | ||
public function __construct( | ||
EntityDescriptorStoreInterface $idpEntityDescriptorStore, | ||
EntityDescriptorStoreInterface $spEntityDescriptorStore, | ||
TrustOptionsStoreInterface $trustOptionsProvider | ||
) { | ||
$this->idpEntityDescriptorStore = $idpEntityDescriptorStore; | ||
$this->spEntityDescriptorStore = $spEntityDescriptorStore; | ||
$this->trustOptionsProvider = $trustOptionsProvider; | ||
} | ||
|
||
/** | ||
* @param ProfileContext $context | ||
*/ | ||
protected function doExecute(ProfileContext $context) | ||
{ | ||
$partyContext = $context->getPartyEntityContext(); | ||
|
||
$partyEntityDescriptor = $this->getPartyEntityDescriptor($context); | ||
$partyContext | ||
->setEntityId($partyEntityDescriptor->getEntityID()) | ||
->setEntityDescriptor($partyEntityDescriptor); | ||
|
||
$trustOptions = $this->trustOptionsProvider->get($partyContext->getEntityDescriptor()->getEntityID()); | ||
if (null === $trustOptions) { | ||
$trustOptions = new TrustOptions(); | ||
} | ||
$partyContext->setTrustOptions($trustOptions); | ||
} | ||
|
||
private function getPartyEntityDescriptor(ProfileContext $context) | ||
{ | ||
$ssoSessionState = $context->getLogoutSsoSessionState(); | ||
$ownEntityId = $context->getOwnEntityDescriptor()->getEntityID(); | ||
$partyId = $ssoSessionState->getOtherPartyId($ownEntityId); | ||
|
||
$partyEntityDescriptor = $this->findParty($partyId, [$this->idpEntityDescriptorStore, $this->spEntityDescriptorStore]); | ||
|
||
if ($partyEntityDescriptor) { | ||
return $partyEntityDescriptor; | ||
} | ||
|
||
throw new LightSamlContextException($context, sprintf('Unknown party "%s"', $partyId)); | ||
} | ||
|
||
/** | ||
* @param string $entityId | ||
* @param EntityDescriptorStoreInterface[] $entityDescriptorStores | ||
* | ||
* @return \LightSaml\Model\Metadata\EntityDescriptor|null | ||
*/ | ||
private function findParty($entityId, array $entityDescriptorStores) | ||
{ | ||
foreach ($entityDescriptorStores as $entityDescriptorStore) { | ||
$entityDescriptor = $entityDescriptorStore->get($entityId); | ||
if ($entityDescriptor) { | ||
return $entityDescriptor; | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/LightSaml/Logout/Builder/Profile/WebBrowserSlo/SloRequestProfileBuilder.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the LightSAML-Logout package. | ||
* | ||
* (c) Milos Tomic <[email protected]> | ||
* | ||
* This source file is subject to the GPL-3 license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace LightSaml\Logout\Builder\Profile\WebBrowserSlo; | ||
|
||
use LightSaml\Builder\Profile\AbstractProfileBuilder; | ||
use LightSaml\Context\Profile\ProfileContext; | ||
use LightSaml\Logout\Builder\Action\Profile\SingleLogout\SloRequestActionBuilder; | ||
use LightSaml\Logout\Profile\Profiles; | ||
|
||
class SloRequestProfileBuilder extends AbstractProfileBuilder | ||
{ | ||
/** | ||
* @return string | ||
*/ | ||
protected function getProfileId() | ||
{ | ||
return Profiles::SLO_SEND_LOGOUT_REQUEST; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
protected function getProfileRole() | ||
{ | ||
return ProfileContext::ROLE_NONE; | ||
} | ||
|
||
/** | ||
* @return \LightSaml\Builder\Action\ActionBuilderInterface | ||
*/ | ||
protected function getActionBuilder() | ||
{ | ||
return new SloRequestActionBuilder($this->container); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the LightSAML-Logout package. | ||
* | ||
* (c) Milos Tomic <[email protected]> | ||
* | ||
* This source file is subject to the GPL-3 license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace LightSaml\Logout\Profile; | ||
|
||
class Profiles | ||
{ | ||
const SLO_SEND_LOGOUT_REQUEST = 'slo_send_logout_request'; | ||
|
||
private function __construct() | ||
{ | ||
} | ||
} |