コード例 #1
0
 public bool UnregisterPermission(Permission permission)
 {
     if (this.inner.UnregisterPermission(permission))
     {
         PermissionMemorySet.UnregisterPermission(permission);
         return(true);
     }
     return(false);
 }
コード例 #2
0
 internal void Fill(HashSet <PermissionAssignment> perms)
 {
     foreach (Guid cur in denies)
     {
         perms.Add(new PermissionAssignment(PermissionMemorySet.Get(cur), GrantType.Deny));
     }
     foreach (Guid cur in grants)
     {
         perms.Add(new PermissionAssignment(PermissionMemorySet.Get(cur), GrantType.Grant));
     }
 }
コード例 #3
0
 public IEnumerable <Permission> GetPermissions()
 {
     return(PermissionMemorySet.GetPermissions());
 }
コード例 #4
0
 public Permission Get(string name)
 {
     return(PermissionMemorySet.Get(name));
 }
コード例 #5
0
 public Permission Get(Guid id)
 {
     return(PermissionMemorySet.Get(id));
 }
コード例 #6
0
 public bool Exists(string name)
 {
     return(PermissionMemorySet.Exists(name));
 }
コード例 #7
0
 public bool Exists(Guid id)
 {
     return(PermissionMemorySet.Exists(id));
 }
コード例 #8
0
        protected override bool Initialize()
        {
            lock (instance)
            {
                if (!this.initialized)
                {
                    string meth = "Initialize";
                    this.logger = LogManager.Instance.GetProvider(typeof(CachingPermissionProviderFactory));
                    Log(meth, LogLevel.Info, "Called");

                    ConfigurationProviderBase config = ConfigurationManager.Instance.GetProvider();
                    if (config != null)
                    {
                        ConfigurationParameter param = config.Get(typeof(CachingPermissionProviderFactory), "provider");
                        if (param != null)
                        {
                            string tName = param.Value as string;
                            if (!string.IsNullOrEmpty(tName))
                            {
                                TypeNameReference typeName = TypeNameReference.Parse(tName);
                                if (typeName != null)
                                {
                                    innerFact = NameReflectionUtils.CreateInstance <PermissionProviderFactory>(typeName);
                                    if (innerFact != null)
                                    {
                                        if (InitializeOther(innerFact))
                                        {
                                            //ok preload the cache
                                            LocalSystemUser     u    = new LocalSystemUser(SecurityUtils.AdminIdentity, "Admin", UserState.Active);
                                            IPermissionProvider prov = this.GetProviderOther(this.innerFact, new UserSecurityContext(u));
                                            if (prov != null)
                                            {
                                                IEnumerable <Permission> perms = prov.GetPermissions();
                                                if (perms != null)
                                                {
                                                    foreach (Permission p in perms)
                                                    {
                                                        PermissionMemorySet.RegisterPermission(p);
                                                    }

                                                    this.initialized = true;
                                                    return(true);
                                                }
                                                else
                                                {
                                                    Log(meth, LogLevel.Error, "Failed to get existing permissions");
                                                }
                                            }
                                            else
                                            {
                                                Log(meth, LogLevel.Error, "Failed to get inner provider for preload");
                                            }
                                        }
                                        else
                                        {
                                            Log(meth, LogLevel.Error, "Failed to initialize inner provider");
                                        }
                                    }
                                    else
                                    {
                                        Log(meth, LogLevel.Error, "Failed to create inner provider factory");
                                    }
                                }
                                else
                                {
                                    Log(meth, LogLevel.Error, "Failed to parse permission provider param value");
                                }
                            }
                            else
                            {
                                Log(meth, LogLevel.Error, "Failed to get provider param value");
                            }
                        }
                        else
                        {
                            Log(meth, LogLevel.Error, "Failed to get provider param");
                        }
                    }
                    else
                    {
                        Log(meth, LogLevel.Error, "Failed to get ConfigurationProvider");
                    }
                }
            }
            return(false);
        }