Example #1
0
        /// <summary>
        /// Checks for user by username and password and sets the cookie
        /// </summary>
        /// <param name="Username">Username</param>
        /// <param name="Password">Password</param>
        /// <param name="RequestObject">Request</param>
        /// <param name="ResponseObject">Response</param>
        /// <param name="CacheObject">Cache</param>
        /// <returns>Returns user associated with the username and password pair</returns>
        public static Actor GetByUserPass(string Username, string Password, HttpRequestBase RequestObject, HttpResponseBase ResponseObject, bool UseCache, GetByUserPassDelegate ActorDelegate)
        {
            Actor actor = null;

            if (String.IsNullOrEmpty(Username))
                return null;

            if (UseCache)
            {
                string cKey = Configuration.UserCache + Username + "_" + Password;
                actor = (Actor)CacheHelper.GetCache(cKey);
                if (actor == null)
                {
                    actor = ActorDelegate(Username, Password);
                    if (actor != null)
                    {
                        CacheHelper.AddCache(actor, cKey, new string[] { Configuration.DefaultCodeListName });
                    }
                }
            }
            else
            {
                actor = ActorDelegate(Username, Password);
            }

            if (actor != null)
            {
                CookieHelper.CreateCookie(RequestObject, ResponseObject, Configuration.LoginCookieName, Configuration.LoginCookieUser, actor.Username);
                CookieHelper.CreateCookie(RequestObject, ResponseObject, Configuration.LoginCookieName, Configuration.LoginCookiePass, actor.Password);
            }

            return actor;
        }
Example #2
0
 /// <summary>
 /// Checks for user if cookie is set and refreshes the cookie
 /// </summary>
 /// <param name="RequestObject">Request </param>
 /// <param name="ResponseObject">Response</param>
 /// <param name="CacheObject">Cache</param>
 /// <returns>Returns user associated with the cookie object</returns>
 public static Actor GetByUserPass(HttpRequest RequestObject, HttpResponse ResponseObject, bool UseCache, GetByUserPassDelegate ActorDelegate)
 {
     string user = CookieHelper.CookieValue(RequestObject, Configuration.LoginCookieName, Configuration.LoginCookieUser);
     string pass = CookieHelper.CookieValue(RequestObject, Configuration.LoginCookieName, Configuration.LoginCookiePass);
     return Actor.GetByUserPass(user, pass, RequestObject, ResponseObject, UseCache, ActorDelegate);
 }
Example #3
0
 public static Actor GetByUserPass(string Username, string Password, HttpRequest RequestObject, HttpResponse ResponseObject, bool UseCache, GetByUserPassDelegate ActorDelegate)
 {
     return GetByUserPass(Username, Password, new HttpRequestWrapper(RequestObject),
                          new HttpResponseWrapper(ResponseObject), UseCache, ActorDelegate);
 }
Example #4
0
 /// <summary>
 /// Checks if user is logged in and valid and refreshes the login cookie
 /// </summary>
 /// <param name="RequestObject">Request</param>
 /// <param name="ResponseObject">Response</param>
 /// <param name="CacheObject">Cache</param>
 /// <returns>True if user is logged in and valid, false if not</returns>
 public virtual bool CheckLoginAndRefreshCookie(HttpRequest RequestObject, HttpResponse ResponseObject, bool UseCache, GetByUserPassDelegate ActorDelegate)
 {
     return CheckLoginAndRefreshCookie(new HttpRequestWrapper(RequestObject),
                                       new HttpResponseWrapper(ResponseObject), UseCache, ActorDelegate);
 }
Example #5
0
 /// <summary>
 /// Checks if user is logged in and valid and refreshes the login cookie
 /// </summary>
 /// <param name="RequestObject">Request</param>
 /// <param name="ResponseObject">Response</param>
 /// <param name="CacheObject">Cache</param>
 /// <returns>True if user is logged in and valid, false if not</returns>
 public virtual bool CheckLoginAndRefreshCookie(HttpRequestBase RequestObject, HttpResponseBase ResponseObject, bool UseCache, GetByUserPassDelegate ActorDelegate)
 {
     string user = CookieHelper.CookieValue(RequestObject, Configuration.LoginCookieName, Configuration.LoginCookieUser);
     string pass = CookieHelper.CookieValue(RequestObject, Configuration.LoginCookieName, Configuration.LoginCookiePass);
     if (!string.IsNullOrEmpty(user) && !string.IsNullOrEmpty(pass))
     {
         Actor actor = Actor.GetByUserPass(user, pass, RequestObject, ResponseObject, UseCache, ActorDelegate);
         if (actor != null)
         {
             return (actor.Id == this.Id);
         }
         else
             return false;
     }
     else
         return false;
 }
Example #6
0
        /// <summary>
        /// Gets user by Cookie values
        /// </summary>
        /// <param name="cookie">AES encrypted cookie</param>
        /// <returns>Returns user associated with the username and password pair</returns>
        public static Actor GetByCookieString(string cookie, GetByUserPassDelegate ActorDelegate)
        {
            string username = CookieHelper.CookieValue(cookie, Configuration.LoginCookieUser);
            string pass = CookieHelper.CookieValue(cookie, Configuration.LoginCookiePass);

            return ActorDelegate(username, pass);
        }