public PersonGroupAssociationSyncManager(SWDBHibernateDAO dao, IConfigurationFacade facade, HlagLocationManager locationManager, PersonGroupSyncManager personGroupSyncManager, HapagPersonGroupHelper hapagHelper, EntityRepository repository) : base(dao, facade, repository) { _locationManager = locationManager; _personGroupSyncManager = personGroupSyncManager; _hapagHelper = hapagHelper; }
public IGenericResponseResult Submit(string password) { var user = SecurityFacade.CurrentUser(); var authorized = false; var adminUser = new SWDBHibernateDAO().FindSingleByQuery <User>(sW4.Security.Entities.User.UserByUserName, "swadmin"); if (adminUser.Password != null) { var authenticatedAdminUser = SecurityFacade.GetInstance().Login(adminUser, password, string.Empty); if (authenticatedAdminUser != null) { if (!user.IsInRole(Role.SysAdmin)) { var adminRole = _dao.FindSingleByQuery <Role>(Role.RoleByName, Role.SysAdmin); user.Roles.Add(adminRole); } if (!user.IsInRole(Role.ClientAdmin)) { var clientRole = _dao.FindSingleByQuery <Role>(Role.RoleByName, Role.ClientAdmin); user.Roles.Add(clientRole); } authorized = true; } } return(new GenericResponseResult <bool>(authorized)); }
public static ICollection <UserProfile> FetchAllProfiles(Boolean eager) { var before = Stopwatch.StartNew(); if (ProfileCache.Count != 0) { return(ProfileCache.Values); } using (var session = SWDBHibernateDAO.CurrentSession()) { using (var transaction = session.BeginTransaction()) { var query = DAO.BuildQuery("from UserProfile", (object[])null, session); var dbProfiles = query.List(); var profiles = new Dictionary <string, UserProfile>(); foreach (var profile in dbProfiles) { var userProfile = (UserProfile)profile; if (eager) { NHibernateUtil.Initialize(userProfile.Roles); NHibernateUtil.Initialize(userProfile.DataConstraints); } profiles.Add(userProfile.Name, userProfile); ProfileCache.Add(userProfile.Id, userProfile); } Log.Info(LoggingUtil.BaseDurationMessage("Profiles Loaded in {0}", before)); return(profiles.Values); } } }
public HlagLocationManager(SWDBHibernateDAO dao, MaximoHibernateDAO maxDAO, EntityRepository repository, IContextLookuper contextLookuper) { _dao = dao; _repository = repository; _personEntity = MetadataProvider.Entity("person"); _contextLookuper = contextLookuper; _maxDAO = maxDAO; }
private SWDBHibernateDAO GetDAO() { if (_dao == null) { _dao = SimpleInjectorGenericFactory.Instance.GetObject <SWDBHibernateDAO>(typeof(SWDBHibernateDAO)); } return(_dao); }
public ConfigurationController(CategoryTreeCache cache, ConfigurationService configService, I18NResolver resolver, SWDBHibernateDAO dao, ConditionService conditionService) { _cache = cache; _configService = configService; _resolver = resolver; _dao = dao; _conditionService = conditionService; }
public static void LoadActiveRoles() { var before = Stopwatch.StartNew(); var activeRoles = new SWDBHibernateDAO().FindByQuery <Role>("from Role where Active = true"); _activeRoles = new HashSet <Role>(activeRoles); Log.Info(LoggingUtil.BaseDurationMessage("Active Roles Loaded in {0}", before)); }
//TODO: remove customUserRoles and customUSerCOnstraints which were exclusions from this profile ==> They don´t make sense anymore (tough,they are useless anyway) public static void DeleteProfile(UserProfile profile) { using (ISession session = SWDBHibernateDAO.CurrentSession()) { using (ITransaction transaction = session.BeginTransaction()) { DAO.Delete(profile); if (ProfileCache.ContainsKey(profile.Id)) { ProfileCache.Remove(profile.Id); } } } }
public InMemoryUser Login(string userName, string password, string userTimezoneOffset) { var shaPassword = AuthUtils.GetSha1HashData(password); var md5Password = AuthUtils.GetHashData(password, SHA256.Create()); var dbUser = new SWDBHibernateDAO().FindSingleByQuery <User>(LoginQuery, userName); if (dbUser == null || !MatchPassword(dbUser, password)) { return(null); } return(UserFound(dbUser, userTimezoneOffset)); }
public static void DeleteRole(Role role) { using (ISession session = SWDBHibernateDAO.CurrentSession()) { using (ITransaction transaction = session.BeginTransaction()) { DAO.ExecuteSql("delete from sw_userprofile_role"); DAO.ExecuteSql("delete from sw_user_customrole"); DAO.Delete(role); Role oldRole = _activeRoles.FirstOrDefault(r => r.Id == role.Id); if (oldRole != null) { _activeRoles.Remove(oldRole); } } } }
public GenericResponseResult <UserProfileListDto> Get(Boolean refreshRoles = true) { //maybe if the number of profiles gets too big, we should lazy-fetch them, in a way to retrieve less data to the list screen var profiles = SecurityFacade.FetchAllProfiles(true); IList <Role> roles = new List <Role>(); if (refreshRoles) { roles = new SWDBHibernateDAO().FindByQuery <Role>("from Role order by name"); } var dto = new UserProfileListDto { Profiles = profiles, Roles = roles }; return(new GenericResponseResult <UserProfileListDto>(dto)); }
public GenericResponseResult <UserListDto> List(bool refreshData = true) { var users = new SWDBHibernateDAO().FindByQuery <User>("select new User(id,UserName,FirstName,LastName,IsActive) from User order by UserName"); ICollection <UserProfile> profiles = new List <UserProfile>(); IList <Role> roles = new List <Role>(); if (refreshData) { roles = new SWDBHibernateDAO().FindByQuery <Role>("from Role order by name"); profiles = SecurityFacade.FetchAllProfiles(true); } return(new GenericResponseResult <UserListDto>(new UserListDto { Users = users, Roles = roles, Profiles = profiles })); }
public static InMemoryUser CurrentUser(Boolean fetchFromDB = true, bool throwAnonymousException = true) { if (ApplicationConfiguration.IsUnitTest) { return(InMemoryUser.TestInstance("test")); } var currLogin = LogicalThreadContext.GetData <string>("user") ?? CurrentPrincipalLogin; if (currLogin == "") { if (!throwAnonymousException) { return(new InMemoryUser { Login = "******" }); } throw new UnauthorizedAccessException(); } if (!fetchFromDB || currLogin == null || _users.ContainsKey(currLogin)) { return(_users[currLogin]); } //cookie authenticated already //TODO: remove this in prod? var dbUser = new SWDBHibernateDAO().FindSingleByQuery <User>(User.UserByUserName, currLogin); if (dbUser == null) { throw new InvalidOperationException("user should exist at DB"); } var formsIdentity = CurrentPrincipal.Identity as System.Web.Security.FormsIdentity; var timezone = String.Empty; if (formsIdentity != null && formsIdentity.Ticket != null && !String.IsNullOrWhiteSpace(formsIdentity.Ticket.UserData)) { var userData = PropertyUtil.ConvertToDictionary(formsIdentity.Ticket.UserData); timezone = userData["userTimezoneOffset"]; } UserFound(dbUser, timezone); return(_users[currLogin]); }
private InMemoryUser GetUser(string userName, string password, string userTimezoneOffset) { var userAux = new SWDBHibernateDAO().FindSingleByQuery <User>(sW4.Security.Entities.User.UserByUserName, userName); var allowNonUsersToLogin = "******".Equals(MetadataProvider.GlobalProperty("ldap.allownonmaximousers")); if (userAux == null) { if (!allowNonUsersToLogin) { //user not found and we will not create a new one --> fail return(null); } //if this flag is true, we will create the user on the fly var ldapResult = _ldapManager.LdapAuth(userName, password); if (ldapResult.Success) { userAux = UserManager.CreateMissingDBUser(userName); if (userAux == null) { //user might not exist on maximo either, in that case we should block its access return(null); } return(SecurityFacade.GetInstance().LdapLogin(userAux, userTimezoneOffset)); } return(null); } //this will trigger default ldap auth ==> The user already exists in our database if (userAux.Password == null) { var ldapResult = _ldapManager.LdapAuth(userName, password); if (ldapResult.Success) { return(SecurityFacade.GetInstance().LdapLogin(userAux, userTimezoneOffset)); } return(null); } var user = SecurityFacade.GetInstance().Login(userAux, password, userTimezoneOffset); return(user); }
public static Role SaveUpdateRole(Role role) { bool updatingRole = role.Id != null; role = new SWDBHibernateDAO().Save(role); if (updatingRole) { Role oldRole = _activeRoles.FirstOrDefault(r => r.Id == role.Id); if (oldRole != null) { _activeRoles.Remove(oldRole); } } if (role.Active) { _activeRoles.Add(role); } return(role); }
public List <PersonGroup> UpdateCacheOnSync(IEnumerable <PersonGroup> personGroupsToIntegrate) { var toInsert = new List <PersonGroup>(); var toUpdate = new List <PersonGroup>(); foreach (var group in personGroupsToIntegrate) { if (!AllGroupsCached.ContainsKey(group.Name)) { AllGroupsCached.Add(group.Name, group); toInsert.Add(group); } else if (AllGroupsCached[group.Name].Rowstamp != group.Rowstamp) { group.Id = AllGroupsCached[group.Name].Id; AllGroupsCached[group.Name] = group; toUpdate.Add(group); } } _dao.BulkSave(toInsert); using (var session = SWDBHibernateDAO.CurrentSession()) { using (var transaction = session.BeginTransaction()) { foreach (var personGrop in toUpdate) { var dbGroup = _dao.FindByPK <PersonGroup>(typeof(PersonGroup), personGrop.Id); dbGroup.Description = personGrop.Description; dbGroup.Rowstamp = personGrop.Rowstamp; _dao.Save(dbGroup); } transaction.Commit(); } } toInsert.AddRange(toUpdate); return(toInsert); }
public UserSyncManager(SWDBHibernateDAO dao, IConfigurationFacade facade, EntityRepository repository) : base(dao, facade, repository) { }
protected BaseISMDecorator() { DAO = SimpleInjectorGenericFactory.Instance.GetObject <SWDBHibernateDAO>(typeof(SWDBHibernateDAO)); }
public HapagProfileInitializer(SWDBHibernateDAO dao) { _dao = dao; }
public MakeSWAdminController(SWDBHibernateDAO dao) { _dao = dao; }
public IsmChangeCrudConnector() { _dao = SimpleInjectorGenericFactory.Instance.GetObject <SWDBHibernateDAO>(typeof(SWDBHibernateDAO)); }
public R0042ExtractorJob(EntityRepository entityRepository, IConfigurationFacade configFacade, SWDBHibernateDAO dao) { _entityRepository = entityRepository; ConfigFacade = configFacade; DAO = dao; }
public HapagInitializer(SWDBHibernateDAO dao, HapagRoleInitializer hapagRoleInitializer, HapagProfileInitializer hapagProfileInitializer) { _dao = dao; _hapagRoleInitializer = hapagRoleInitializer; _hapagProfileInitializer = hapagProfileInitializer; }
public DbUserInitializer(SWDBHibernateDAO dao) { _dao = dao; }
public GenericResponseResult <IList <Role> > Get() { var roles = new SWDBHibernateDAO().FindByQuery <Role>("from Role order by name"); return(new GenericResponseResult <IList <Role> >(roles)); }
public ConditionService(SWDBHibernateDAO dao) { _dao = dao; }
public ComInitializer(SWDBHibernateDAO dao, ComProfileInitializer comProfileInitializer) { _dao = dao; _comProfileInitializer = comProfileInitializer; }
public HapagPersonGroupHelper(SWDBHibernateDAO dao) { this._dao = dao; }
public ComConfigurationRegistry(IConfigurationFacade facade, IWhereClauseFacade wcFacade, SWDBHibernateDAO dao) { _wcFacade = wcFacade; _facade = facade; }
public CategoryTreeCache(SWDBHibernateDAO dao) { _dao = dao; }