예제 #1
0
        private string CheckCredentials(Credentials credentials)
        {
            if (credentials == null)
            {
                throw new ArgumentException("No credentials specified.  Integrated security not enabled.", "credentials");
            }

            string userName = credentials.Username;
            string password = credentials.Password;
            string session  = credentials.Session;

            if (securityWebServiceClient.ValidateUserPassword(userName, password))
            {
                return(userName);
            }

            SimpleSession simpleSession = securityWebServiceClient.FindBySession(session);

            if (simpleSession != null)
            {
                return(simpleSession.UserName);
            }

            string message = string.Format("Invalid Credentials (User:'******', Password:'******', Session:'{2}')",
                                           credentials.Username, credentials.Password, credentials.Session);

            throw new ArgumentException(message, "credentials");
        }
        public void UseSessionIdInCredentials()
        {
            SimpleSecurityWebServiceClient securityWebService = new SimpleSecurityWebServiceClient("User");

            SimpleDataWebServiceClient webServiceClient = new SimpleDataWebServiceClient(database, configuration, securityWebService);

            Assert.Throws <FaultException>(() =>
                                           webServiceClient.GetNavigationHierarchy(new GetNavigationHierarchyRequest()
            {
                Module      = AmplaModules.Production,
                Credentials = new Credentials {
                    Session = Guid.NewGuid().ToString()
                }
            }));

            securityWebService.AddExistingSession("User");

            Assert.That(securityWebService.Sessions, Is.Not.Empty);
            SimpleSession session = securityWebService.Sessions[0];

            webServiceClient.GetNavigationHierarchy(new GetNavigationHierarchyRequest()
            {
                Module      = AmplaModules.Production,
                Credentials = new Credentials {
                    Session = session.SessionId
                }
            });
        }
예제 #3
0
        private void OnStart()
        {
            if (this.IsRunning)
            {
                return;
            }

            try
            {
                SimpleSession <IJobScheduler> newSession = new SimpleSession <IJobScheduler>();
                newSession.Id     = Guid.NewGuid();
                newSession.Parent = this;
                newSession.Time   = AppTime.Now;

                this.Session = newSession;
                this.StartTimer();

                this.RaiseEventHandler(this.Started);
            }
            catch
            {
                this.Session = null;
                this.RaiseEventHandler(this.Stopped);

                throw;
            }
        }
        private void SetSession()
        {
            var session = new SimpleSession();

            session.setUser(new User("REST"));

            [email protected]().setSession(session);
        }
예제 #5
0
        public Session NewSession(Terminal terminal)
        {
            // ask the user to login
            int attempts = 0;

            do
            {
                try
                {
                    // prompt for user name
                    terminal.Echo = true;
                    terminal.Write("Hey, you! Log in. Username: "******"Username: "******"Enter Password: "******"");

                    // authenticate user
                    int UserID = security.Authenticate(username, password);

                    // create a new session and return it
                    SimpleSession session = new SimpleSession(security, filesystem, shells, terminal, UserID);
                    return(session);
                }
                catch (Exception ex)
                {
                    terminal.WriteLine("NOT authenticated");
                    attempts++;
                }
            }while (attempts < 3);
            // user failed authentication too many times
            terminal.WriteLine("Too many attempts! You're out.");
            return(null);
        }