예제 #1
0
        public void Locale()
        {
            var englishGreatBritain = new Locales(this.DatabaseSession).EnglishGreatBritain;
            var dutchBelgium = new Locales(this.DatabaseSession).DutchBelgium;

            new C1Builder(this.DatabaseSession).WithC1AllorsString("c1A").WithC1AllorsDecimal(10.5M).Build();
            new C1Builder(this.DatabaseSession).WithC1AllorsString("c1B").WithC1AllorsDecimal(11.5M).Build();

            this.DatabaseSession.Derive(true);

            var column1 = new CsvExportPath(C1s.Meta.C1AllorsString);
            var column2 = new CsvExportPath(C1s.Meta.C1AllorsDecimal);

            var export = new CsvExport("Test");
            export.Columns.Add(column1);
            export.Columns.Add(column2);

            var extent = this.DatabaseSession.Extent(C1s.Meta.ObjectType).AddSort(C1s.Meta.C1AllorsString);

            var user = new Users(this.DatabaseSession).GetCurrentUser();
            var acls = new AccessControlListCache(user);

            var csvEn = export.Write(extent, englishGreatBritain, acls);
            var csvNl = export.Write(extent, dutchBelgium, acls);

            Assert.AreNotEqual(csvEn, csvNl);
        }
예제 #2
0
        // TODO: move to security
        public static void AddCreatorSecurityToken(this Domain.Object @this)
        {
            var accessControlledObject = @this as AccessControlledObject;
            if (accessControlledObject != null)
            {
                var creator = new Users(@this.Strategy.Session).GetCurrentAuthenticatedUser();

                if (creator != null)
                {
                    accessControlledObject.AddSecurityToken(creator.OwnerSecurityToken);
                }
            }
        }
예제 #3
0
        public Derivation(ISession session)
        {
            this.session = session;
            this.log = new DerivationLog(this);

            this.derivedObjects = new HashSet<Object>();
            this.preparedObjects = new HashSet<IObject>();
            this.changeSet = session.Checkpoint();

            this.generation = 0;

            var user = new Users(session).GetCurrentUser();
        }
예제 #4
0
파일: Auditable.cs 프로젝트: Mathus/dipu
        public static void DipuOnDerive(this Auditable @this, ObjectOnDerive method)
        {
            var derivation = method.Derivation;
            var user = new Users(@this.Strategy.Session).GetCurrentAuthenticatedUser();

            if (user != null)
            {
                var changeSet = derivation.ChangeSet;
                if (changeSet.Created.Contains(@this.Id))
                {
                    @this.CreationDate = DateTime.UtcNow;
                    @this.CreatedBy = user;
                }

                if (changeSet.Associations.Contains(@this.Id))
                {
                    @this.LastModifiedDate = DateTime.UtcNow;
                    @this.LastModifiedBy = user;
                }
            }
        }
예제 #5
0
        public override string[] GetRolesForUser(string username)
        {
            var roles = new List<string>();
            if (!string.IsNullOrWhiteSpace(username))
            {
                var database = Config.Default;

                using (ISession session = database.CreateSession())
                {
                    var user = new Users(session).FindBy(Users.Meta.UserName, username);
                    if (user != null)
                    {
                        foreach (UserGroup userGroup in user.UserGroupsWhereMember)
                        {
                            roles.Add(userGroup.Name);
                        }
                    }
                }
            }

            return roles.ToArray();
        }
예제 #6
0
        public override bool ValidateUser(string userId, string password)
        {
            var database = Config.Default;
            using (ISession session = database.CreateSession())
            {
                var user = new Users(session).FindBy(Users.Meta.UserName, userId);
                if (user != null)
                {
                    if (user.ExistUserPasswordHash)
                    {
                        var passwordHasher = new PasswordHasher();
                        return passwordHasher.VerifyHashedPassword(user.UserPasswordHash, password) != PasswordVerificationResult.Failed;
                    }

                    return false;
                }

                return false;
            }
        }
예제 #7
0
        public override MembershipUser GetUser(string userId, bool userIsOnline)
        {
            var database = Config.Default;
            using (ISession session = database.CreateSession())
            {
                var user = new Users(session).FindBy(Users.Meta.UserName, userId);
                if (user != null)
                {
                    return this.CreateMembershipUser(user);
                }

                session.Rollback();
            }

            return null;
        }