ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
IFrameLogoutHandler.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 
41  public function startLogout(array &$state, $assocId)
42  {
43  assert('is_string($assocId) || is_null($assocId)');
44 
45  $associations = $this->idp->getAssociations();
46 
47  if (count($associations) === 0) {
48  $this->idp->finishLogout($state);
49  }
50 
51  foreach ($associations as $id => &$association) {
53  $association['core:Logout-IFrame:Name'] = $idp->getSPName($id);
54  $association['core:Logout-IFrame:State'] = 'onhold';
55  }
56  $state['core:Logout-IFrame:Associations'] = $associations;
57 
58  if (!is_null($assocId)) {
59  $spName = $this->idp->getSPName($assocId);
60  if ($spName === null) {
61  $spName = array('en' => $assocId);
62  }
63 
64  $state['core:Logout-IFrame:From'] = $spName;
65  } else {
66  $state['core:Logout-IFrame:From'] = null;
67  }
68 
69  $params = array(
70  'id' => \SimpleSAML_Auth_State::saveState($state, 'core:Logout-IFrame'),
71  );
72  if (isset($state['core:Logout-IFrame:InitType'])) {
73  $params['type'] = $state['core:Logout-IFrame:InitType'];
74  }
75 
76  $url = Module::getModuleURL('core/idp/logout-iframe.php', $params);
78  }
79 
80 
91  {
92  assert('is_string($assocId)');
93 
94  $spId = sha1($assocId);
95  $this->idp->terminateAssociation($assocId);
96 
97  $header = <<<HEADER
98 <!DOCTYPE html>
99 <html>
100  <head>
101  <title>Logout response from %s</title>
102  <script>
103 HEADER;
104  printf($header, htmlspecialchars(var_export($assocId, true)));
105  if ($error) {
106  $errorMsg = $error->getMessage();
107  echo('window.parent.logoutFailed("'.$spId.'", "'.addslashes($errorMsg).'");');
108  } else {
109  echo('window.parent.logoutCompleted("'.$spId.'");');
110  }
111  echo <<<FOOTER
112  </script>
113  </head>
114  <body>
115  </body>
116 </html>
117 FOOTER;
118  exit(0);
119  }
120 }
$params
Definition: disable.php:11
static getByState(array &$state)
Retrieve the IdP "owning" the state.
Definition: IdP.php:152
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:962
static getModuleURL($resource, array $parameters=array())
Get absolute URL to a specified module resource.
Definition: Module.php:303
if(!array_key_exists('stateid', $_REQUEST)) $state
Handle linkback() response from LinkedIn.
Definition: linkback.php:10
$error
Definition: Error.php:17
$relayState
Create styles array
The data for the language used.
Add data(end) s
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