Exemple #1
0
        public IConfigUser GetUser(string id)
        {
            if (id.IsNullOrWhiteSpace())
            {
                return(null);
            }
            IConfigUser user;

            if (Repository.ConfigUsers.Count() == 0)
            {
                user                   = Repository.ConfigUsers.Create();
                user.FirstName         = "";
                user.LastName          = "";
                user.NameId            = id;
                user.AdministratorType = AdministratorTypes.SystemAdmin;
                user.SetAccessToken(UniqueIdGenerator.CreateNewId(20).Encrypt(KeySalt));
                Repository.SaveChanges();
            }
            user = (from u in Repository.ConfigUsers
                    where u.NameId.ToLower().Equals(id.ToLower())
                    select u).Single();
            if (user.AccessToken.IsNullOrWhiteSpace())
            {
                user.SetAccessToken(UniqueIdGenerator.CreateNewId(20).Encrypt(KeySalt));
                cacheManagement.NotifyUserChange(id.ToLower());
                Repository.SaveChanges();
            }
            return(user);
        }
Exemple #2
0
        public void GenerateAccessToken(string id)
        {
            var user = GetUser(id);

            user.SetAccessToken(UniqueIdGenerator.CreateNewId(20).Encrypt(KeySalt));
            Repository.SaveChanges();
            cacheManagement.NotifyUserChange(id.ToLower());
        }
        public string GenerateReaderKey(string id, string environment)
        {
            var env = GetEnvironment(id, environment);

            env.SetReaderKey(UniqueIdGenerator.CreateNewId(20).Encrypt(KeySalt));
            UpdateEnvironment(env);
            return(env.GetReaderKey());
        }
Exemple #4
0
        public string GenerateReaderKey(string id)
        {
            var configSets = from cs in Repository.ConfigSets where cs.Id == id select cs;

            var configSet = configSets.Single();

            configSet.ReaderKey = UniqueIdGenerator.CreateNewId(20).Encrypt(KeySalt);
            UpdateConfigSet(configSet);
            return(configSet.ReaderKey);
        }
Exemple #5
0
        public void CreateUser(IConfigUser newUser)
        {
            var user = Repository.ConfigUsers.Create();

            user.FirstName         = newUser.FirstName;
            user.LastName          = newUser.LastName;
            user.NameId            = newUser.NameId;
            user.AdministratorType = newUser.AdministratorType;
            user.SetAccessToken(UniqueIdGenerator.CreateNewId(20).Encrypt(KeySalt));
            Repository.SaveChanges();
        }
Exemple #6
0
        public void UpdateUser(ConfigUser model)
        {
            var user = GetUser(model.NameId);

            user.FirstName = model.FirstName;
            user.LastName  = model.LastName;
            if (!user.NameId.ToLower().Equals(ConfigReaderFactory.CurrentUser.NameId.ToLower()))
            {
                user.AdministratorType = model.AdministratorType;
            }
            if (user.AccessToken.IsNullOrWhiteSpace())
            {
                user.SetAccessToken(UniqueIdGenerator.CreateNewId(20).Encrypt(KeySalt));
            }
            cacheManagement.NotifyUserChange(model.NameId.ToLower());
            Repository.SaveChanges();
        }
Exemple #7
0
        public IConfigSet GetConfigSet(string id)
        {
            var configSets = from cs in Repository.ConfigSets where cs.Id == id select cs;

            var configSet = configSets.Single();

            if (configSet.ReaderKey.IsNullOrWhiteSpace())
            {
                configSet.SetReaderKey(UniqueIdGenerator.CreateNewId(20).Encrypt(KeySalt));
                UpdateConfigSet(configSet);
            }
            foreach (var env in configSet.Environments)
            {
                if (env.ReaderKey.IsNullOrWhiteSpace())
                {
                    env.SetReaderKey(UniqueIdGenerator.CreateNewId(20).Encrypt(KeySalt));
                    environmentTasks.UpdateEnvironment(env);
                }
            }
            return(configSet);
        }
Exemple #8
0
 public string GenerateReaderKey(IConfigSet configSet)
 {
     configSet.ReaderKey = UniqueIdGenerator.CreateNewId(20).Encrypt(KeySalt);
     return(configSet.ReaderKey);
 }