public static function getCurrentBinding() : Binding
    {
        switch ($_SERVER['REQUEST_METHOD']) {
            case 'GET':
                if (array_key_exists('SAMLRequest', $_GET) || array_key_exists('SAMLResponse', $_GET)) {
                    return new HTTPRedirect();
                } elseif (array_key_exists('SAMLart', $_GET)) {
                    return new HTTPArtifact();
                }
                break;

            case 'POST':
                if (isset($_SERVER['CONTENT_TYPE'])) {
                    $contentType = $_SERVER['CONTENT_TYPE'];
                    $contentType = explode(';', $contentType);
                    $contentType = $contentType[0]; /* Remove charset. */
                } else {
                    $contentType = null;
                }
                if (array_key_exists('SAMLRequest', $_POST) || array_key_exists('SAMLResponse', $_POST)) {
                    return new HTTPPost();
                } elseif (array_key_exists('SAMLart', $_POST)) {
                    return new HTTPArtifact();
                } elseif ($contentType === 'text/xml') {
                    return new SOAP();
                }
                break;
        }

        $logger = Utils::getContainer()->getLogger();
        $logger->warning('Unable to find the SAML 2 binding used for this request.');
        $logger->warning('Request method: '.var_export($_SERVER['REQUEST_METHOD'], true));
        if (!empty($_GET)) {
            $logger->warning("GET parameters: '".implode("', '", array_map('addslashes', array_keys($_GET)))."'");
        }
        if (!empty($_POST)) {
            $logger->warning("POST parameters: '".implode("', '", array_map('addslashes', array_keys($_POST)))."'");
        }
        if (isset($_SERVER['CONTENT_TYPE'])) {
            $logger->warning('Content-Type: '.var_export($_SERVER['CONTENT_TYPE'], true));
        }

        throw new \Exception('Unable to find the SAML 2 binding used for this request.');
    }
public static function getCurrentBinding() : Binding
    {
        switch ($_SERVER['REQUEST_METHOD']) {
            case 'GET':
                if (array_key_exists('SAMLRequest', $_GET) || array_key_exists('SAMLResponse', $_GET)) {
                    return new HTTPRedirect();
                } elseif (array_key_exists('SAMLart', $_GET)) {
                    return new HTTPArtifact();
                }
                break;

            case 'POST':
                if (isset($_SERVER['CONTENT_TYPE'])) {
                    $contentType = $_SERVER['CONTENT_TYPE'];
                    $contentType = explode(';', $contentType);
                    $contentType = $contentType[0]; /* Remove charset. */
                } else {
                    $contentType = null;
                }
                if (array_key_exists('SAMLRequest', $_POST) || array_key_exists('SAMLResponse', $_POST)) {
                    return new HTTPPost();
                } elseif (array_key_exists('SAMLart', $_POST)) {
                    return new HTTPArtifact();
                } elseif ($contentType === 'text/xml') {
                    return new SOAP();
                }
                break;
        }

        $logger = Utils::getContainer()->getLogger();
        $logger->warning('Unable to find the SAML 2 binding used for this request.');
        $logger->warning('Request method: '.var_export($_SERVER['REQUEST_METHOD'], true));
        if (!empty($_GET)) {
            $logger->warning("GET parameters: '".implode("', '", array_map('addslashes', array_keys($_GET)))."'");
        }
        if (!empty($_POST)) {
            $logger->warning("POST parameters: '".implode("', '", array_map('addslashes', array_keys($_POST)))."'");
        }
        if (isset($_SERVER['CONTENT_TYPE'])) {
            $logger->warning('Content-Type: '.var_export($_SERVER['CONTENT_TYPE'], true));
        }

        throw new \Exception('Unable to find the SAML 2 binding used for this request.');
    }
public static function getCurrentBinding ( ) : Binding { switch ( $ _SERVER [ 'REQUEST_METHOD' ] ) { case 'GET' : if ( array_key_exists ( 'SAMLRequest' , $ _GET ) || array_key_exists ( 'SAMLResponse' , $ _GET ) ) { return new HTTPRedirect ( ) ; } elseif ( array_key_exists ( 'SAMLart' , $ _GET ) ) { return new HTTPArtifact ( ) ; } break ; case 'POST' : if ( isset ( $ _SERVER [ 'CONTENT_TYPE' ] ) ) { $ contentType = $ _SERVER [ 'CONTENT_TYPE' ] ; $ contentType = explode ( ';' , $ contentType ) ; $ contentType = $ contentType [ 0 ] ; /* Remove charset. */ } else { $ contentType = null ; } if ( array_key_exists ( 'SAMLRequest' , $ _POST ) || array_key_exists ( 'SAMLResponse' , $ _POST ) ) { return new HTTPPost ( ) ; } elseif ( array_key_exists ( 'SAMLart' , $ _POST ) ) { return new HTTPArtifact ( ) ; } elseif ( $ contentType === 'text/xml' ) { return new SOAP ( ) ; } break ; } $ logger = Utils :: getContainer ( ) -> getLogger ( ) ; $ logger -> warning ( 'Unable to find the SAML 2 binding used for this request.' ) ; $ logger -> warning ( 'Request method: ' . var_export ( $ _SERVER [ 'REQUEST_METHOD' ] , true ) ) ; if ( ! empty ( $ _GET ) ) { $ logger -> warning ( "GET parameters: '" . implode ( "', '" , array_map ( 'addslashes' , array_keys ( $ _GET ) ) ) . "'" ) ; } if ( ! empty ( $ _POST ) ) { $ logger -> warning ( "POST parameters: '" . implode ( "', '" , array_map ( 'addslashes' , array_keys ( $ _POST ) ) ) . "'" ) ; } if ( isset ( $ _SERVER [ 'CONTENT_TYPE' ] ) ) { $ logger -> warning ( 'Content-Type: ' . var_export ( $ _SERVER [ 'CONTENT_TYPE' ] , true ) ) ; } throw new \ Exception ( 'Unable to find the SAML 2 binding used for this request.' ) ; }
Guess the current binding.

This function guesses the current binding and creates an instance
of \SAML2\Binding matching that binding.

An exception will be thrown if it is unable to guess the binding.

@throws \Exception
@return \SAML2\Binding The binding.
Guess the current binding .