protected function handleInvalidToken($tokenBehavior = self::TOKEN_BEHAVIOR_DEFAULT)
    {
        switch ($tokenBehavior) {
            case self::TOKEN_BEHAVIOR_IGNORE:
                $status = true;
                break;

            case self::TOKEN_BEHAVIOR_INVALIDATE:
                $status = false;
                break;

            case self::TOKEN_BEHAVIOR_DENY:
            default:
                // Headers ...
                $headers = [
                    'HTTP/1.0 400 Bad Request',
                    sprintf('WWW-Authenticate: x-doozr-form-service-token realm="%s"', $this->generateToken()),
                ];

                // Need to be sure to be able to send header, otherwise we need to stop operation
                if (false === headers_sent($file, $line)) {
                    foreach ($headers as $header) {
                        header($header);
                    }
                }
                exit;
                break;
        }

        return $status;
    }
protected function handleInvalidToken($tokenBehavior = self::TOKEN_BEHAVIOR_DEFAULT)
    {
        switch ($tokenBehavior) {
            case self::TOKEN_BEHAVIOR_IGNORE:
                $status = true;
                break;

            case self::TOKEN_BEHAVIOR_INVALIDATE:
                $status = false;
                break;

            case self::TOKEN_BEHAVIOR_DENY:
            default:
                // Headers ...
                $headers = [
                    'HTTP/1.0 400 Bad Request',
                    sprintf('WWW-Authenticate: x-doozr-form-service-token realm="%s"', $this->generateToken()),
                ];

                // Need to be sure to be able to send header, otherwise we need to stop operation
                if (false === headers_sent($file, $line)) {
                    foreach ($headers as $header) {
                        header($header);
                    }
                }
                exit;
                break;
        }

        return $status;
    }
protected function handleInvalidToken ( $ tokenBehavior = self :: TOKEN_BEHAVIOR_DEFAULT ) { switch ( $ tokenBehavior ) { case self :: TOKEN_BEHAVIOR_IGNORE : $ status = true ; break ; case self :: TOKEN_BEHAVIOR_INVALIDATE : $ status = false ; break ; case self :: TOKEN_BEHAVIOR_DENY : default : // Headers ... $ headers = [ 'HTTP/1.0 400 Bad Request' , sprintf ( 'WWW-Authenticate: x-doozr-form-service-token realm="%s"' , $ this -> generateToken ( ) ) , ] ; // Need to be sure to be able to send header, otherwise we need to stop operation if ( false === headers_sent ( $ file , $ line ) ) { foreach ( $ headers as $ header ) { header ( $ header ) ; } } exit ; break ; } return $ status ; }
Handles invalid tokens by passed behavior.

@param int $tokenBehavior Behavior for invalid token

@author Benjamin Carl <opensource@clickalicious.de>

@return bool TRUE on success, otherwise FALSE
Handles invalid tokens by passed behavior .