ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
TraditionalLogoutHandler.php
Go to the documentation of this file.
1 <?php
2 
3 namespace SimpleSAML\IdP;
4 
7 
14 {
15 
21  private $idp;
22 
23 
29  public function __construct(\SimpleSAML_IdP $idp)
30  {
31  $this->idp = $idp;
32  }
33 
34 
42  private function logoutNextSP(array &$state)
43  {
44  $association = array_pop($state['core:LogoutTraditional:Remaining']);
45  if ($association === null) {
46  $this->idp->finishLogout($state);
47  }
48 
49  $relayState = \SimpleSAML_Auth_State::saveState($state, 'core:LogoutTraditional', true);
50 
51  $id = $association['id'];
52  Logger::info('Logging out of '.var_export($id, true).'.');
53 
54  try {
56  $url = call_user_func(array($association['Handler'], 'getLogoutURL'), $idp, $association, $relayState);
58  } catch (\Exception $e) {
59  Logger::warning('Unable to initialize logout to '.var_export($id, true).'.');
60  $this->idp->terminateAssociation($id);
61  $state['core:Failed'] = true;
62 
63  // Try the next SP
64  $this->logoutNextSP($state);
65  assert(false);
66  }
67  }
68 
69 
78  public function startLogout(array &$state, $assocId)
79  {
80  $state['core:LogoutTraditional:Remaining'] = $this->idp->getAssociations();
81 
82  $this->logoutNextSP($state);
83  }
84 
85 
97  public function onResponse($assocId, $relayState, \SimpleSAML_Error_Exception $error = null)
98  {
99  assert(is_string($assocId));
100  assert(is_string($relayState) || $relayState === null);
101 
102  if ($relayState === null) {
103  throw new \SimpleSAML_Error_Exception('RelayState lost during logout.');
104  }
105 
106  $state = \SimpleSAML_Auth_State::loadState($relayState, 'core:LogoutTraditional');
107 
108  if ($error === null) {
109  Logger::info('Logged out of '.var_export($assocId, true).'.');
110  $this->idp->terminateAssociation($assocId);
111  } else {
112  Logger::warning('Error received from '.var_export($assocId, true).' during logout:');
113  $error->logWarning();
114  $state['core:Failed'] = true;
115  }
116 
117  $this->logoutNextSP($state);
118  }
119 }
__construct(\SimpleSAML_IdP $idp)
TraditionalLogout constructor.
static getByState(array &$state)
Retrieve the IdP "owning" the state.
Definition: IdP.php:145
if(!array_key_exists('StateId', $_REQUEST)) $id
logoutNextSP(array &$state)
Picks the next SP and issues a logout request.
static redirectTrustedURL($url, $parameters=array())
This function redirects to the specified URL without performing any security checks.
Definition: HTTP.php:959
if(!array_key_exists('stateid', $_REQUEST)) $state
Handle linkback() response from LinkedIn.
Definition: linkback.php:10
static info($string)
Definition: Logger.php:199
$relayState
static warning($string)
Definition: Logger.php:177
startLogout(array &$state, $assocId)
Start the logout operation.
static loadState($id, $stage, $allowMissing=false)
Retrieve saved state.
Definition: State.php:259
onResponse($assocId, $relayState, \SimpleSAML_Error_Exception $error=null)
Continue the logout operation.
if(!isset($associations[$assocId])) $association
if(!isset($_REQUEST['association'])) $assocId
$url
static saveState(&$state, $stage, $rawId=false)
Save the state.
Definition: State.php:194