當前位置: 首頁>>代碼示例>>C#>>正文


C# Security.SecurityContext類代碼示例

本文整理匯總了C#中System.Security.SecurityContext的典型用法代碼示例。如果您正苦於以下問題:C# SecurityContext類的具體用法?C# SecurityContext怎麽用?C# SecurityContext使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SecurityContext類屬於System.Security命名空間,在下文中一共展示了SecurityContext類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Setup

 internal void Setup(SecurityContextDisableFlow flags)
 {
     this.useEC = false;
     this._sc = Thread.CurrentThread.ExecutionContext.SecurityContext;
     this._sc._disableFlow = flags;
     this._thread = Thread.CurrentThread;
 }
開發者ID:randomize,項目名稱:VimConfig,代碼行數:7,代碼來源:AsyncFlowControl.cs

示例2: Schedule

		protected void Schedule()
		{
			if (!this.isScheduled)
			{
				this.isScheduled = true;
				if (PartialTrustHelpers.ShouldFlowSecurityContext)
				{
					this.context = PartialTrustHelpers.CaptureSecurityContextNoIdentityFlow();
				}
				if (this.context == null)
				{
					this.ScheduleCallback(ActionItem.CallbackHelper.InvokeWithoutContextCallback);
					return;
				}
				else
				{
					this.ScheduleCallback(ActionItem.CallbackHelper.InvokeWithContextCallback);
					return;
				}
			}
			else
			{
				throw Fx.Exception.AsError(new InvalidOperationException(InternalSR.ActionItemIsAlreadyScheduled));
			}
		}
開發者ID:nickchal,項目名稱:pash,代碼行數:25,代碼來源:ActionItem.cs

示例3: SecurityContext

		// copy constructor
		internal SecurityContext (SecurityContext sc)
		{
			_capture = true;
			_winid = sc._winid;
			if (sc._stack != null)
				_stack = sc._stack.CreateCopy ();
		}
開發者ID:ngraziano,項目名稱:mono,代碼行數:8,代碼來源:SecurityContext.cs

示例4: ExecutionContext

		internal ExecutionContext (ExecutionContext ec)
		{
			if (ec._sc != null)
				_sc = new SecurityContext (ec._sc);
			_suppressFlow = ec._suppressFlow;
			_capture = true;
		}
開發者ID:ramonsmits,項目名稱:mono,代碼行數:7,代碼來源:ExecutionContext.cs

示例5: SecurityContext

		// copy constructor
		internal SecurityContext (SecurityContext sc)
		{
			_capture = true;
#if !MOBILE
			_winid = sc._winid;
			if (sc._stack != null)
				_stack = sc._stack.CreateCopy ();
#endif
		}
開發者ID:carrie901,項目名稱:mono,代碼行數:10,代碼來源:SecurityContext.cs

示例6: ExecutionContext

		internal ExecutionContext (ExecutionContext ec)
		{
#if !MOONLIGHT
			if (ec._sc != null)
				_sc = new SecurityContext (ec._sc);
#endif
			_suppressFlow = ec._suppressFlow;
			_capture = true;
		}
開發者ID:calumjiao,項目名稱:Mono-Class-Libraries,代碼行數:9,代碼來源:ExecutionContext.cs

示例7: ExecutionContext

		internal ExecutionContext (ExecutionContext ec)
		{
#if !NET_2_1 || MONOTOUCH
			if (ec._sc != null)
				_sc = new SecurityContext (ec._sc);
#endif
			_suppressFlow = ec._suppressFlow;
			_capture = true;
		}
開發者ID:runefs,項目名稱:Marvin,代碼行數:9,代碼來源:ExecutionContext.cs

示例8: Capture

		// static methods

		static public SecurityContext Capture ()
		{
			SecurityContext sc = Thread.CurrentThread.ExecutionContext.SecurityContext;
			if (sc.FlowSuppressed)
				return null;

			SecurityContext capture = new SecurityContext ();
			capture._capture = true;
			capture._winid = WindowsIdentity.GetCurrentToken ();
			capture._stack = CompressedStack.Capture ();
			return capture;
		}
開發者ID:ngraziano,項目名稱:mono,代碼行數:14,代碼來源:SecurityContext.cs

示例9: ExecutionContext

		private ExecutionContext (ExecutionContext ec)
		{
#if !MOBILE
			if (ec._sc != null)
				_sc = new SecurityContext (ec._sc);
#endif
			if (ec._lcc != null)
				_lcc = (LogicalCallContext) ec._lcc.Clone ();

			_suppressFlow = ec._suppressFlow;
			_capture = true;
		}
開發者ID:KonajuGames,項目名稱:SharpLang,代碼行數:12,代碼來源:ExecutionContext.cs

示例10: Schedule

        protected void Schedule()
        {
            if (isScheduled)
            {
                throw Fx.Exception.AsError(new InvalidOperationException(CommonResources.ActionItemIsAlreadyScheduled));
            }

            this.isScheduled = true;
            if (PartialTrustHelpers.ShouldFlowSecurityContext)
            {
                this.context = PartialTrustHelpers.CaptureSecurityContextNoIdentityFlow();
            }
            if (this.context != null)
            {
                ScheduleCallback(CallbackHelper.InvokeWithContextCallback);
            }
            else
            {
                ScheduleCallback(CallbackHelper.InvokeWithoutContextCallback);
            }
        }
開發者ID:stefangordon,項目名稱:azure-iot-sdks,代碼行數:21,代碼來源:ActionItem.cs

示例11: Schedule

        protected void Schedule()
        {
            if (isScheduled)
            {
                throw Fx.Exception.AsError(new InvalidOperationException(InternalSR.ActionItemIsAlreadyScheduled));
            }

            this.isScheduled = true;
#if FEATURE_COMPRESSEDSTACK
            if (PartialTrustHelpers.ShouldFlowSecurityContext)
            {
                this.context = PartialTrustHelpers.CaptureSecurityContextNoIdentityFlow();
            }
            if (this.context != null)
            {
                ScheduleCallback(CallbackHelper.InvokeWithContextCallback);
            }
            else
#endif
            {
                ScheduleCallback(CallbackHelper.InvokeWithoutContextCallback);
            }
        }
開發者ID:JokerMisfits,項目名稱:linux-packaging-mono,代碼行數:23,代碼來源:ActionItem.cs

示例12: SetSecurityContext

 [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
 internal static SecurityContextSwitcher SetSecurityContext(SecurityContext sc, SecurityContext.Reader prevSecurityContext, bool modifyCurrentExecutionContext)
 {
     StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
     return SetSecurityContext(sc, prevSecurityContext, modifyCurrentExecutionContext, ref stackMark);
 }
開發者ID:ItsVeryWindy,項目名稱:mono,代碼行數:6,代碼來源:securitycontext.cs

示例13: SecurityContextRunData

 internal SecurityContextRunData(SecurityContext securityContext, ContextCallback cb, Object state)
 {
     this.sc = securityContext;
     this.callBack = cb;
     this.state = state;
     this.scsw = new SecurityContextSwitcher();
 }
開發者ID:ItsVeryWindy,項目名稱:mono,代碼行數:7,代碼來源:securitycontext.cs

示例14: RunInternal

        [System.Security.SecurityCritical]  // auto-generated
        internal static void RunInternal(SecurityContext securityContext, ContextCallback callBack, Object state)
        {
            if (cleanupCode == null)
            {
                tryCode = new RuntimeHelpers.TryCode(runTryCode);
                cleanupCode = new RuntimeHelpers.CleanupCode(runFinallyCode);
            }
            SecurityContextRunData runData = new SecurityContextRunData(securityContext, callBack, state);
            RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(tryCode, cleanupCode, runData);

        }
開發者ID:ItsVeryWindy,項目名稱:mono,代碼行數:12,代碼來源:securitycontext.cs

示例15: Run

        [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
        public static void Run(SecurityContext securityContext, ContextCallback callback, Object state)
        {
            if (securityContext == null )
            {
                throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NullContext"));
            }
            Contract.EndContractBlock();

            StackCrawlMark stackMark = StackCrawlMark.LookForMe;

            if (!securityContext.isNewCapture)
            {
                throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NotNewCaptureContext"));
            }

            securityContext.isNewCapture = false;
#if !MOBILE
            ExecutionContext.Reader ec = Thread.CurrentThread.GetExecutionContextReader();
            
            // Optimization: do the callback directly if both the current and target contexts are equal to the
            // default full-trust security context
            if ( SecurityContext.CurrentlyInDefaultFTSecurityContext(ec)
                && securityContext.IsDefaultFTSecurityContext())
            {
                callback(state);
                
                if (GetCurrentWI(Thread.CurrentThread.GetExecutionContextReader()) != null) 
                {
                    // If we enter here it means the callback did an impersonation
                    // that we need to revert.
                    // We don't need to revert any other security state since it is stack-based 
                    // and automatically goes away when the callback returns.
                    WindowsIdentity.SafeRevertToSelf(ref stackMark);
                    // Ensure we have reverted to the state we entered in.
                    Contract.Assert(GetCurrentWI(Thread.CurrentThread.GetExecutionContextReader()) == null);
                }
            }
            else
#endif
            {
                RunInternal(securityContext, callback, state);
            }

        }
開發者ID:ItsVeryWindy,項目名稱:mono,代碼行數:45,代碼來源:securitycontext.cs


注:本文中的System.Security.SecurityContext類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。