Пример #1
0
        /// <summary>
        /// 登录到线程
        /// </summary>
        /// <param name="id"></param>
        /// <param name="auth"></param>
        /// <returns></returns>
        public virtual UMC.Security.Principal Authorization(Security.AccessToken auth, UMC.Security.Identity id)
        {
            var passDate = Data.Utility.TimeSpan();// DateTime.Now.AddMinutes(-10));

            if (auth.ActiveTime < passDate - 600)
            {
                Data.Reflection.SetProperty(auth, "ActiveTime", passDate);

                this.Activation(auth);
            }
            return(UMC.Security.Principal.Create(id, auth));
        }
Пример #2
0
        public virtual void Activation(Security.AccessToken token)
        {
            int cuttime = UMC.Data.Utility.TimeSpan();

            if (token.Timeout > 0 && ((token.ActiveTime ?? 0) + token.Timeout) < cuttime)
            {
                var at     = AccessToken.Create(UMC.Security.Identity.Create(token.Id.Value, "?", "Guest"), token.Id.Value, token.ContentType, 0);
                var sesion = new Configuration.Session <UMC.Security.AccessToken>(at, token.Id.ToString());
                sesion.ContentType = at.ContentType;
                sesion.Commit(token.Id.Value);
                return;
            }


            switch (token.Username ?? "?")
            {
            case "#":
            case "?":
                break;

            default:
                if (String.IsNullOrEmpty(token.Username) == false)
                {
                    UMC.Data.Database.Instance().ObjectEntity <UMC.Data.Entities.User>()
                    .Where.And(new UMC.Data.Entities.User {
                        Username = token.Username
                    }).Entities
                    .Update(new UMC.Data.Entities.User {
                        ActiveTime = DateTime.Now, SessionKey = token.Id.Value
                    });
                }
                break;
            }
            if (token.UId.HasValue)
            {
                var sesion = new Configuration.Session <UMC.Security.AccessToken>(token, token.Id.ToString());
                sesion.ContentType = token.ContentType;
                sesion.Commit(token.UId.Value);
            }
        }
Пример #3
0
        public override void Activation(Security.AccessToken token)
        {
            var sesion = new Configuration.Session <UMC.Security.AccessToken>(token, token.Id.ToString());

            sesion.ContentType = token.ContentType;

            switch (token.Username ?? "?")
            {
            case "?":
                if (token.SId.HasValue)
                {
                    sesion.Commit(Guid.Empty, token.SId ?? Guid.Empty);
                }
                else
                {
                    sesion.Commit(Guid.Empty, token.Id ?? Guid.Empty);
                }
                break;

            case "#":
                sesion.Commit(Guid.Empty, token.Identity().Id ?? Guid.Empty);
                break;

            default:
                sesion.Commit(Guid.Empty, token.Identity().Id ?? Guid.Empty);

                UMC.Data.Database.Instance().ObjectEntity <UMC.Data.Entities.User>()
                .Where.And(new UMC.Data.Entities.User {
                    Username = token.Username
                }).Entities
                .Update(new User {
                    ActiveTime = DateTime.Now, SessionKey = token.Id.Value
                });
                break;
            }
        }