ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 54 of file class.ilShibbolethWAYF.php.

54 {
55 // Was the WAYF form submitted?
56 if (isset($_POST['home_organization_selection'])) {
57 $this->is_selection = true;
58 } else {
59 $this->is_selection = false;
60 }
61 // Was selected IdP a valid
62 $this->idp_list = $this->getIdplist();
63 if (isset($_POST['idp_selection']) AND
64 $_POST['idp_selection'] != '-' AND isset($this->idp_list[$_POST['idp_selection']])
65 ) {
66 $this->is_valid_selection = true;
67 $this->selected_idp = $_POST['idp_selection'];
68 } else {
69 $this->is_valid_selection = false;
70 }
71 }
$_POST['username']
Definition: cron.php:12

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 252 of file class.ilShibbolethWAYF.php.

252 {
253 array_push($arr_cookie, $value);
254 $arr_cookie = array_reverse($arr_cookie);
255 $arr_cookie = array_unique($arr_cookie);
256 $arr_cookie = array_reverse($arr_cookie);
257
258 return $arr_cookie;
259 }

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 221 of file class.ilShibbolethWAYF.php.

221 {
222 $arr_cookie = explode(' ', $value);
223 $arr_cookie = array_map('base64_decode', $arr_cookie);
224
225 return $arr_cookie;
226 }

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 236 of file class.ilShibbolethWAYF.php.

236 {
237 $arr_cookie = array_map('base64_encode', $arr_cookie);
238 $value = implode(' ', $arr_cookie);
239
240 return $value;
241 }

Referenced by setSAMLCookie().

+ Here is the caller graph for this function:

◆ generateSelection()

ShibWAYF::generateSelection ( )
Returns
string

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

109 {
110 if (! $this->idp_list) {
111 $arr_idp_list = $this->getIdplist();
112 } else {
113 $arr_idp_list = $this->idp_list;
114 }
115 $idp_cookie = $this->generateCookieArray($_COOKIE['_saml_idp']);
116 $lng = new ilLanguage($_GET["lang"]);
117 if (count($idp_cookie) > 0 AND isset($arr_idp_list[end($idp_cookie)])) {
118 $selectedIDP = end($idp_cookie);
119 $selectElement = '
120 <select name="idp_selection">
121 <option value="-">' . $lng->txt("shib_member_of") . '</option>';
122 } else {
123 $selectElement = '
124 <select name="idp_selection">
125 <option value="-" selected="selected">' . $lng->txt("shib_member_of") . '</option>';
126 }
127 foreach ($arr_idp_list as $idp_id => $idp_data) {
128 if ($idp_id == $selectedIDP) {
129 $selectElement .= '<option value="' . $idp_id . '" selected="selected">' . $idp_data[0] . '</option>';
130 } else {
131 $selectElement .= '<option value="' . $idp_id . '">' . $idp_data[0] . '</option>';
132 }
133 }
134 $selectElement .= '
135 </select>';
136
137 return $selectElement;
138 }
$_GET["client_id"]
generateCookieArray($value)
language handling
$_COOKIE["ilClientId"]
Definition: cron.php:11
global $lng
Definition: privfeed.php:40

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 197 of file class.ilShibbolethWAYF.php.

197 {
198 global $ilSetting;
199 $idp_list = array();
200 $idp_raw_list = split("\n", $ilSetting->get("shib_idp_list"));
201 foreach ($idp_raw_list as $idp_line) {
202 $idp_data = split(',', $idp_line);
203 if (isset($idp_data[2])) {
204 $idp_list[trim($idp_data[0])] = array( trim($idp_data[1]), trim($idp_data[2]) );
205 } elseif (isset($idp_data[1])) {
206 $idp_list[trim($idp_data[0])] = array( trim($idp_data[1]) );
207 }
208 }
209
210 return $idp_list;
211 }
global $ilSetting
Definition: privfeed.php:40

References $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 77 of file class.ilShibbolethWAYF.php.

77 {
78 return $this->isSelection();
79 }

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 93 of file class.ilShibbolethWAYF.php.

93 {
94 return $this->isValidSelection();
95 }

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 85 of file class.ilShibbolethWAYF.php.

85 {
87 }

References $is_selection.

Referenced by is_selection().

+ Here is the caller graph for this function:

◆ isValidSelection()

ShibWAYF::isValidSelection ( )
Returns
bool

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

101 {
103 }

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 144 of file class.ilShibbolethWAYF.php.

144 {
145 if (! $this->idp_list) {
146 $arr_idp_list = $this->getIdplist();
147 } else {
148 $arr_idp_list = $this->idp_list;
149 }
150 // Where to return after the authentication process
151 $target = trim(ILIAS_HTTP_PATH, '/') . '/shib_login.php?target=' . $_POST["il_target"];
152 $idp_data = $arr_idp_list[$this->selected_idp];
153 if (isset($idp_data[1])) {
154 ilUtil::redirect($idp_data[1] . '?providerId=' . urlencode($this->selected_idp) . '&target='
155 . urlencode($target));
156 } else {
157 // TODO: This has to be changed to /Shibboleth.sso/DS?entityId= for
158 // Shibbolet 2.x sometime...
159 ilUtil::redirect('/Shibboleth.sso?providerId=' . urlencode($this->selected_idp) . '&target='
160 . urlencode($target));
161 }
162 }
static redirect($a_script)
http redirect to other 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 168 of file class.ilShibbolethWAYF.php.

168 {
169 if (isset($_COOKIE['_saml_idp'])) {
170 $arr_idps = $this->generateCookieArray($_COOKIE['_saml_idp']);
171 } else {
172 $arr_idps = array();
173 }
174 $arr_idps = $this->appendCookieValue($this->selected_idp, $arr_idps);
175 setcookie('_saml_idp', $this->generateCookieValue($arr_idps), time() + (100 * 24 * 3600), '/');
176 }
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 183 of file class.ilShibbolethWAYF.php.

183 {
184 $lng = new ilLanguage($_GET["lang"]);
185 if (! $this->is_selection() or $this->is_valid_selection()) {
186 return '';
187 } else {
188 return $lng->txt("shib_invalid_home_organization");
189 }
190 }

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 51 of file class.ilShibbolethWAYF.php.

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

◆ $is_selection

ShibWAYF::$is_selection = false

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

Referenced by isSelection().

◆ $is_valid_selection

ShibWAYF::$is_valid_selection = false

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

Referenced by isValidSelection().

◆ $selected_idp

ShibWAYF::$selected_idp = '-'

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

Referenced by redirect().


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