public bool Authenticate(HttpApplication application, bool basicAuthenticated, bool anonymAuthenticated)
        {
            var    context = AuthenticationHelper.GetContext(application); //HttpContext.Current;
            var    request = AuthenticationHelper.GetRequest(application);
            bool   headerMark, uriMark;
            string actionHeader, uri, accessHeadAndPayload;

            if (IsTokenAuthenticationRequested(request, out headerMark, out uriMark, out actionHeader, out uri, out accessHeadAndPayload))
            {
                if (basicAuthenticated && anonymAuthenticated)
                {
                    SnLog.WriteException(new UnauthorizedAccessException("Invalid user."));
                    context.Response.StatusCode = HttpResponseStatusCode.Unauthorized;
                    context.Response.Flush();
                    if (application?.Context != null)
                    {
                        application.CompleteRequest();
                    }
                }
                else
                {
                    TokenAuthenticate(basicAuthenticated, headerMark, uriMark, actionHeader, uri, accessHeadAndPayload, context, application);
                }
                return(true);
            }
            return(false);
        }