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); }
// 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); } } }
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(); }
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; } } }
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(); }
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; } }
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; }