Example #1
0
        public bool Authenticate(string username, string password)
        {
            //Run auth through the auth svc to get an identity
            AuthenticateService authsvc = new AuthenticateService();

            try {
                authsvc.Url = String.Format("http://{0}/FrontDeskServices/authsvc.asmx",
                                            TestConfig.AuthenticationAddress);
                Authentication.ServiceTicket     tik    = authsvc.Authenticate(username, password);
                FrontDesk.Services.ServiceTicket ticket = new FrontDesk.Services.ServiceTicket();
                ticket.HostAddress = tik.HostAddress;
                ticket.Username    = tik.Username;
                ticket.Ident       = tik.Ident;
                m_ident            = AuthorizedIdent.Create(ticket);
                if (m_ident != null)
                {
                    m_logger.Log("Authentication for: " + username +
                                 " succeeded.");
                    return(true);
                }
                else
                {
                    m_logger.Log("Authentication for: " + username +
                                 " failed.", TestLogger.LogType.ERROR);
                    return(false);
                }
            } catch (Exception er) {
                m_logger.Log("Error during authentication: MESSAGE: " + er.Message,
                             TestLogger.LogType.ERROR);
                return(false);
            }
        }
Example #2
0
        protected AuthorizedIdent AuthenticateTicket(ServiceTicket ticket)
        {
            AuthorizedIdent ident = AuthorizedIdent.Create(ticket);
            if (ident == null)
                throw new ServiceAuthenticationException("Unable to authenticate ticket because some aspect of it is invalid. You session may have expired or you may have switched to another machine (and somehow saved the ticket). Please login again");

            return ident;
        }
Example #3
0
        protected AuthorizedIdent AuthenticateTicket(ServiceTicket ticket)
        {
            AuthorizedIdent ident = AuthorizedIdent.Create(ticket);

            if (ident == null)
            {
                throw new ServiceAuthenticationException("Unable to authenticate ticket because some aspect of it is invalid. You session may have expired or you may have switched to another machine (and somehow saved the ticket). Please login again");
            }

            return(ident);
        }
Example #4
0
        public ServiceTicket Authenticate(string username, string password)
        {
            if (new Users(null).IsValid(username, password)) {
                ServiceTicket tik = new ServiceTicket();
                tik.Username = username;
                tik.Ident = Guid.NewGuid();
                tik.HostAddress = Context.Request.UserHostAddress;

                //Create session
                new Sessions(null).Create(tik.Ident, tik.Username, tik.HostAddress);

                return tik;
            } else
                throw new ServiceAuthenticationException("Username or password invalid");
        }
Example #5
0
        public ServiceTicket Authenticate(string username, string password)
        {
            if (new Users(null).IsValid(username, password))
            {
                ServiceTicket tik = new ServiceTicket();
                tik.Username    = username;
                tik.Ident       = Guid.NewGuid();
                tik.HostAddress = Context.Request.UserHostAddress;

                //Create session
                new Sessions(null).Create(tik.Ident, tik.Username, tik.HostAddress);

                return(tik);
            }
            else
            {
                throw new ServiceAuthenticationException("Username or password invalid");
            }
        }
Example #6
0
        /// <summary>
        /// Create an identity from a service created service ticket
        /// </summary>
        public static AuthorizedIdent Create(ServiceTicket ticket)
        {
            ServiceTicket tik;
            if (ticket == null)
                return null;
            else {
                Session ses = new Sessions(null).GetInfo(ticket.Ident);
                if (ses == null)
                    return null;

                tik = new ServiceTicket();
                tik.Username = ses.Username; tik.HostAddress = ses.Address;
                tik.Ident = ses.Identifier;
            }

            if (tik.Username != ticket.Username)
                return null;
            else if (tik.HostAddress != ticket.HostAddress)
                return null;
            else
                return new AuthorizedIdent(tik.Username);
        }
Example #7
0
 public bool Authenticate(string username, string password)
 {
     //Run auth through the auth svc to get an identity
     AuthenticateService authsvc = new AuthenticateService();
     try {
         authsvc.Url = String.Format("http://{0}/FrontDeskServices/authsvc.asmx",
             TestConfig.AuthenticationAddress);
         Authentication.ServiceTicket tik = authsvc.Authenticate(username, password);
         FrontDesk.Services.ServiceTicket ticket = new FrontDesk.Services.ServiceTicket();
         ticket.HostAddress = tik.HostAddress;
         ticket.Username = tik.Username;
         ticket.Ident = tik.Ident;
         m_ident = AuthorizedIdent.Create(ticket);
         if (m_ident != null) {
             m_logger.Log("Authentication for: " + username +
                 " succeeded.");
             return true;
         }
         else {
             m_logger.Log("Authentication for: " + username +
                 " failed.", TestLogger.LogType.ERROR);
             return false;
         }
     } catch (Exception er) {
         m_logger.Log("Error during authentication: MESSAGE: " + er.Message,
             TestLogger.LogType.ERROR);
         return false;
     }
 }