Esempio n. 1
0
        public override void AddUsersToRoles(string[] usernames, string[] roleNames)
        {
            Upn upn = new Upn(HttpContext.Current.User.Identity.Name);

            string[] adamUsernames = FromUpns(usernames);
            AuthorizationProxy.AddUsersToRoles(upn.TenantName, adamUsernames, roleNames);
        }
Esempio n. 2
0
        public override string[] GetRolesForUser(string username)
        {
            string tenantName     = null;
            string tenantUsername = null;

            Upn.TryParse(username, out tenantName, out tenantUsername);
            return(AuthorizationProxy.GetRolesForUser(tenantName, tenantUsername));
        }
Esempio n. 3
0
        public override bool IsUserInRole(string username, string roleName)
        {
            string tenantName     = null;
            string tenantUsername = null;

            Upn.TryParse(username, out tenantName, out tenantUsername);
            return(AuthorizationProxy.IsUserInRole(tenantName, tenantUsername, roleName));
        }
Esempio n. 4
0
        public override void CreateRole(string roleName)
        {
            string tenantName     = null;
            string tenantUsername = null;

            Upn.TryParse(HttpContext.Current.User.Identity.Name, out tenantName, out tenantUsername);
            if (!string.IsNullOrEmpty(tenantName))
            {
                AuthorizationProxy.CreateRole(tenantName, roleName);
            }
        }
Esempio n. 5
0
        public override void RemoveUsersFromRoles(string[] usernames, string[] roleNames)
        {
            string tenantName     = null;
            string tenantUsername = null;

            Upn.TryParse(HttpContext.Current.User.Identity.Name, out tenantName, out tenantUsername);
            string[] adamUsernames = FromUpns(usernames);
            if (!string.IsNullOrEmpty(tenantName))
            {
                AuthorizationProxy.RemoveUsersFromRoles(tenantName, adamUsernames, roleNames);
            }
        }
Esempio n. 6
0
        public override bool DeleteRole(string roleName, bool throwOnPopulatedRole)
        {
            string tenantName     = null;
            string tenantUsername = null;

            Upn.TryParse(HttpContext.Current.User.Identity.Name, out tenantName, out tenantUsername);
            if (!string.IsNullOrEmpty(tenantName))
            {
                AuthorizationProxy.DeleteRole(tenantName, roleName);
            }
            return(true);
        }
Esempio n. 7
0
        public override bool RoleExists(string roleName)
        {
            string tenantName     = null;
            string tenantUsername = null;

            Upn.TryParse(HttpContext.Current.User.Identity.Name, out tenantName, out tenantUsername);
            if (!string.IsNullOrEmpty(tenantName))
            {
                return(AuthorizationProxy.RoleExists(tenantName, roleName));
            }
            else
            {
                return(false);
            }
        }
Esempio n. 8
0
        public override string[] GetAllRoles()
        {
            string tenantName     = null;
            string tenantUsername = null;

            Upn.TryParse(HttpContext.Current.User.Identity.Name, out tenantName, out tenantUsername);
            if (!string.IsNullOrEmpty(tenantName))
            {
                return(AuthorizationProxy.GetAllRoles(tenantName));
            }
            else
            {
                return(null);
            }
        }
        /// <summary>
        /// Get all action codes for a given user.
        /// </summary>
        /// <param name="userName">User Name</param>
        /// <returns>Action Codes.</returns>
        public override string[] GetActionsForUser(string userName)
        {
            if (string.IsNullOrEmpty(userName))
            {
                throw new ArgumentNullException("userName");
            }
            if (_cacheManager == null)
            {
                throw new HiiP.Framework.Common.BusinessException("Uable to create cache storage.");
            }

            string cacheKey = ActionsCacheKeyPrefix + userName;
            var data = this._cacheManager.GetData(cacheKey) as string[];

            if (data == null)
            {
                using (var proxy = new AuthorizationProxy())
                {
                    data = proxy.GetActionsForUser(this.ApplicationName, userName);
                    this._cacheManager.Add(cacheKey,data ,CacheItemPriority.None,null,new AbsoluteTime(ParameterUtil.DefaultCacheTimeSpan));
                }
            }

            return data ;
        }