当前位置: 首页>>代码示例>>C#>>正文


C# IAuthenticationService.Authenticate方法代码示例

本文整理汇总了C#中IAuthenticationService.Authenticate方法的典型用法代码示例。如果您正苦于以下问题:C# IAuthenticationService.Authenticate方法的具体用法?C# IAuthenticationService.Authenticate怎么用?C# IAuthenticationService.Authenticate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IAuthenticationService的用法示例。


在下文中一共展示了IAuthenticationService.Authenticate方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: verify_receive_appropriate_error_message_when_user_provides_a_bad_user_name_or_password

        public void verify_receive_appropriate_error_message_when_user_provides_a_bad_user_name_or_password()
        {
            AuthenticationStatus authStatus = null;
            Story authenticateUserStory = new Story("Authenticate User");

            authenticateUserStory.AsA("Unauthenticated user")
                .IWant("supply my user name and password to the login form")
                .SoThat("I can  authenticate to the application");

            authenticateUserStory
                .WithScenario("User provides an invalid user name")
                .Given("My user name and password are ", "Big Daddy", "Gobldegook", delegate(string userName, string password) { UserRepositoryFactory factory = _mock.DynamicMock<UserRepositoryFactory>();

                                                                                                                                 using (_mock.Record())
                                                                                                                                 {
                                                                                                                                    Expect.Call(factory.Create(userName, password))
                                                                                                                                        .Return(_mock.DynamicMock<IUserRepository>());
                                                                                                                                 }

                                                                                                                                 _user = factory.Create(userName, password); })
                .When("I authenticate the user", delegate {_service = _mock.DynamicMock<IAuthenticationService>();
                                                            using (_mock.Record())
                                                            {
                                                                Expect.Call(_service.Authenticate(_user))
                                                                    .Return(new AuthenticationStatus(new Exception("Bad Username or Password")));
                                                            }
                                                           authStatus = _service.Authenticate(_user);})
                .Then("I should receive an Authentication status of", Status.Failed, delegate(Status expectedStatus) {Assert.AreEqual(expectedStatus, authStatus.Status);});
        }
开发者ID:mmann2943,项目名称:berry-patch,代码行数:29,代码来源:AuthenticateUser.cs

示例2: SecurityModule

        public SecurityModule(IContainer container, IAuthenticationService authenticationService)
        {
            logger.Debug("Instantiate SecurityModule.");

            Post[RouterPattern.Security.VerifyToken] = (parameters =>
            {                
                return parameters;
            });

            Get[RouterPattern.Security.Authenticate] = (parameters =>
            {
                return "test";
            });

            Post[RouterPattern.Security.Authenticate] = parameters =>
            {                
                try
                {
                    var authenticationBody = new StreamReader(this.Request.Body).ReadToEnd();

                    logger.Debug("DeserializeObject IAuthenticationRequest.");
                    var authenticationRequest = JsonIocConvert.DeserializeObject<IAuthenticationRequest>(authenticationBody, container);
                    
                    // check whether the request is valid
                    if (authenticationRequest.IsValid)
                    {
                        logger.Debug("IAuthenticationRequest is valid.");
                        
                        // authenticate the user
                        var authenticatonResult = authenticationService.Authenticate(authenticationRequest.Username, authenticationRequest.Password);
                        
                        // return authentication results as JSON
                        return Response.AsJson<IAuthenticationResult>(authenticatonResult);
                    }
                    else
                    {
                        logger.Warn("IAuthenticationRequest is not valid.");
                        return BadRequest(authenticationService.InvalidRequest());                        
                    }                    
                }
                catch (Exception e)
                {
                    logger.Error(e);
                    // TODO move this away from authentication service (inner method call)
                    return BadRequest(authenticationService.ErrorRequest());
                }
            };          
        }
开发者ID:himmelreich-it,项目名称:opencbs-online,代码行数:48,代码来源:SecurityModule.cs

示例3: verify_receive_appropriate_success_message_when_user_provides_a_good_user_name_and_password

        public void verify_receive_appropriate_success_message_when_user_provides_a_good_user_name_and_password()
        {
            Story authenticateUserStory = new Story("Authenticate User");

            authenticateUserStory.AsA("USer with a valid user name and password")
                .IWant("supply my user name and password to the login form")
                .SoThat("I can authenticate to the application");

            authenticateUserStory
                .WithScenario("User provides a valid user name and password")
                .Given("My user name and password are ", "mmann", "validpassword_1", delegate(string userName, string password) { UserRepositoryFactory factory = _mock.DynamicMock<UserRepositoryFactory>();

                                                                                                                                 using (_mock.Record())
                                                                                                                                 {
                                                                                                                                    Expect.Call(factory.Create(userName, password))
                                                                                                                                        .Return(_mock.DynamicMock<IUserRepository>());
                                                                                                                                 }

                                                                                                                                 _user = factory.Create(userName, password); })
                .When("I authenticate the user", delegate {_service = _mock.DynamicMock<IAuthenticationService>();
                                                            using (_mock.Record())
                                                            {
                                                                Expect.Call(_service.Authenticate(_user))
                                                                    .Return(new AuthenticationStatus());
                                                            }
                                                           _authStatus = _service.Authenticate(_user);})
                .Then("I should receive an Authentication status of", Status.Success, delegate(Status expectedStatus) {Assert.AreEqual(expectedStatus, _authStatus.Status);});
        }
开发者ID:mmann2943,项目名称:berry-patch,代码行数:28,代码来源:AuthenticateUser.cs

示例4: ResolveDependencies

        private void ResolveDependencies(Veyron.App app)
        {
            PaletteManager.ThemesJSon = "[]";
            
            var loggerMock = Mock.Create<IClientLogger>();
            var communicationServiceMock = Mock.Create<ICommunicationService>();
            _authenticateServiceMock = Mock.Create<IAuthenticationService>();
            Mock.Arrange(() => _authenticateServiceMock.Authenticate(Arg.IsAny<string>()))
                .Returns((new TaskCompletionSource<object>()).Task);
            var clientInfoMock = Mock.Create<IClientInfoService>();
            _eventAggregatorMock = Mock.Create<IEventAggregator>();
            var mainViewModelMock = Mock.Create<IShell>();

            app.Logger = loggerMock;
            app.CommunicationService = communicationServiceMock;
            app.AuthenticationService = _authenticateServiceMock;
            app.ClientInfoService = clientInfoMock;
            app.TheEventAggregator = _eventAggregatorMock;
            app.MainViewModel = mainViewModelMock;
        }
开发者ID:mparsin,项目名称:Elements,代码行数:20,代码来源:AppTests.cs


注:本文中的IAuthenticationService.Authenticate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。