Public Member Functions | Data Fields

ShibWAYF Class Reference

Class ShibbolethWAYF. More...

Public Member Functions

 ShibWAYF ()
 isSelection ()
 isValidSelection ()
 generateSelection ()
 redirect ()
 setSAMLCookie ()
 showNotice ()
 getIDPList ()
 generateCookieArray ($value)
 generateCookieValue ($CookieArray)
 appendCookieValue ($value, $CookieArray)

Data Fields

 $isSelection = false
 $isValidSelection = false
 $selectedIDP = '-'
 $IDPList = false

Detailed Description

Class ShibbolethWAYF.

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

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


Member Function Documentation

ShibWAYF::appendCookieValue ( value,
CookieArray 
)

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

Referenced by setSAMLCookie().

        {
                
                array_push($CookieArray, $value);
                $CookieArray = array_reverse($CookieArray);
                $CookieArray = array_unique($CookieArray);
                $CookieArray = array_reverse($CookieArray);
                
                return $CookieArray;
        }

Here is the caller graph for this function:

ShibWAYF::generateCookieArray ( value  ) 

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

Referenced by generateSelection(), and setSAMLCookie().

        {
                
                // Decodes and splits cookie value
                $CookieArray = split(' ', $value);
                $CookieArray = array_map('base64_decode', $CookieArray);
                
                return $CookieArray;
        }

Here is the caller graph for this function:

ShibWAYF::generateCookieValue ( CookieArray  ) 

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

Referenced by setSAMLCookie().

        {
        
                // Merges cookie content and encodes it
                $CookieArray = array_map('base64_encode', $CookieArray);
                $value = implode(' ', $CookieArray);
                return $value;
        }

Here is the caller graph for this function:

ShibWAYF::generateSelection (  ) 

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

References $_GET, $lng, $selectedIDP, generateCookieArray(), and getIDPList().

        {
                global $ilSetting;
                
                // Calculate select element
                
                $selectElement = '';
                
                if (!$this->IDPList)
                {
                        $idp_list = $this->getIDPList();
                }
                else
                {
                        $idp_list = $this->IDPList;
                }
                
                $idp_cookie = $this->generateCookieArray($_COOKIE['_saml_idp']);
                
                $lng = new ilLanguage($_GET["lang"]);
                
                if (count($idp_cookie) > 0 && isset($idp_list[end($idp_cookie)]))
                {
                        $selectedIDP = end($idp_cookie);
                        $selectElement = '
                <select name="idp_selection">
                        <option value="-">'.$lng->txt("shib_member_of").'</option>';
                }
                else
                {
                        $selectElement = '
                <select name="idp_selection">
                        <option value="-" selected="selected">'.$lng->txt("shib_member_of").'</option>';
                }
                
                foreach ($idp_list as $idp_id => $idp_data){
                        
                        if ($idp_id == $selectedIDP)
                        {
                                $selectElement .= '<option value="'.$idp_id.'" selected="selected">'.$idp_data[0].'</option>';
                        }
                        else
                        {
                                $selectElement .= '<option value="'.$idp_id.'">'.$idp_data[0].'</option>';
                        }
                }
                
                $selectElement .= '
                </select>';
                
                return $selectElement;
        }

Here is the call graph for this function:

ShibWAYF::getIDPList (  ) 

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

References exit.

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

        {
                global $ilSetting;
                
                $idp_list = array();
                
                $idp_raw_list = split("\n", $ilSetting->get("shib_idp_list"));
                
                foreach ($idp_raw_list as $idp_line){
                        $idp_data = split(',', $idp_line);
                        if (isset($idp_data[2]))
                        {
                                $idp_list[trim($idp_data[0])] = array(trim($idp_data[1]),trim($idp_data[2])); 
                        }
                        elseif(isset($idp_data[1]))
                        {
                                $idp_list[trim($idp_data[0])] = array(trim($idp_data[1]));
                        }
                }
                
                return $idp_list;
                print_r($idp_list);exit;
        }

Here is the caller graph for this function:

ShibWAYF::isSelection (  ) 

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

Referenced by ShibWAYF(), and showNotice().

        {
                
                return $this->isSelection;
        }

Here is the caller graph for this function:

ShibWAYF::isValidSelection (  ) 

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

Referenced by ShibWAYF(), and showNotice().

        {
                
                return $this->isValidSelection;
                
        }

Here is the caller graph for this function:

ShibWAYF::redirect (  ) 

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

References getIDPList().

        {
                if (!$this->IDPList)
                {
                        $idp_list = $this->getIDPList();
                }
                else
                {
                        $idp_list = $this->IDPList;
                }
                
                // Where to return after the authentication process
                $target = trim(ILIAS_HTTP_PATH, '/').'/shib_login.php';
                
                $idp_data = $idp_list[$this->selectedIDP];
                if (isset($idp_data[1]))
                {
                        ilUtil::redirect($idp_data[1].'?providerId='.urlencode($this->selectedIDP).'&target='.urlencode($target));
                }
                else
                {
                        ilUtil::redirect('/Shibboleth.sso?providerId='.urlencode($this->selectedIDP).'&target='.urlencode($target));
                }
                
        }

Here is the call graph for this function:

ShibWAYF::setSAMLCookie (  ) 

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

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

        {
                if (isset($_COOKIE['_saml_idp']))
                {
                        $IDPArray = $this->generateCookieArray($_COOKIE['_saml_idp']);
                }
                else
                {
                        $IDPArray = array();
                }
                $IDPArray = $this->appendCookieValue($this->selectedIDP, $IDPArray);
                setcookie ('_saml_idp', $this->generateCookieValue($IDPArray), time() + (100*24*3600), '/');
        }

Here is the call graph for this function:

ShibWAYF::ShibWAYF (  ) 

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

References $_POST, getIDPList(), isSelection(), and isValidSelection().

        {
                // Was the WAYF form submitted?
                if (isset($_POST['home_organization_selection']))
                {
                        $this->isSelection = true;
                }
                else
                {
                        $this->isSelection = false;
                }
                
                // Was selected IdP a valid
                $this->IDPList = $this->getIDPList();
                if (
                        isset($_POST['idp_selection'])
                        && $_POST['idp_selection'] != '-'
                        && isset($this->IDPList[$_POST['idp_selection']])
                        )
                {
                        $this->isValidSelection = true;
                        $this->selectedIDP = $_POST['idp_selection'];
                }
                else
                {
                        $this->isValidSelection = false;
                }
        }

Here is the call graph for this function:

ShibWAYF::showNotice (  ) 

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

References $_GET, $lng, isSelection(), and isValidSelection().

        {
                $lng = new ilLanguage($_GET["lang"]);
                
                if (!$this->isSelection() or $this->isValidSelection())
                {
                        return '';
                }
                else
                {
                        return $lng->txt("shib_invalid_home_organization");
                }
        }

Here is the call graph for this function:


Field Documentation

ShibWAYF::$IDPList = false

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

ShibWAYF::$isSelection = false

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

ShibWAYF::$isValidSelection = false

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

ShibWAYF::$selectedIDP = '-'

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

Referenced by generateSelection().


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