Пример #1
0
        private void SecretPage(IRequest request, IResponse response)
        {
            var repos         = new SingleRealmRepository("MyRealm");
            var storage       = new DummyUserStorage();
            var authenticator = new DigestAuthenticator(repos, storage);


            if (request.Headers["Authorization"] == null)
            {
                authenticator.CreateChallenge(request, response);
                Send(response);
                return;
            }
            var user = authenticator.Authenticate(request);

            if (user == null)
            {
                response.StatusCode = 403;
                Send(response);
                return;
            }

            response.Body        = new MemoryStream();
            response.ContentType = "text/plain";
            var buffer = Encoding.UTF8.GetBytes(@"Welcome to my secret place");

            response.Body.Write(buffer, 0, buffer.Length);
            response.Body.Position = 0;
            Send(response);
        }
        private void SecretPage(IRequest request, IResponse response)
        {
            var repos = new SingleRealmRepository("MyRealm");
            var storage = new DummyUserStorage();
            var authenticator = new DigestAuthenticator(repos, storage);


            if (request.Headers["Authorization"] == null)
            {
                authenticator.CreateChallenge(request, response);
                Send(response);
                return;
            }
            var user = authenticator.Authenticate(request);
            if (user == null)
            {
                response.StatusCode = 403;
                Send(response);
                return;
            }

            response.Body = new MemoryStream();
            response.ContentType = "text/plain";
            var buffer = Encoding.UTF8.GetBytes(@"Welcome to my secret place");
            response.Body.Write(buffer, 0, buffer.Length);
            response.Body.Position = 0;
            Send(response);
        }