コード例 #1
0
        /// <summary>
        /// This instance is allowed to call only from test bed - todo security
        /// </summary>
        /// <param name="userName">The logged in user name</param>
        /// <param name="rbacName">The overridden rbac name, empty will use user's default</param>
        /// <param name="roleName">The overriden role name, empty will use user's default</param>
        public Rbac(string userName, string rbacName, string roleName)
        {
            //no cache will be implemented

            DataManager.Manager manager = new DataManager.Manager(false);
            RbacUser            user    = new RbacUser(userName);

            if (!string.IsNullOrEmpty(roleName))
            {
                user.Role = new RbacRole(roleName);  //override role
            }
            if (user.Role == null)
            {
                RbacException.Raise(string.Format("The role '{0}' is not found!", roleName), RbacExceptionCategories.Repository);
            }

            Rbac dbRbac = null;

            if (!string.IsNullOrEmpty(rbacName))
            {
                dbRbac = manager.GetRbac(rbacName);     //override rbac
            }
            else
            {
                dbRbac = manager.GetRbac(user.Role.RbacId);
            }

            if (dbRbac == null)
            {
                RbacException.Raise(string.Format("The rbac '{0}' was not defined yet!", rbacName), RbacExceptionCategories.Repository);
            }

            dbRbac.User = user;
            Assign(dbRbac);
        }
コード例 #2
0
        public static RbacUser CreateUser(string userName, string fullName, string email, string password, RbacRole role)
        {
            RbacUser user = new RbacUser(userName, fullName, email, role);

            ChangePassword(user.UserName, RbacCache.TempPassword, password);
            return(user);
        }
コード例 #3
0
ファイル: ExtensionMethods.cs プロジェクト: crazyants/aarbac
 public static void AddParameter(this RbacUser user, string paramName, string paramValue)
 {
     if (user != null)
     {
         RbacParameter newParam = new DataManager.Manager(false).AddOrUpdateUserParameter(user.UserId, paramName, paramValue);
         user.Parameters.Add(newParam.Name, newParam.Value);
     }
 }
コード例 #4
0
        public static void Save(RbacRegisterUser user)
        {
            RbacUser dbUser = GetUser(user.UserName);

            dbUser.FullName = user.FullName;
            dbUser.Email    = user.Email;
            dbUser.Role     = GetRole(user.RoleId);
            new DataManager.Manager().AddOrUpdate(dbUser);
        }
コード例 #5
0
ファイル: RbacUser.cs プロジェクト: karlosRivera/aarbac
 private void Assign(RbacUser user)
 {
     this.UserId   = user.UserId;
     this.UserName = user.UserName;
     this.FullName = user.FullName;
     this.Email    = user.Email;
     this.Role     = user.Role;
     this.Role.ParseMetaData();
 }
コード例 #6
0
ファイル: RbacUser.cs プロジェクト: karlosRivera/aarbac
        public RbacUser(string userName, string fullName, string email, RbacRole role, string password = null)
        {
            RbacUser newUser = new RbacUser();

            newUser.UserName = userName;
            newUser.FullName = fullName;
            newUser.Email    = email;
            newUser.Role     = role;
            newUser          = new DataManager.Manager(false).AddOrUpdate(newUser);
            Assign(newUser);
            Parameters = new ObservableDictionary <string, string>();
        }
コード例 #7
0
        public RbacUser Authenticate(string userName, string password)
        {
            RbacUser user = GetUser(userName);

            if (user == null)
            {
                RbacException.Raise("User name was not found!");
            }

            user = new DataManager.Manager().Authenticate(userName, password);
            if (user == null)
            {
                RbacException.Raise("Incorrect password!");
            }

            return(user);
        }
コード例 #8
0
        public Rbac(string userName)
        {
            Rbac rbacFromCache = RbacCache.Instance.GetContext(userName);

            if (rbacFromCache == null)
            {
                RbacUser user   = new RbacUser(userName);
                Rbac     dbRbac = new DataManager.Manager(false).GetRbac(user.Role.RbacId);
                dbRbac.User = user;
                Assign(dbRbac);
                RbacCache.Instance.Contexts.Add(userName, this);
            }
            else
            {
                Assign(rbacFromCache);
            }
        }
コード例 #9
0
ファイル: ExtensionMethods.cs プロジェクト: crazyants/aarbac
 public static RbacUser PopulateRole(this RbacUser user)
 {
     return(new DataManager.Manager(false).GetUser(user.UserId));
 }
コード例 #10
0
 public static void Delete(RbacUser rbacUser)
 {
     new DataManager.Manager().Delete(rbacUser);
 }