public bool IsAuthorizedForOperation(WindowsIdentity clientIdentity) { bool isAccessAllowed = false; if (clientIdentity == null) { throw Fx.AssertAndThrow("NULL Identity"); } if (IntPtr.Zero == clientIdentity.Token) { throw Fx.AssertAndThrow("Token handle cannot be zero"); } lock (this) { if (this.securityDescriptor == null) { this.BuildSecurityDescriptor(); } } System.ServiceModel.ComIntegration.LUID modifiedIDLUID = System.ServiceModel.ComIntegration.SecurityUtils.GetModifiedIDLUID(new SafeCloseHandle(clientIdentity.Token, false)); if (!this.IsAccessCached(modifiedIDLUID, out isAccessAllowed)) { this.CheckAccess(clientIdentity, out isAccessAllowed); this.CacheAccessCheck(modifiedIDLUID, isAccessAllowed); } return(isAccessAllowed); }
private void CacheAccessCheck(System.ServiceModel.ComIntegration.LUID luidModifiedID, bool isAccessAllowed) { if (this.accessCheckCache == null) { throw Fx.AssertAndThrowFatal("AcessCheckCache must not be NULL"); } lock (this) { this.accessCheckCache[luidModifiedID] = isAccessAllowed; } }
private bool IsAccessCached(System.ServiceModel.ComIntegration.LUID luidModifiedID, out bool isAccessAllowed) { if (this.accessCheckCache == null) { throw Fx.AssertAndThrowFatal("AcessCheckCache must not be NULL"); } lock (this) { return(this.accessCheckCache.TryGetValue(luidModifiedID, out isAccessAllowed)); } }