示例#1
0
        public bool Authenticate(ExtendedApplicationBase app)
        {
            AuthenticationWindow loadingWindow = new AuthenticationWindow();

            loadingWindow.Show();

            var account  = app.Properties[app.PROPERTY_ACCOUNT];
            var password = app.Properties[app.PROPERTY_PASSWORD];

            if (account == null || password == null)
            {
                loadingWindow.Close();
                return(false);
            }

            if (Authenticate(account.ToString(), password.ToString()))
            {
                //1. 获取用户信息
                UserWorkRequest request  = new UserWorkRequest();
                var             identity = new Identity(account.ToString(), true);
                app.Context.User = new Principal(request, identity);
                Thread.Sleep(5000);
                loadingWindow.Close();

                return(true);
            }
            loadingWindow.Close();
            return(false);
        }
示例#2
0
        public Principal(UserWorkRequest request, IIdentity identity)
        {
            if(request == null)
            {
                throw new FatalException("request arguement can't be null.");
            }
            if(identity == null) {
                throw new FatalException("identity arguement can't be null.");
            }

            _request = request;
            _identity = identity;
        }
示例#3
0
        public Principal(UserWorkRequest request, IIdentity identity)
        {
            if (request == null)
            {
                throw new FatalException("request arguement can't be null.");
            }
            if (identity == null)
            {
                throw new FatalException("identity arguement can't be null.");
            }

            _request  = request;
            _identity = identity;
        }