internal static void ExecutePrivileged(IStackWalk permission, PrivilegedCallback callback) { permission.Assert(); try { callback(); } finally { CodeAccessPermission.RevertAssert(); } }
internal static void ExecutePrivileged(IStackWalk permission, PrivilegedCallback callback) { permission.Assert(); try { callback(); } finally { CodeAccessPermission.RevertAssert(); } }
public override int ReadEntityBody(byte[] buffer, int size) { if (_bodyBytesLeft == 0) { return(0); } int bytesRead = size; _bodyBytesLeft -= size; if (_bodyBytesLeft < 0) { bytesRead += _bodyBytesLeft; _bodyBytesLeft = 0; } _connectionPermission.Assert(); byte[] bytes = _connection.GetBody(); Buffer.BlockCopy(bytes, 0, buffer, 0, bytesRead); return(bytesRead); }
internal static void DemandEnvironmentPermissions <T>(ClientBase <T> proxy) where T : class { if (!SecurityEnabled(proxy.Endpoint) || IsAnonymous(proxy.Endpoint)) { return; } IPermission permission = new EnvironmentPermission(EnvironmentPermissionAccess.Read, "USERNAME"); IStackWalk environment = permission as IStackWalk; environment.Assert(); string windowsUserName = proxy.ClientCredentials.Windows.ClientCredential.UserName; CodeAccessPermission.RevertAssert(); if (windowsUserName == String.Empty && proxy.ClientCredentials.UserName.UserName == null) { Debug.Assert(WindowsSecurityEnabled(proxy.Endpoint)); permission.Demand(); } }
public override string GetRemoteAddress() { _connectionPermission.Assert(); return(_connection.RemoteIP); }
public override void CloseConnection() { _connectionPermission.Assert(); _connection.Close(); }