ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
TraditionalLogoutHandler.php
Go to the documentation of this file.
1 <?php
2 
3 namespace SimpleSAML\IdP;
4 
7 
8 
15 {
16 
22  private $idp;
23 
24 
30  public function __construct(\SimpleSAML_IdP $idp)
31  {
32  $this->idp = $idp;
33  }
34 
35 
43  private function logoutNextSP(array &$state)
44  {
45  $association = array_pop($state['core:LogoutTraditional:Remaining']);
46  if ($association === null) {
47  $this->idp->finishLogout($state);
48  }
49 
50  $relayState = \SimpleSAML_Auth_State::saveState($state, 'core:LogoutTraditional', true);
51 
52  $id = $association['id'];
53  Logger::info('Logging out of '.var_export($id, true).'.');
54 
55  try {
57  $url = call_user_func(array($association['Handler'], 'getLogoutURL'), $idp, $association, $relayState);
59  } catch (\Exception $e) {
60  Logger::warning('Unable to initialize logout to '.var_export($id, true).'.');
61  $this->idp->terminateAssociation($id);
62  $state['core:Failed'] = true;
63 
64  // Try the next SP
65  $this->logoutNextSP($state);
66  assert('FALSE');
67  }
68  }
69 
70 
79  public function startLogout(array &$state, $assocId)
80  {
81  $state['core:LogoutTraditional:Remaining'] = $this->idp->getAssociations();
82 
83  self::logoutNextSP($state);
84  }
85 
86 
99  {
100  assert('is_string($assocId)');
101  assert('is_string($relayState) || is_null($relayState)');
102 
103  if ($relayState === null) {
104  throw new \SimpleSAML_Error_Exception('RelayState lost during logout.');
105  }
106 
107  $state = \SimpleSAML_Auth_State::loadState($relayState, 'core:LogoutTraditional');
108 
109  if ($error === null) {
110  Logger::info('Logged out of '.var_export($assocId, true).'.');
111  $this->idp->terminateAssociation($assocId);
112  } else {
113  Logger::warning('Error received from '.var_export($assocId, true).' during logout:');
114  $error->logWarning();
115  $state['core:Failed'] = true;
116  }
117 
118  self::logoutNextSP($state);
119  }
120 }
__construct(\SimpleSAML_IdP $idp)
TraditionalLogout constructor.
static getByState(array &$state)
Retrieve the IdP "owning" the state.
Definition: IdP.php:152
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:962
if(!array_key_exists('stateid', $_REQUEST)) $state
Handle linkback() response from LinkedIn.
Definition: linkback.php:10
$error
Definition: Error.php:17
static info($string)
Definition: Logger.php:201
$relayState
static warning($string)
Definition: Logger.php:179
startLogout(array &$state, $assocId)
Start the logout operation.
static loadState($id, $stage, $allowMissing=false)
Retrieve saved state.
Definition: State.php:259
Create styles array
The data for the language used.
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