public function logout($application_index = null, $returnTo = null, $parameters = array(), $nameId = null, $sessionIndex = null, $stay = false, $nameIdFormat = null, $nameIdNameQualifier = null)
    {
        assert('is_array($parameters)');

        $sloUrl = $this->getSLOurl($application_index);
        if (empty($sloUrl)) {
            throw new OneLogin_Saml2_Error(
                'The IdP does not support Single Log Out',
                OneLogin_Saml2_Error::SAML_SINGLE_LOGOUT_NOT_SUPPORTED
            );
        }

        if (empty($nameId) && !empty($this->_nameid)) {
            $nameId = $this->_nameid;
        }
        if (empty($nameIdFormat) && !empty($this->_nameidFormat)) {
            $nameIdFormat = $this->_nameidFormat;
        }

        $logoutRequest = new OneLogin_Saml2_LogoutRequest($application_index, $this->_settings, null, $nameId, $sessionIndex, $nameIdFormat, $nameIdNameQualifier);

        $this->_lastRequest = $logoutRequest->getXML();
        $this->_lastRequestID = $logoutRequest->id;

        $samlRequest = $logoutRequest->getRequest();

        $parameters['SAMLRequest'] = $samlRequest;
        if (!empty($returnTo)) {
            $parameters['RelayState'] = $returnTo;
        } else {
            $parameters['RelayState'] = OneLogin_Saml2_Utils::getSelfRoutedURLNoQuery();
        }

        $security = $this->_settings->getSecurityData();
        if (isset($security['logoutRequestSigned']) && $security['logoutRequestSigned']) {
            $signature = $this->buildRequestSignature($samlRequest, $parameters['RelayState'], $security['signatureAlgorithm']);
            $parameters['SigAlg'] = $security['signatureAlgorithm'];
            $parameters['Signature'] = $signature;
        }

        return $this->redirectTo($sloUrl, $parameters, $stay);
    }
public function logout($application_index = null, $returnTo = null, $parameters = array(), $nameId = null, $sessionIndex = null, $stay = false, $nameIdFormat = null, $nameIdNameQualifier = null)
    {
        assert('is_array($parameters)');

        $sloUrl = $this->getSLOurl($application_index);
        if (empty($sloUrl)) {
            throw new OneLogin_Saml2_Error(
                'The IdP does not support Single Log Out',
                OneLogin_Saml2_Error::SAML_SINGLE_LOGOUT_NOT_SUPPORTED
            );
        }

        if (empty($nameId) && !empty($this->_nameid)) {
            $nameId = $this->_nameid;
        }
        if (empty($nameIdFormat) && !empty($this->_nameidFormat)) {
            $nameIdFormat = $this->_nameidFormat;
        }

        $logoutRequest = new OneLogin_Saml2_LogoutRequest($application_index, $this->_settings, null, $nameId, $sessionIndex, $nameIdFormat, $nameIdNameQualifier);

        $this->_lastRequest = $logoutRequest->getXML();
        $this->_lastRequestID = $logoutRequest->id;

        $samlRequest = $logoutRequest->getRequest();

        $parameters['SAMLRequest'] = $samlRequest;
        if (!empty($returnTo)) {
            $parameters['RelayState'] = $returnTo;
        } else {
            $parameters['RelayState'] = OneLogin_Saml2_Utils::getSelfRoutedURLNoQuery();
        }

        $security = $this->_settings->getSecurityData();
        if (isset($security['logoutRequestSigned']) && $security['logoutRequestSigned']) {
            $signature = $this->buildRequestSignature($samlRequest, $parameters['RelayState'], $security['signatureAlgorithm']);
            $parameters['SigAlg'] = $security['signatureAlgorithm'];
            $parameters['Signature'] = $signature;
        }

        return $this->redirectTo($sloUrl, $parameters, $stay);
    }
public function logout ( $ application_index = null , $ returnTo = null , $ parameters = array ( ) , $ nameId = null , $ sessionIndex = null , $ stay = false , $ nameIdFormat = null , $ nameIdNameQualifier = null ) { assert ( 'is_array($parameters)' ) ; $ sloUrl = $ this -> getSLOurl ( $ application_index ) ; if ( empty ( $ sloUrl ) ) { throw new OneLogin_Saml2_Error ( 'The IdP does not support Single Log Out' , OneLogin_Saml2_Error :: SAML_SINGLE_LOGOUT_NOT_SUPPORTED ) ; } if ( empty ( $ nameId ) && ! empty ( $ this -> _nameid ) ) { $ nameId = $ this -> _nameid ; } if ( empty ( $ nameIdFormat ) && ! empty ( $ this -> _nameidFormat ) ) { $ nameIdFormat = $ this -> _nameidFormat ; } $ logoutRequest = new OneLogin_Saml2_LogoutRequest ( $ application_index , $ this -> _settings , null , $ nameId , $ sessionIndex , $ nameIdFormat , $ nameIdNameQualifier ) ; $ this -> _lastRequest = $ logoutRequest -> getXML ( ) ; $ this -> _lastRequestID = $ logoutRequest -> id ; $ samlRequest = $ logoutRequest -> getRequest ( ) ; $ parameters [ 'SAMLRequest' ] = $ samlRequest ; if ( ! empty ( $ returnTo ) ) { $ parameters [ 'RelayState' ] = $ returnTo ; } else { $ parameters [ 'RelayState' ] = OneLogin_Saml2_Utils :: getSelfRoutedURLNoQuery ( ) ; } $ security = $ this -> _settings -> getSecurityData ( ) ; if ( isset ( $ security [ 'logoutRequestSigned' ] ) && $ security [ 'logoutRequestSigned' ] ) { $ signature = $ this -> buildRequestSignature ( $ samlRequest , $ parameters [ 'RelayState' ] , $ security [ 'signatureAlgorithm' ] ) ; $ parameters [ 'SigAlg' ] = $ security [ 'signatureAlgorithm' ] ; $ parameters [ 'Signature' ] = $ signature ; } return $ this -> redirectTo ( $ sloUrl , $ parameters , $ stay ) ; }
Initiates the SLO process.

@param string|null $returnTo            The target URL the user should be returned to after logout.
@param array       $parameters          Extra parameters to be added to the GET
@param string|null $nameId              The NameID that will be set in the LogoutRequest.
@param string|null $sessionIndex        The SessionIndex (taken from the SAML Response in the SSO process).
@param bool        $stay                True if we want to stay (returns the url string) False to redirect
@param string|null $nameIdFormat        The NameID Format will be set in the LogoutRequest.
@param string|null $nameIdNameQualifier The NameID NameQualifier will be set in the LogoutRequest.

@return string|null If $stay is True, it return a string with the SLO URL + LogoutRequest + parameters

@throws OneLogin_Saml2_Error
Initiates the SLO process .