예제 #1
0
 internal static void ExecutePrivileged(IStackWalk permission, PrivilegedCallback callback)
 {
     permission.Assert();
     try
     {
         callback();
     }
     finally
     {
         CodeAccessPermission.RevertAssert();
     }
 }
예제 #2
0
 internal static void ExecutePrivileged(IStackWalk permission, PrivilegedCallback callback)
 {
     permission.Assert();
     try
     {
         callback();
     }
     finally
     {
         CodeAccessPermission.RevertAssert();
     }
 }
예제 #3
0
        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();
            }
        }
예제 #5
0
 public override string GetRemoteAddress()
 {
     _connectionPermission.Assert();
     return(_connection.RemoteIP);
 }
예제 #6
0
 public override void CloseConnection()
 {
     _connectionPermission.Assert();
     _connection.Close();
 }