ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ShibWAYF Class Reference

Class ShibbolethWAYF. More...

+ Collaboration diagram for ShibWAYF:

Public Member Functions

 __construct ()
 
 is_selection ()
 
 isSelection ()
 
 is_valid_selection ()
 
 isValidSelection ()
 
 generateSelection ()
 
 redirect ()
 Redirects user to the local Shibboleth session initatiotor with already set GET arguments for the right IdP and return location. More...
 
 setSAMLCookie ()
 Sets the standard SAML domain cookie that is also used to preselect the right entry on the local wayf More...
 
 showNotice ()
 
 getIdplist ()
 
 generateCookieArray ($value)
 
 generateCookieValue (array $arr_cookie)
 
 appendCookieValue ($value, array $arr_cookie)
 

Data Fields

 $is_selection = false
 
 $is_valid_selection = false
 
 $selected_idp = '-'
 
 $idp_list = false
 

Detailed Description

Class ShibbolethWAYF.

This class handles the Home Organization selection (also called Where Are You From service) process for Shibboleth users.

Author
Fabian Schmid fs@st.nosp@m.uder.nosp@m.-raim.nosp@m.ann..nosp@m.ch

Definition at line 34 of file class.ilShibbolethWAYF.php.

Constructor & Destructor Documentation

◆ __construct()

ShibWAYF::__construct ( )

Definition at line 55 of file class.ilShibbolethWAYF.php.

References $_POST, getIdplist(), is_selection(), and is_valid_selection().

56  {
57  // Was the WAYF form submitted?
58  if (isset($_POST['home_organization_selection'])) {
59  $this->is_selection = true;
60  } else {
61  $this->is_selection = false;
62  }
63  // Was selected IdP a valid
64  $this->idp_list = $this->getIdplist();
65  if (isset($_POST['idp_selection']) and
66  $_POST['idp_selection'] != '-' and isset($this->idp_list[$_POST['idp_selection']])
67  ) {
68  $this->is_valid_selection = true;
69  $this->selected_idp = $_POST['idp_selection'];
70  } else {
71  $this->is_valid_selection = false;
72  }
73  }
$_POST["username"]
+ Here is the call graph for this function:

Member Function Documentation

◆ appendCookieValue()

ShibWAYF::appendCookieValue (   $value,
array  $arr_cookie 
)
Parameters
$value
$arr_cookieAppend a value to the array of IDPs
Returns
array

Definition at line 266 of file class.ilShibbolethWAYF.php.

Referenced by setSAMLCookie().

267  {
268  array_push($arr_cookie, $value);
269  $arr_cookie = array_reverse($arr_cookie);
270  $arr_cookie = array_unique($arr_cookie);
271  $arr_cookie = array_reverse($arr_cookie);
272 
273  return $arr_cookie;
274  }
+ Here is the caller graph for this function:

◆ generateCookieArray()

ShibWAYF::generateCookieArray (   $value)
Parameters
$valueGenerates an array of IDPs using the cookie value
Returns
array

Definition at line 233 of file class.ilShibbolethWAYF.php.

Referenced by generateSelection(), and setSAMLCookie().

234  {
235  $arr_cookie = explode(' ', $value);
236  $arr_cookie = array_map('base64_decode', $arr_cookie);
237 
238  return $arr_cookie;
239  }
+ Here is the caller graph for this function:

◆ generateCookieValue()

ShibWAYF::generateCookieValue ( array  $arr_cookie)
Parameters
$arr_cookieGenerate the value that is stored in the cookie using the list of IDPs
Returns
string

Definition at line 249 of file class.ilShibbolethWAYF.php.

Referenced by setSAMLCookie().

250  {
251  $arr_cookie = array_map('base64_encode', $arr_cookie);
252  $value = implode(' ', $arr_cookie);
253 
254  return $value;
255  }
+ Here is the caller graph for this function:

◆ generateSelection()

ShibWAYF::generateSelection ( )
Returns
string

Definition at line 115 of file class.ilShibbolethWAYF.php.

References $_COOKIE, $_GET, $idp_list, $lng, generateCookieArray(), and getIdplist().

116  {
117  if (!$this->idp_list) {
118  $arr_idp_list = $this->getIdplist();
119  } else {
120  $arr_idp_list = $this->idp_list;
121  }
122  $idp_cookie = $this->generateCookieArray($_COOKIE['_saml_idp']);
123  $lng = new ilLanguage($_GET["lang"]);
124  if (count($idp_cookie) > 0 and isset($arr_idp_list[end($idp_cookie)])) {
125  $selectedIDP = end($idp_cookie);
126  $selectElement = '
127  <select name="idp_selection">
128  <option value="-">' . $lng->txt("shib_member_of") . '</option>';
129  } else {
130  $selectElement = '
131  <select name="idp_selection">
132  <option value="-" selected="selected">' . $lng->txt("shib_member_of") . '</option>';
133  }
134  foreach ($arr_idp_list as $idp_id => $idp_data) {
135  if ($idp_id == $selectedIDP) {
136  $selectElement .= '<option value="' . $idp_id . '" selected="selected">' . $idp_data[0] . '</option>';
137  } else {
138  $selectElement .= '<option value="' . $idp_id . '">' . $idp_data[0] . '</option>';
139  }
140  }
141  $selectElement .= '
142  </select>';
143 
144  return $selectElement;
145  }
$_COOKIE['client_id']
Definition: server.php:9
$_GET["client_id"]
generateCookieArray($value)
global $lng
Definition: privfeed.php:17
language handling
+ Here is the call graph for this function:

◆ getIdplist()

ShibWAYF::getIdplist ( )
Returns
array Generate array of IdPs from ILIAS Shibboleth settings

Definition at line 207 of file class.ilShibbolethWAYF.php.

References $DIC, $idp_list, $ilSetting, and array.

Referenced by __construct(), generateSelection(), and redirect().

208  {
209  global $DIC;
210  $ilSetting = $DIC['ilSetting'];
211  $idp_list = array();
212  $idp_raw_list = explode("\n", $ilSetting->get("shib_idp_list"));
213  foreach ($idp_raw_list as $idp_line) {
214  $idp_data = explode(',', $idp_line);
215  if (isset($idp_data[2])) {
216  $idp_list[trim($idp_data[0])] = array( trim($idp_data[1]), trim($idp_data[2]) );
217  } elseif (isset($idp_data[1])) {
218  $idp_list[trim($idp_data[0])] = array( trim($idp_data[1]) );
219  }
220  }
221 
222  return $idp_list;
223  }
global $DIC
Definition: saml.php:7
Create styles array
The data for the language used.
global $ilSetting
Definition: privfeed.php:17
+ Here is the caller graph for this function:

◆ is_selection()

ShibWAYF::is_selection ( )
Returns
bool

Definition at line 79 of file class.ilShibbolethWAYF.php.

References isSelection().

Referenced by __construct(), and showNotice().

80  {
81  return $this->isSelection();
82  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ is_valid_selection()

ShibWAYF::is_valid_selection ( )
Returns
bool

Definition at line 97 of file class.ilShibbolethWAYF.php.

References isValidSelection().

Referenced by __construct(), and showNotice().

98  {
99  return $this->isValidSelection();
100  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isSelection()

ShibWAYF::isSelection ( )
Returns
bool

Definition at line 88 of file class.ilShibbolethWAYF.php.

References $is_selection.

Referenced by is_selection().

89  {
90  return $this->is_selection;
91  }
+ Here is the caller graph for this function:

◆ isValidSelection()

ShibWAYF::isValidSelection ( )
Returns
bool

Definition at line 106 of file class.ilShibbolethWAYF.php.

References $is_valid_selection.

Referenced by is_valid_selection().

107  {
109  }
+ Here is the caller graph for this function:

◆ redirect()

ShibWAYF::redirect ( )

Redirects user to the local Shibboleth session initatiotor with already set GET arguments for the right IdP and return location.

Definition at line 151 of file class.ilShibbolethWAYF.php.

References $_POST, $idp_list, $selected_idp, $target, getIdplist(), and ilUtil\redirect().

152  {
153  if (!$this->idp_list) {
154  $arr_idp_list = $this->getIdplist();
155  } else {
156  $arr_idp_list = $this->idp_list;
157  }
158  // Where to return after the authentication process
159  $target = trim(ILIAS_HTTP_PATH, '/') . '/shib_login.php?target=' . $_POST["il_target"];
160  $idp_data = $arr_idp_list[$this->selected_idp];
161  if (isset($idp_data[1])) {
162  ilUtil::redirect($idp_data[1] . '?providerId=' . urlencode($this->selected_idp) . '&target='
163  . urlencode($target));
164  } else {
165  // TODO: This has to be changed to /Shibboleth.sso/DS?entityId= for
166  // Shibbolet 2.x sometime...
167  ilUtil::redirect('/Shibboleth.sso?providerId=' . urlencode($this->selected_idp) . '&target='
168  . urlencode($target));
169  }
170  }
static redirect($a_script)
$_POST["username"]
+ Here is the call graph for this function:

◆ setSAMLCookie()

ShibWAYF::setSAMLCookie ( )

Sets the standard SAML domain cookie that is also used to preselect the right entry on the local wayf

Definition at line 176 of file class.ilShibbolethWAYF.php.

References $_COOKIE, appendCookieValue(), array, generateCookieArray(), generateCookieValue(), and time.

177  {
178  if (isset($_COOKIE['_saml_idp'])) {
179  $arr_idps = $this->generateCookieArray($_COOKIE['_saml_idp']);
180  } else {
181  $arr_idps = array();
182  }
183  $arr_idps = $this->appendCookieValue($this->selected_idp, $arr_idps);
184  setcookie('_saml_idp', $this->generateCookieValue($arr_idps), time() + (100 * 24 * 3600), '/');
185  }
$_COOKIE['client_id']
Definition: server.php:9
generateCookieArray($value)
Create styles array
The data for the language used.
generateCookieValue(array $arr_cookie)
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
appendCookieValue($value, array $arr_cookie)
+ Here is the call graph for this function:

◆ showNotice()

ShibWAYF::showNotice ( )
Returns
string Show notice in case no IdP was selected

Definition at line 192 of file class.ilShibbolethWAYF.php.

References $_GET, $lng, is_selection(), and is_valid_selection().

193  {
194  $lng = new ilLanguage($_GET["lang"]);
195  if (!$this->is_selection() or $this->is_valid_selection()) {
196  return '';
197  } else {
198  return $lng->txt("shib_invalid_home_organization");
199  }
200  }
$_GET["client_id"]
global $lng
Definition: privfeed.php:17
language handling
+ Here is the call graph for this function:

Field Documentation

◆ $idp_list

ShibWAYF::$idp_list = false

Definition at line 52 of file class.ilShibbolethWAYF.php.

Referenced by generateSelection(), getIdplist(), and redirect().

◆ $is_selection

ShibWAYF::$is_selection = false

Definition at line 40 of file class.ilShibbolethWAYF.php.

Referenced by isSelection().

◆ $is_valid_selection

ShibWAYF::$is_valid_selection = false

Definition at line 44 of file class.ilShibbolethWAYF.php.

Referenced by isValidSelection().

◆ $selected_idp

ShibWAYF::$selected_idp = '-'

Definition at line 48 of file class.ilShibbolethWAYF.php.

Referenced by redirect().


The documentation for this class was generated from the following file: