• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Permissions.SecurityPermission类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.Security.Permissions.SecurityPermission的典型用法代码示例。如果您正苦于以下问题:C# SecurityPermission类的具体用法?C# SecurityPermission怎么用?C# SecurityPermission使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SecurityPermission类属于System.Security.Permissions命名空间,在下文中一共展示了SecurityPermission类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Credential

 /// <summary>
 ///     Initializes UnmanagedCodePermission for the <see cref="Credential" /> class.
 /// </summary>
 static Credential()
 {
     lock (LockObject)
     {
         UnmanagedCodePermission = new SecurityPermission(SecurityPermissionFlag.UnmanagedCode);
     }
 }
开发者ID:zidad,项目名称:Simple.CredentialsManager,代码行数:10,代码来源:Credential.cs


示例2: ReflectionFormatterReadSecurityExceptionPropertiesWithoutPermissionTest

        public void ReflectionFormatterReadSecurityExceptionPropertiesWithoutPermissionTest()
        {
            SecurityPermission denyPermission
                = new SecurityPermission(SecurityPermissionFlag.ControlPolicy | SecurityPermissionFlag.ControlEvidence);
            PermissionSet permissions = new PermissionSet(PermissionState.None);
            permissions.AddPermission(denyPermission);
            permissions.Deny();

            StringBuilder sb = new StringBuilder();
            StringWriter writer = new StringWriter(sb);

            SecurityException exception = null;
            try
            {
                DemandException(denyPermission);
            }
            catch (SecurityException e)
            {
                exception = e;
            }

            MockTextExceptionFormatter formatter = new MockTextExceptionFormatter(writer, exception, Guid.Empty);
            formatter.Format();

            CodeAccessPermission.RevertDeny();

            formatter = new MockTextExceptionFormatter(writer, exception, Guid.Empty);
            formatter.Format();
            Assert.AreEqual(exception.Demanded.ToString(), formatter.properties["Demanded"]);
        }
开发者ID:jmeckley,项目名称:Enterprise-Library-5.0,代码行数:30,代码来源:ExceptionFormatterFixture.2008.cs


示例3: Correctly_determines_permissions

		public void Correctly_determines_permissions()
		{
			// Execution has to be always granted. Otherwise this code wouldn't run in the first place.
			var securityPermission = new SecurityPermission(SecurityPermissionFlag.Execution);

			Assert.IsTrue(securityPermission.IsGranted());
		}
开发者ID:jeremymeng,项目名称:Core,代码行数:7,代码来源:PermissionUtilTestCase.cs


示例4: Install

        public override void Install(IDictionary stateSaver)
        {
            try
            {
                SecurityPermission permission =
                    new SecurityPermission(PermissionState.Unrestricted);
                permission.Demand();
            }
            catch (SecurityException)
            {
                throw new InstallException(
                    "You have insufficient privileges to " +
                    "register a trust relationship. Start Excel " +
                    "and confirm the trust dialog to run the addin.");
            }
            Uri deploymentManifestLocation = null;

            // NodeXLModification
            //
            // "deploymentManifestLocation" parameter name changed to
            // "deploymentLocation" to make it consistent with
            // ClickOnceInstaller.cs.

            if (Uri.TryCreate(Context.Parameters["deploymentLocation"],
                UriKind.RelativeOrAbsolute, out deploymentManifestLocation) == false)
            {
                throw new InstallException(
                    "The location of the deployment manifest is missing or invalid.");
            }
            AddInSecurityEntry entry = new AddInSecurityEntry(
                            deploymentManifestLocation, RSA_PublicKey);
            UserInclusionList.Add(entry);
            stateSaver.Add("entryKey", deploymentManifestLocation);
            base.Install(stateSaver);
        }
开发者ID:haisreekanth,项目名称:NetMap,代码行数:35,代码来源:TrustInstaller.cs


示例5: RunApp

        public void RunApp(string FileName, string arg)
        {
            SecurityPermission SP = new SecurityPermission(SecurityPermissionFlag.AllFlags);
            SP.Assert();

            //ProcessStartInfo process = new ProcessStartInfo("cmd", "/c " + FileName ));
            System.Diagnostics.Process process = new System.Diagnostics.Process();
            process.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
            //process.StartInfo.UseShellExecute = false;
            //process.StartInfo.RedirectStandardOutput = true;
            //process.StartInfo.RedirectStandardError = true;
            //process.StartInfo.CreateNoWindow = true;
            process.StartInfo.FileName = FileName;
            process.StartInfo.Arguments = arg;
            process.StartInfo.WorkingDirectory = System.IO.Path.GetDirectoryName(FileName);

            //Vista or higher check
            if (System.Environment.OSVersion.Version.Major >= 6)
                process.StartInfo.Verb = "runas";

            try
            {
                process.Start();
                process.WaitForExit();
                process.Close();
            }
            catch (InvalidOperationException)
            {
                //e.ExceptionObject.ToString();
            }
        }
开发者ID:swmicro,项目名称:CHMedit,代码行数:31,代码来源:Form1.cs


示例6: CanReflectOnSecurityExceptionWithoutPermission

		public void CanReflectOnSecurityExceptionWithoutPermission()
		{
			SecurityPermission denyPermission
				= new SecurityPermission(SecurityPermissionFlag.ControlPolicy | SecurityPermissionFlag.ControlEvidence);
			PermissionSet permissions = new PermissionSet(PermissionState.None);
			permissions.AddPermission(denyPermission);
			permissions.Deny();

			SecurityException exception = null;
			try
			{
				DemandException(denyPermission);
			}
			catch (SecurityException e)
			{
				exception = e;
			}
			
			ExceptionFormatter formatter = new ExceptionFormatter();

			String message = formatter.GetMessage(exception);
			Match demandedMatch = DemandedEntryRegex.Match(message);
			Assert.IsNotNull(demandedMatch);
			Assert.AreEqual(Resources.PropertyAccessFailed, demandedMatch.Groups[1].Value);

			CodeAccessPermission.RevertDeny();

			message = formatter.GetMessage(exception);
			demandedMatch = DemandedEntryRegex.Match(message);
			Assert.IsNotNull(demandedMatch);
			Assert.AreNotEqual(Resources.PropertyAccessFailed, demandedMatch.Groups[1].Value);
		}
开发者ID:jmeckley,项目名称:Enterprise-Library-5.0,代码行数:32,代码来源:ExceptionFormatterFixture.cs


示例7: BaseCredentialsPrompt

 static BaseCredentialsPrompt()
 {
     lock (_lockObject)
     {
         _unmanagedCodePermission = new SecurityPermission(SecurityPermissionFlag.UnmanagedCode);
     }
 }
开发者ID:CuneytKukrer,项目名称:TestProject,代码行数:7,代码来源:BaseCredentialsPrompt.cs


示例8: Clerk

 public Clerk(string compensator, string description, CompensatorOptions flags)
 {
     SecurityPermission permission = new SecurityPermission(SecurityPermissionFlag.UnmanagedCode);
     permission.Demand();
     permission.Assert();
     this.Init(compensator, description, flags);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:7,代码来源:Clerk.cs


示例9: SetAppDomainData

        public static void SetAppDomainData()
        {
            SecurityPermission sp = new SecurityPermission(SecurityPermissionFlag.ControlAppDomain);
            sp.Assert();

            AppDomain.CurrentDomain.SetData("SQLServerCompactEditionUnderWebHosting", true);
        }
开发者ID:mclricardo,项目名称:DotNetMagazineChat,代码行数:7,代码来源:Global.asax.cs


示例10: CodeAccessSecurityEngine

        // static default constructor. This will be called before any of the static members are accessed.
        static CodeAccessSecurityEngine()
        {
#pragma warning disable 618
            AssertPermission = new SecurityPermission(SecurityPermissionFlag.Assertion);
#pragma warning restore 618
            AssertPermissionToken = PermissionToken.GetToken(AssertPermission);
        }
开发者ID:kouvel,项目名称:coreclr,代码行数:8,代码来源:CodeAccessSecurityEngine.cs


示例11: ClerkMonitor

 public ClerkMonitor()
 {
     SecurityPermission permission = new SecurityPermission(SecurityPermissionFlag.UnmanagedCode);
     permission.Demand();
     permission.Assert();
     this._monitor = new CrmMonitor();
     this._version = 0;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:8,代码来源:ClerkMonitor.cs


示例12: AnimateWindow

 internal static void AnimateWindow(Control control, int time, AnimationFlags flags)
 {
     try
     {
         SecurityPermission sp = new SecurityPermission(SecurityPermissionFlag.UnmanagedCode);
         sp.Demand();
         AnimateWindow(new HandleRef(control, control.Handle), time, flags);
     }
     catch (SecurityException) { }
 }
开发者ID:devfinity-fx,项目名称:cpms_z,代码行数:10,代码来源:NativeMethods.cs


示例13: Assert

	public void Assert()
			{
				// We must have the "Assertion" security flag for this to work.
				SecurityPermission perm;
				perm = new SecurityPermission(SecurityPermissionFlag.Assertion);
				perm.Demand();

				// Assert this permission.
				Assert(2);
			}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:10,代码来源:CodeAccessPermission.cs


示例14: _UnsafeGetAssertPermSet

 internal static PermissionSet _UnsafeGetAssertPermSet()
 {
     PermissionSet set = new PermissionSet(PermissionState.None);
     RegistryPermission perm = new RegistryPermission(PermissionState.Unrestricted);
     set.AddPermission(perm);
     EnvironmentPermission permission2 = new EnvironmentPermission(PermissionState.Unrestricted);
     set.AddPermission(permission2);
     SecurityPermission permission3 = new SecurityPermission(SecurityPermissionFlag.UnmanagedCode);
     set.AddPermission(permission3);
     return set;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:11,代码来源:EventLog.cs


示例15: AnimateWindow

        internal static void AnimateWindow(Control control, int time, AnimationFlags flags)
        {
            Contract.Requires<ArgumentNullException>(control != null);

            try
            {
                SecurityPermission sp = new SecurityPermission(SecurityPermissionFlag.UnmanagedCode);
                sp.Demand();
                AnimateWindow(new HandleRef(control, control.Handle), time, flags);
            }
            catch (SecurityException) { }
        }
开发者ID:xieguigang,项目名称:Reference_SharedLib,代码行数:12,代码来源:NativeMethods.cs


示例16: RemotingServices

 [System.Security.SecuritySafeCritical]  // auto-generated
 static RemotingServices() 
 { 
     System.Security.CodeAccessPermission.Assert(true);
     s_RemotingInfrastructurePermission= new SecurityPermission(SecurityPermissionFlag.Infrastructure); 
     s_MscorlibAssembly = typeof(RemotingServices).Assembly;
     s_FieldGetterMB = null;
     s_FieldSetterMB = null;
     s_bRemoteActivationConfigured = false; 
     s_bRegisteredWellKnownChannels = false;
     s_bInProcessOfRegisteringWellKnownChannels = false; 
     s_delayLoadChannelLock = new Object(); 
 }
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:13,代码来源:RemotingServices.cs


示例17: DoWork

 public void DoWork()
 {
     // Note that because DoDangerousThing is public, this
      // security check does not resolve the violation.
      // This only checks callers that go through DoWork().
      SecurityPermission secPerm = new SecurityPermission(
     SecurityPermissionFlag.ControlPolicy |
     SecurityPermissionFlag.ControlEvidence
      );
      secPerm.Demand();
      DoDangerousThing();
 }
开发者ID:terryjintry,项目名称:OLSource1,代码行数:12,代码来源:ca2118--review-suppressunmanagedcodesecurityattribute-usage_3.cs


示例18: Serializer

 /// <summary>
 /// Static Constructor is used to set the CanBinarySerialize value only once for the given security policy
 /// </summary>
 static Serializer()
 {
     SecurityPermission sp =  new SecurityPermission(SecurityPermissionFlag.SerializationFormatter);
     try
     {
         sp.Demand();
         CanBinarySerialize = true;
     }
     catch(SecurityException)
     {
         CanBinarySerialize = false;
     }
 }
开发者ID:pcstx,项目名称:OA,代码行数:16,代码来源:Serializer.cs


示例19: TRACKMOUSEEVENT

		/// <summary>
		/// Creates a new TRACKMOUSEEVENT struct with default settings
		/// </summary>
		public TRACKMOUSEEVENT()
		{
			// Marshal.SizeOf() uses SecurityAction.LinkDemand to prevent 
			// it from being called from untrusted code, so make sure we 
			// have permission to call it
			SecurityPermission permission = new SecurityPermission(SecurityPermissionFlag.UnmanagedCode);
			permission.Demand();

			this.cbSize = Marshal.SizeOf(typeof(TRACKMOUSEEVENT));
			
			this.dwFlags = 0;
			this.hwndTrack = IntPtr.Zero;
			this.dwHoverTime = 100;
		}
开发者ID:samuraitruong,项目名称:comitdownloader,代码行数:17,代码来源:TRACKMOUSEEVENT.cs


示例20: RemoveEventHandler

        public override void RemoveEventHandler(object target, Delegate handler) {
            if (Marshal.IsComObject(target)) {
                // retrieve sourceIid and dispid
                Guid sourceIid;
                int dispid;
                GetDataForComInvocation(_innerEventInfo, out sourceIid, out dispid);

                // now validate the caller can call into native and redirect to ComEventHelpers.Combine
                SecurityPermission perm = new SecurityPermission(SecurityPermissionFlag.UnmanagedCode);
                perm.Demand();
                System.Runtime.InteropServices.ComEventsHelper.Remove(target, sourceIid, dispid, handler);
            } else {
                // we are dealing with a managed object - just add the delegate through relection
                _innerEventInfo.RemoveEventHandler(target, handler);
            }
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:16,代码来源:ComAwareEventInfo.cs



注:本文中的System.Security.Permissions.SecurityPermission类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Permissions.StorePermission类代码示例发布时间:2022-05-26
下一篇:
C# Permissions.RegistryPermission类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap