Exemple #1
0
        protected string GetUserInfo()
        {
            var key = HttpContext.GetToken(WebConfiguration.Instance.ConfigSecurityTokenName);


            if (string.IsNullOrEmpty(key))
            {
                return(string.Empty);
            }

            IUserSnap user = Reception.Instance.GetUser(key, LoginType.Web);

            //IUserInfo user = WinWebGlobalManager.Reception.GetUserInfo(key);
            if (user == null)
            {
                user = GetService <IProfile>().GetUserSnap(key, LoginType.Web);
            }
            if (user == null)
            {
                return(string.Empty);
            }
            //WinWebGlobalManager.Reception.Sign(HttpContext, user);
            string _u = user.ToXml();

            return(_u);
        }
Exemple #2
0
 public SessionSnap(IUserSnap user)
 {
     UserSnap = user;
     LastTime = DateTime.Now;
     //SecurityToken = user.SecurityKey;
     _securityToken = string.Format("{0}{1}{2}", user.Id, user.Account, user.LoginCode).ToMD5();
 }
Exemple #3
0
        public T GetService <T>(IUserSnap me) where T : ITripBusiness
        {
            var ibusiness = AutofacResolver.Instance.GetService <T>();

            ibusiness.SetUserSnap(me);
            return(ibusiness);
        }
Exemple #4
0
 public void SetUserSnap(IUserSnap snap)
 {
     if (_me == null || _me.Account != snap.Account)
     {
         _me = snap;
     }
 }
Exemple #5
0
 public SessionSnap(IUserSnap user)
 {
     UserSnap = user;
     LastTime = DateTime.Now;
     //SecurityToken = user.SecurityKey;
     _securityToken = string.Format("{0}{1}{2}", user.Id, user.Account, user.LoginCode).ToMD5();
 }
Exemple #6
0
        public bool IsAuthorized(IUserSnap user)
        {
            IUserSnap snap = GetUser(user.SecurityKey, user.LoginType);

            if (snap == null)
            {
                return(false);
            }
            return(_session_manager.IsValid(user));
        }
Exemple #7
0
 public string Add(IUserSnap snap)
 {
     Refresh();
     ISessionSnap session = _session_snaps.SingleOrDefault(s => s.UserSnap.SecurityKey == snap.SecurityKey);
     if (session == null)
     {
         session = new SessionSnap(snap);
         _session_snaps.Add(session);
     }
     return session.SecurityToken;
 }
Exemple #8
0
        public string Add(IUserSnap snap)
        {
            Refresh();
            ISessionSnap session = _session_snaps.SingleOrDefault(s => s.UserSnap.SecurityKey == snap.SecurityKey);

            if (session == null)
            {
                session = new SessionSnap(snap);
                _session_snaps.Add(session);
            }
            return(session.SecurityToken);
        }
Exemple #9
0
        public IUserSnap GetUser(string securitytoken, LoginType type)
        {
            IUserSnap snap = _session_manager.Get(securitytoken);

            if (snap == null)
            {
                _usersnap_loader.SetResource(WebConfiguration.Instance.WebUpdateUserAddress);
                snap = _usersnap_loader.Load(securitytoken, type);
                if (snap == null)
                {
                    return(snap);
                }
                _session_manager.Add(snap);
            }
            return(snap);
        }
Exemple #10
0
 public bool IsValidUser(IUserSnap snap)
 {
     return _securityToken.Equals(string.Format("{0}{1}{2}", snap.Id, snap.Account, snap.LoginCode).ToMD5());
 }
Exemple #11
0
 public bool IsAuthorized(IUserSnap user)
 {
     IUserSnap snap = GetUser(user.SecurityKey, user.LoginType);
     if (snap == null) return false;
     return _session_manager.IsValid(user);
 }
Exemple #12
0
 public void SaveCookies(HttpContextBase context, IUserSnap user)
 {
     context.SaveCookie(WebConfiguration.Instance.ConfigAccountTokenName, user.Account, WebConfiguration.Instance.ConfigDomainName);
     context.SaveCookie(WebConfiguration.Instance.ConfigIdTokenName, user.Id, WebConfiguration.Instance.ConfigDomainName);
     context.SaveCookie(WebConfiguration.Instance.ConfigSecurityTokenName, user.SecurityKey, WebConfiguration.Instance.ConfigDomainName);
 }
Exemple #13
0
 public void SaveCookies(HttpContextBase context, IUserSnap user)
 {
     context.SaveCookie(WebConfiguration.Instance.ConfigAccountTokenName, user.Account, WebConfiguration.Instance.ConfigDomainName);
     context.SaveCookie(WebConfiguration.Instance.ConfigIdTokenName, user.Id, WebConfiguration.Instance.ConfigDomainName);
     context.SaveCookie(WebConfiguration.Instance.ConfigSecurityTokenName, user.SecurityKey, WebConfiguration.Instance.ConfigDomainName);
 }
Exemple #14
0
 public bool IsValid(IUserSnap snap)
 {
     ISessionSnap session = _session_snaps.SingleOrDefault(s => s.UserSnap.SecurityKey == snap.SecurityKey);
     return session.IsValidUser(snap);
 }
Exemple #15
0
 public bool IsValidUser(IUserSnap snap)
 {
     return(_securityToken.Equals(string.Format("{0}{1}{2}", snap.Id, snap.Account, snap.LoginCode).ToMD5()));
 }
Exemple #16
0
        public bool IsValid(IUserSnap snap)
        {
            ISessionSnap session = _session_snaps.SingleOrDefault(s => s.UserSnap.SecurityKey == snap.SecurityKey);

            return(session.IsValidUser(snap));
        }