getMatchFailureReason

@param array $nomatch
@param Request $request

@return int
344461
private function getMatchFailureReason(array $nomatch, Request $request)
    {
        $path = $request->getPath();

        $reduce = array_filter($nomatch, function ($route) use ($path) {
            return (bool)preg_match_all($route->getContext()->getRegex(), $path);
        });

        foreach ($reduce as $name => $route) {
            if (!$this->matchHost($route->getContext(), $request, $route->getHost())) {
                return RequestMatcherInterface::NOMATCH_HOST;
            }

            if (!$route->hasScheme($request->getScheme())) {
                return RequestMatcherInterface::NOMATCH_SCHEME;
            }

            if (!$route->hasMethod($request->getMethod())) {
                return RequestMatcherInterface::NOMATCH_METHOD;
            }
        }

        return RequestMatcherInterface::NOMATCH;
    }
44686
public function verify(Request $request)
    {
        if (!config('laravel2step.laravel2stepEnabled')) {
            abort(404);
        }

        if ($request->ajax()) {
            $validator = Validator::make($request->all(), [
                'v_input_1' => 'required|min:1|max:1',
                'v_input_2' => 'required|min:1|max:1',
                'v_input_3' => 'required|min:1|max:1',
                'v_input_4' => 'required|min:1|max:1',
            ]);

            if ($validator->fails()) {
                $returnData = $this->invalidCodeReturnData($validator->errors());

                return response()->json($returnData, 418);
            }

            $code = $request->v_input_1.$request->v_input_2.$request->v_input_3.$request->v_input_4;
            $validCode = $this->_twoStepAuth->authCode;

            if ($validCode != $code) {
                $returnData = $this->invalidCodeReturnData();

                return response()->json($returnData, 418);
            }

            $this->resetActivationCountdown($this->_twoStepAuth);

            $returnData = [
                'nextUri' => session('nextUri', '/'),
                'message' => trans('laravel2step::laravel-verification.titlePassed'),
            ];

            return response()->json($returnData, 200);
        } else {
            abort(404);
        }
    }
78709
public function match($request_url = null, $request_method = null)
    {
        // Set Request Url if it isn't passed as parameter
        if ($request_url === null) {
            $request_url = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '/';
        }
        
        $this->request_url = $request_url;
        
        // Set Request Method if it isn't passed as a parameter
        if ($request_method === null) {
            $request_method = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : 'GET';
        }
        
        // Is this an ajax request?
        if (substr($request_url, - 5) == '/ajax') {
            $this->ajax = true;
            $request_url = str_replace('/ajax', '', $request_url);
        } elseif (isset($_GET['ajax'])) {
            $this->ajax = true;
        }
        
        $this->match = parent::match($request_url, $request_method);
        
        if (! empty($this->match)) {
            
            // Some parameters only have control or workflow character and are no parameters for public use.
            // Those will be removed from the parameters array after using them to set corresponding values and/or flags
            // in router.
            $controls = [
                'ajax',
                'format'
            ];
            
            foreach ($controls as $key) {
                
                if (isset($this->match['params'][$key])) {
                    
                    switch ($key) {
                        case 'ajax':
                            $this->ajax = true;
                            break;
                        case 'format':
                            $this->format = $this->match['params'][$key];
                            break;
                        default:
                            $this->{$key} = $this->match['params'][$key];
                    }
                    break;
                }
                
                unset($this->match['params'][$key]);
            }
        }
        
        if (! empty($this->match['params'])) {
            
            foreach ($this->match['params'] as $key => $val) {
                
                if (empty($val)) {
                    unset($this->match['params'][$key]);
                }
                
                if (in_array($key, $this->parameter_to_target)) {
                    $this->match['target'][$key] = $val;
                }
            }
        }
    }
674218
public function match(HttpServletRequestInterface $servletRequest)
    {
        return fnmatch($this->getUrlPattern(), $servletRequest->getServletPath() . $servletRequest->getPathInfo());
    }
1012606
public function matchRoot(&$request)
    {
        // empty means match always.
        if (empty($this->_patterns)) {
            return true;
        }
        $path   = $request->getPathToMatch();
        $method = $request->getMethod();
        foreach ($this->_patterns as $pattern) {
            if ($matched = Matcher::verify($pattern, $path, $method)) {
                if (isset($matched['matched'])) {
                    $request = $request->withPathToMatch($matched['matched'], $matched['trailing']);
                }
                return true;
            }
        }
        return false;
    }
1207922
private function isMatching(RequestInterface $request, &$route): int
    {
        $match = -1;

        $pattern = str_replace('/', '\/', trim($route['pattern'], '/'));
        $pattern = str_replace(array_keys(self::$expressions), array_values(self::$expressions), $pattern);

        if (preg_match('/^' . $pattern . '$/', ltrim($request->getUri()->getPath(), '/'), $matches)) {
            $match = $this->rate($route['target'], $matches);
        }

        return $match;
    }
1222044
public function match(Request $request)
	{
		foreach ($this->routes->filterByMethod($request->getMethod()) as $route)
		{
			if ($route->isMatch($request->getPathInfo()))
			{
				return $route;
			}
		}

		return null;
	}
840085
function checkNonceMatch(context) {
    var newNonce1 = Buffer.concat([utility.string2Buffer(context.newNonce, 32), new Buffer([1]), context.authKeyAuxHash]);
    var newNonceHash = utility.buffer2String(utility.createSHAHash(newNonce1).slice(-16));
    var serverNewNonceHash = context.setClientDHParamsAnswer.new_nonce_hash1;
    if (logger.isDebugEnabled()) {
        logger.debug('newNonceHash = %s, new_nonce_hash1 = %s', newNonceHash.toString(), serverNewNonceHash.toString());
    }
    if (newNonceHash !== serverNewNonceHash) {
        logger.warn('\'dh_gen_ok.new_nonce_hash1\' check fails!');
        throw createError(newNonceHash + ' != ' + serverNewNonceHash, 'EREPLAYATTACK');
    }
    return context;
}
474350
protected function buildFailedValidationResponse(Request $request, array $errors)
    {
        if ($request->expectsJson()) {
            return $this->respondInvalid($errors);
        }

        return parent::buildFailedValidationResponse($request, $errors);
    }
1338987
public function matchRequest(Request $request)
    {
        $this->reset();

        $groups = Arr::get($this->config, 'group', []);
        $matchs = Arr::get($this->config, 'match', []);

        // 全局中间件
        if (isset($matchs['*'])) {
            $wildcards = is_string($matchs['*']) ? (array) $matchs['*'] : $matchs['*'];

            foreach ($wildcards as $alias) {
                if (isset($groups[$alias])) {
                    foreach ($groups[$alias] as $name) {
                        $this->addMatched($name);
                    }
                } else {
                    $this->addMatched($alias);
                }
            }

            unset($wildcards, $matchs['*']);
        }

        // 匹配中间件
        if (count($matchs) > 0) {
            // {{
            $uri = $request->getUri()->getPath();
            // }}
            foreach ($matchs as $pattern => $name) {
                if (preg_match("#{$pattern}#i", $uri)) {
                    $this->addMatched($name);
                }
            }

            unset($uri);
        }

        unset($groups, $matchs);
    }
1236759
public function getMatchingRoute($routes, Request $request)
    {
        foreach ($routes as $matchingRoute) {
            if ($matchingRoute->matches($request)) {
                return $matchingRoute;
            }
        }

        return null;
    }
1045139
public function matches(Request $request, $includingMethod = true)
    {
        // Create compiled route
        $this->compileRoute();

        foreach ($this->getValidators() as $validator) {
            // Check for method validator explicitly
            if (!$includingMethod && $validator instanceof MethodValidator) {
                continue;
            }

            // Check if validator matches
            if (!$validator->matches($this, $request)) {
                return false;
            }
        }

        // All match
        return true;
    }
37250
public int checkNonce(String nonce, HttpRequest request)
    {
        try
        {
            byte[] n = B64Code.decode(nonce.toCharArray());
            if (n.length!=24)
                return -1;
            
            long ts=0;
            long sk=nonceSecret;
            byte[] n2 = new byte[16];
            for (int i=0;i<8;i++)
            {
                n2[i]=n[i];
                n2[8+i]=(byte)(sk&0xff);
                sk=sk>>8;
                ts=(ts<<8)+(0xff&(long)n[7-i]);
            }
            
            long age=request.getTimeStamp()-ts;
	    if (log.isDebugEnabled()) log.debug("age="+age);
            
            byte[] hash=null;
            try
            {
                MessageDigest md = MessageDigest.getInstance("MD5");
                md.reset();
                md.update(n2,0,16);
                hash = md.digest();
            }
            catch(Exception e)
            {
                log.fatal(this,e);
            }
            
            for (int i=0;i<16;i++)
                if (n[i+8]!=hash[i])
                    return -1;
                
            if(maxNonceAge>0 && (age<0 || age>maxNonceAge))
                return 0; // stale
            
            return 1;
        }
        catch(Exception e)
        {
            log.debug("",e);
        }
        return -1;
    }
886758
public function onAuthenticationFailure( Request $request, AuthenticationException $exception )
	{
		// if AJAX login
		if ( ! $request->isXmlHttpRequest() ) {
			throw new NotFoundHttpException('Must use AJAX Login');
		}

		return new JsonResponse(array(
				"success" => false
		));
	}
1047890
public static function get($request, $match)
    {
        $perm = Pluf_Shortcuts_GetObjectOr404('User_Role', $match['role_id']);
        $groupModel = new User_Group();
        $param = array(
            'view' => 'join_role',
            'filter' => array(
                'id=' . $match['group_id'],
                'role_id=' . $perm->id
            )
        );
        $groups = $groupModel->getList($param);
        if ($groups->count() == 0) {
            throw new Pluf_Exception_DoesNotExist('Group has not such role');
        }
        return $groups[0];
    }
430312
private boolean allMatch(final Request request) throws IOException {
        boolean success = true;
        for (final Pass pass : this.all) {
            if (!pass.enter(request).has()) {
                success = false;
                break;
            }
        }
        return success;
    }
45788
public function onAuthenticationFailure(Request $request, AuthenticationException $exception)
    {
        $data = array(
            'message' => strtr($exception->getMessageKey(), $exception->getMessageData())
        );
        $def_response = new JsonResponse($data, 403);

        $event = new CASAuthenticationFailureEvent($request,$exception, $def_response);
        $this->eventDispatcher->dispatch(CASAuthenticationFailureEvent::POST_MESSAGE, $event);

        return $event->getResponse();
    }