ILIAS  release_7 Revision v7.30-3-g800a261c036
ShibWAYF Class Reference

Class ShibbolethWAYF. More...

+ Collaboration diagram for ShibWAYF:

Public Member Functions

 __construct ()
 
 is_selection ()
 
 isSelection ()
 
 is_valid_selection ()
 
 isValidSelection ()
 
 generateSelection ()
 
 redirect ()
 @description Redirects user to the local Shibboleth session initatiotor with already set GET arguments for the right IdP and return location. More...
 
 setSAMLCookie ()
 @description 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.

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"]

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

+ Here is the call graph for this function:

Member Function Documentation

◆ appendCookieValue()

ShibWAYF::appendCookieValue (   $value,
array  $arr_cookie 
)
Parameters
$value
$arr_cookie

@description Append a value to the array of IDPs

Returns
array

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

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 }

Referenced by setSAMLCookie().

+ Here is the caller graph for this function:

◆ generateCookieArray()

ShibWAYF::generateCookieArray (   $value)
Parameters
$value

@description Generates an array of IDPs using the cookie value

Returns
array

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

234 {
235 $arr_cookie = explode(' ', $value);
236 $arr_cookie = array_map('base64_decode', $arr_cookie);
237
238 return $arr_cookie;
239 }

Referenced by generateSelection(), and setSAMLCookie().

+ Here is the caller graph for this function:

◆ generateCookieValue()

ShibWAYF::generateCookieValue ( array  $arr_cookie)
Parameters
$arr_cookie

@description Generate the value that is stored in the cookie using the list of IDPs

Returns
string

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

250 {
251 $arr_cookie = array_map('base64_encode', $arr_cookie);
252 $value = implode(' ', $arr_cookie);
253
254 return $value;
255 }

Referenced by setSAMLCookie().

+ Here is the caller graph for this function:

◆ generateSelection()

ShibWAYF::generateSelection ( )
Returns
string

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

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 }
$_GET["client_id"]
generateCookieArray($value)
language handling
$lng
$_COOKIE[session_name()]
Definition: xapitoken.php:37

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

+ Here is the call graph for this function:

◆ getIdplist()

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

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

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: goto.php:24
global $ilSetting
Definition: privfeed.php:17

References $DIC, $idp_list, and $ilSetting.

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

+ Here is the caller graph for this function:

◆ is_selection()

ShibWAYF::is_selection ( )
Returns
bool

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

80 {
81 return $this->isSelection();
82 }

References isSelection().

Referenced by __construct(), and showNotice().

+ 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.

98 {
99 return $this->isValidSelection();
100 }

References isValidSelection().

Referenced by __construct(), and showNotice().

+ 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.

89 {
91 }

References $is_selection.

Referenced by is_selection().

+ Here is the caller graph for this function:

◆ isValidSelection()

ShibWAYF::isValidSelection ( )
Returns
bool

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

107 {
109 }

References $is_valid_selection.

Referenced by is_valid_selection().

+ Here is the caller graph for this function:

◆ redirect()

ShibWAYF::redirect ( )

@description 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.

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)

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

+ Here is the call graph for this function:

◆ setSAMLCookie()

ShibWAYF::setSAMLCookie ( )

@description 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.

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 }
generateCookieValue(array $arr_cookie)
appendCookieValue($value, array $arr_cookie)

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

+ Here is the call graph for this function:

◆ showNotice()

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

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

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 }

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

+ 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: