private AuthenticationResult Authorise(string userName, string password)
        {
            ICommandHandlerStrategy             commandHandlerStrategy = CommandHandlerStrategyFactory.Create <User>();
            UserNameAndPwdAuthenticationRequest request = new UserNameAndPwdAuthenticationRequest(userName, password);

            commandHandlerStrategy.Execute(request);
            return(request.Result);
        }
        public override void Execute(TaskArgument <System.Web.HttpApplication> context)
        {
            ICommandHandlerStrategy commandHandlerStrategy = CommandHandlerStrategyFactory.Create <User>();
            CreateUserCommand       request = this.CreateUserCommand();

            commandHandlerStrategy.Execute(request);

            ILogger logger = IoC.Container.Resolve <ILogger>();

            logger.Info("New user created with Id:{0}", request.Result);
        }
Ejemplo n.º 3
0
        private AuthenticationResult Authorise(IHeaderDictionary headers)
        {
            string[] acceptLanguageValues;
            bool     acceptLanguageHeaderPresent = headers.TryGetValue(Constants.AUTHENTICATION_TOKEN, out acceptLanguageValues);

            if (!acceptLanguageHeaderPresent)
            {
                return(null);
            }
            string[] elementsInHeader = acceptLanguageValues.ToList()[0].Split(new string[] { Constants.AUTHENTICATION_TOKEN_SEPERATOR }, StringSplitOptions.RemoveEmptyEntries);
            string   userName         = elementsInHeader[0];
            string   pwd = elementsInHeader[1];

            ICommandHandlerStrategy             commandHandlerStrategy = CommandHandlerStrategyFactory.Create <User>();
            UserNameAndPwdAuthenticationRequest request = new UserNameAndPwdAuthenticationRequest(userName, pwd);

            commandHandlerStrategy.Execute(request);
            return(request.Result);
        }