public bool UnregisterPermission(Permission permission) { if (this.inner.UnregisterPermission(permission)) { PermissionMemorySet.UnregisterPermission(permission); return(true); } return(false); }
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)); } }
public IEnumerable <Permission> GetPermissions() { return(PermissionMemorySet.GetPermissions()); }
public Permission Get(string name) { return(PermissionMemorySet.Get(name)); }
public Permission Get(Guid id) { return(PermissionMemorySet.Get(id)); }
public bool Exists(string name) { return(PermissionMemorySet.Exists(name)); }
public bool Exists(Guid id) { return(PermissionMemorySet.Exists(id)); }
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); }