本文整理汇总了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;
}
示例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));
}
}
示例3: SecurityContext
// copy constructor
internal SecurityContext (SecurityContext sc)
{
_capture = true;
_winid = sc._winid;
if (sc._stack != null)
_stack = sc._stack.CreateCopy ();
}
示例4: ExecutionContext
internal ExecutionContext (ExecutionContext ec)
{
if (ec._sc != null)
_sc = new SecurityContext (ec._sc);
_suppressFlow = ec._suppressFlow;
_capture = true;
}
示例5: SecurityContext
// copy constructor
internal SecurityContext (SecurityContext sc)
{
_capture = true;
#if !MOBILE
_winid = sc._winid;
if (sc._stack != null)
_stack = sc._stack.CreateCopy ();
#endif
}
示例6: ExecutionContext
internal ExecutionContext (ExecutionContext ec)
{
#if !MOONLIGHT
if (ec._sc != null)
_sc = new SecurityContext (ec._sc);
#endif
_suppressFlow = ec._suppressFlow;
_capture = true;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例13: SecurityContextRunData
internal SecurityContextRunData(SecurityContext securityContext, ContextCallback cb, Object state)
{
this.sc = securityContext;
this.callBack = cb;
this.state = state;
this.scsw = new SecurityContextSwitcher();
}
示例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);
}
示例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);
}
}