ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
IFrameLogoutHandler.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 
40  public function startLogout(array &$state, $assocId)
41  {
42  assert(is_string($assocId) || $assocId === null);
43 
44  $associations = $this->idp->getAssociations();
45 
46  if (count($associations) === 0) {
47  $this->idp->finishLogout($state);
48  }
49 
50  foreach ($associations as $id => &$association) {
52  $association['core:Logout-IFrame:Name'] = $idp->getSPName($id);
53  $association['core:Logout-IFrame:State'] = 'onhold';
54  }
55  $state['core:Logout-IFrame:Associations'] = $associations;
56 
57  if (!is_null($assocId)) {
58  $spName = $this->idp->getSPName($assocId);
59  if ($spName === null) {
60  $spName = array('en' => $assocId);
61  }
62 
63  $state['core:Logout-IFrame:From'] = $spName;
64  } else {
65  $state['core:Logout-IFrame:From'] = null;
66  }
67 
68  $params = array(
69  'id' => \SimpleSAML_Auth_State::saveState($state, 'core:Logout-IFrame'),
70  );
71  if (isset($state['core:Logout-IFrame:InitType'])) {
72  $params['type'] = $state['core:Logout-IFrame:InitType'];
73  }
74 
75  $url = Module::getModuleURL('core/idp/logout-iframe.php', $params);
77  }
78 
79 
89  public function onResponse($assocId, $relayState, \SimpleSAML_Error_Exception $error = null)
90  {
91  assert(is_string($assocId));
92 
93  $spId = sha1($assocId);
94  $this->idp->terminateAssociation($assocId);
95 
96  $header = <<<HEADER
97 <!DOCTYPE html>
98 <html>
99  <head>
100  <title>Logout response from %s</title>
101  <script>
102 HEADER;
103  printf($header, htmlspecialchars(var_export($assocId, true)));
104  if ($error) {
105  $errorMsg = $error->getMessage();
106  echo('window.parent.logoutFailed("'.$spId.'", "'.addslashes($errorMsg).'");');
107  } else {
108  echo('window.parent.logoutCompleted("'.$spId.'");');
109  }
110  echo <<<FOOTER
111  </script>
112  </head>
113  <body>
114  </body>
115 </html>
116 FOOTER;
117  exit(0);
118  }
119 }
static getByState(array &$state)
Retrieve the IdP "owning" the state.
Definition: IdP.php:145
onResponse($assocId, $relayState, \SimpleSAML_Error_Exception $error=null)
Continue the logout operation.
if(!array_key_exists('StateId', $_REQUEST)) $id
static redirectTrustedURL($url, $parameters=array())
This function redirects to the specified URL without performing any security checks.
Definition: HTTP.php:959
static getModuleURL($resource, array $parameters=array())
Get absolute URL to a specified module resource.
Definition: Module.php:220
if(!array_key_exists('stateid', $_REQUEST)) $state
Handle linkback() response from LinkedIn.
Definition: linkback.php:10
$relayState
exit
Definition: backend.php:16
if(!isset($associations[$assocId])) $association
__construct(\SimpleSAML_IdP $idp)
LogoutIFrame constructor.
html()
startLogout(array &$state, $assocId)
Start the logout operation.
if(!isset($_REQUEST['association'])) $assocId
$url
static saveState(&$state, $stage, $rawId=false)
Save the state.
Definition: State.php:194
$associations