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

C# SecurityZone类代码示例

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

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



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

示例1: BasicTestZone

		private ZoneIdentityPermission BasicTestZone (SecurityZone zone, bool special)
		{
			ZoneIdentityPermission zip = new ZoneIdentityPermission (zone);
			Assert.AreEqual (zone, zip.SecurityZone, "SecurityZone");
			
			ZoneIdentityPermission copy = (ZoneIdentityPermission) zip.Copy ();
			Assert.IsTrue (Same (zip, copy), "Equals-Copy");
			Assert.IsTrue (zip.IsSubsetOf (copy), "IsSubset-1");
			Assert.IsTrue (copy.IsSubsetOf (zip), "IsSubset-2");
			if (special) {
				Assert.IsFalse (zip.IsSubsetOf (null), "IsSubset-Null");
			}
			
			IPermission intersect = zip.Intersect (copy);
			if (special) {
				Assert.IsTrue (intersect.IsSubsetOf (zip), "IsSubset-3");
				Assert.IsFalse (Object.ReferenceEquals (zip, intersect), "!ReferenceEquals1");
				Assert.IsTrue (intersect.IsSubsetOf (copy), "IsSubset-4");
				Assert.IsFalse (Object.ReferenceEquals (copy, intersect), "!ReferenceEquals2");
			}

			Assert.IsNull (zip.Intersect (null), "Intersect with null");

			intersect = zip.Intersect (new ZoneIdentityPermission (PermissionState.None));
			Assert.IsNull (intersect, "Intersect with PS.None");

			// note: can't be tested with PermissionState.Unrestricted

			// XML roundtrip
			SecurityElement se = zip.ToXml ();
			copy.FromXml (se);
			Assert.IsTrue (Same (zip, copy), "Equals-Xml");

			return zip;
		}
开发者ID:nlhepler,项目名称:mono,代码行数:35,代码来源:ZoneIdentityPermissionTest.cs


示例2: ZoneIdentityPermission

		public ZoneIdentityPermission (PermissionState state)
		{
			// false == do not allow Unrestricted for Identity Permissions
			CheckPermissionState (state, false);
			// default values
			zone = SecurityZone.NoZone;
		}
开发者ID:jack-pappas,项目名称:mono,代码行数:7,代码来源:ZoneIdentityPermission.cs


示例3: Zone

     /// <include file='doc\Zone.uex' path='docs/doc[@for="Zone.Zone"]/*' />
     public Zone(SecurityZone zone)
     {
         if (zone < SecurityZone.NoZone || zone > SecurityZone.Untrusted)
             throw new ArgumentException( Environment.GetResourceString( "Argument_IllegalZone" ) );
 
         m_zone = zone;
     }
开发者ID:ArildF,项目名称:masters,代码行数:8,代码来源:zone.cs


示例4: ZoneIdentityPermission

	// Constructor.
	public ZoneIdentityPermission(PermissionState state)
			{
				if(state != PermissionState.None)
				{
					throw new ArgumentException(_("Arg_PermissionState"));
				}
				zone = SecurityZone.NoZone;
			}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:9,代码来源:ZoneIdentityPermission.cs


示例5: Zone

	// Constructor.
	public Zone(SecurityZone zone)
			{
				if(((int)zone) < ((int)(SecurityZone.NoZone)) ||
				   ((int)zone) > ((int)(SecurityZone.Untrusted)))
				{
					throw new ArgumentException(_("Arg_SecurityZone"));
				}
				this.zone = zone;
			}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:10,代码来源:Zone.cs


示例6: ZoneMembershipCondition

	public ZoneMembershipCondition(SecurityZone zone)
			{
				if(zone < SecurityZone.MyComputer ||
				   zone > SecurityZone.Untrusted)
				{
					throw new ArgumentException(_("Arg_SecurityZone"));
				}
				this.zone = zone;
			}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:9,代码来源:ZoneMembershipCondition.cs


示例7: Zone

		public Zone (SecurityZone zone)
		{
			if (!Enum.IsDefined (typeof (SecurityZone), zone)) {
				string msg = String.Format (Locale.GetText ("Invalid zone {0}."), zone);
				throw new ArgumentException (msg, "zone");
			}

			this.zone = zone;
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:9,代码来源:Zone.cs


示例8: OnSerializing

        private void OnSerializing(StreamingContext ctx)
        { 

            if ((ctx.State & ~(StreamingContextStates.Clone|StreamingContextStates.CrossAppDomain)) != 0) 
            { 
                m_serializedPermission = ToXml().ToString(); //for the v2 and beyond case
                m_zone = SecurityZone; 

            }
        }
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:10,代码来源:ZoneIdentityPermission.cs


示例9: CreateSandboxDomain

        public AppDomain CreateSandboxDomain(string name, string path, SecurityZone zone)
        {
            var setup = new AppDomainSetup { ApplicationBase = Common.ApiPath, PrivateBinPath = Path.GetFullPath(path) };

            var evidence = new Evidence();
            evidence.AddHostEvidence(new Zone(zone));
            var permissions = SecurityManager.GetStandardSandbox(evidence);

            var strongName = typeof(OSAEService).Assembly.Evidence.GetHostEvidence<StrongName>();

            return AppDomain.CreateDomain(name, null, setup);
        }
开发者ID:smackay,项目名称:Open-Source-Automation,代码行数:12,代码来源:OSAEService.cs


示例10: RunScenario

        private static void RunScenario(SecurityZone zone, bool fullyTrustEventSource, bool grantUnmanagedCodePermission)
        {
            Console.Write("Running scenario for zone '{0}', fully trusted EventSource {1}, unmanaged permission {2}: ", zone, fullyTrustEventSource, grantUnmanagedCodePermission);

            var evidence = new Evidence();
            evidence.AddHostEvidence(new Zone(zone));
            var permissionSet = SecurityManager.GetStandardSandbox(evidence);
            if (!permissionSet.IsUnrestricted() && grantUnmanagedCodePermission)
            {
                permissionSet.AddPermission(new SecurityPermission(SecurityPermissionFlag.UnmanagedCode));
            }

            var eventSourceAssemblyName = typeof(EventSource).Assembly.GetName();
            var fullyTrustedAssemblies =
                fullyTrustEventSource
                    ? new StrongName[]  
                    {
                        new StrongName(new StrongNamePublicKeyBlob(eventSourceAssemblyName.GetPublicKey()), eventSourceAssemblyName.Name, eventSourceAssemblyName.Version)
                    }
                    : new StrongName[0];

            var info = new AppDomainSetup { ApplicationBase = AppDomain.CurrentDomain.BaseDirectory };
            info.ApplicationTrust = new ApplicationTrust(permissionSet, fullyTrustedAssemblies);

            var appDomain =
                AppDomain.CreateDomain(
                    "partial trust",
                    evidence,
                    info);
            try
            {
                var tester = (LttADEventSourceTester)appDomain
                    .CreateInstanceAndUnwrap(
                        typeof(LttADEventSourceTester).Assembly.GetName().Name,
                        typeof(LttADEventSourceTester).FullName);
                tester.IsEventSourceAssmFullyTrusted = fullyTrustEventSource;
                tester.DoStuff(1);
                tester.DoStuff(2);
                tester.DoStuff(3);

                Assert.IsTrue(tester.IsStateValid, "EventSource ConstructionException as expected");
                Console.WriteLine("SUCCESS");
                Console.WriteLine();
            }
            finally
            {
                AppDomain.Unload(appDomain);
            }

            Console.WriteLine("==================================================================");
            Console.WriteLine();
        }
开发者ID:Rayislandstyle,项目名称:corefx,代码行数:52,代码来源:TestsLowTrust.cs


示例11: ZoneIdentityPermission

 //------------------------------------------------------
 //
 // PUBLIC CONSTRUCTORS
 //
 //------------------------------------------------------
 
 /// <include file='doc\ZoneIdentityPermission.uex' path='docs/doc[@for="ZoneIdentityPermission.ZoneIdentityPermission"]/*' />
 public ZoneIdentityPermission(PermissionState state)
 {
     if (state == PermissionState.Unrestricted)
     {
         throw new ArgumentException(Environment.GetResourceString("Argument_UnrestrictedIdentityPermission"));
     }
     else if (state == PermissionState.None)
     {
         m_zone = SecurityZone.NoZone;
     }
     else
     {
         throw new ArgumentException(Environment.GetResourceString("Argument_InvalidPermissionState"));
     }
 }
开发者ID:ArildF,项目名称:masters,代码行数:22,代码来源:zoneidentitypermission.cs


示例12: OnDeserialized

        private void OnDeserialized(StreamingContext ctx) 
        {
            if ((ctx.State & ~(StreamingContextStates.Clone|StreamingContextStates.CrossAppDomain)) != 0)
            {
                // v2.0 and beyond XML case 
                if (m_serializedPermission != null)
                { 
                    FromXml(SecurityElement.FromString(m_serializedPermission)); 
                    m_serializedPermission = null;
                } 
                else //v1.x case where we read the m_zone value
                {
                    SecurityZone = m_zone;
                    m_zone = SecurityZone.NoZone; 
                }
            } 
 

        } 
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:19,代码来源:ZoneIdentityPermission.cs


示例13: FromXml

	// Convert an XML value into a permissions value.
	public override void FromXml(SecurityElement esd)
			{
				String value;
				if(esd == null)
				{
					throw new ArgumentNullException("esd");
				}
				if(esd.Attribute("version") != "1")
				{
					throw new ArgumentException(_("Arg_PermissionVersion"));
				}
				value = esd.Attribute("Zone");
				if(value != null)
				{
					zone = (SecurityZone)
						Enum.Parse(typeof(SecurityZone), value);
				}
				else
				{
					zone = SecurityZone.NoZone;
				}
			}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:23,代码来源:ZoneIdentityPermission.cs


示例14: SecurityException

 protected SecurityException(SerializationInfo info, StreamingContext context) : base(info, context)
 {
     if (info == null)
     {
         throw new ArgumentNullException("info");
     }
     try
     {
         this.m_action = (SecurityAction) info.GetValue("Action", typeof(SecurityAction));
         this.m_permissionThatFailed = (string) info.GetValueNoThrow("FirstPermissionThatFailed", typeof(string));
         this.m_demanded = (string) info.GetValueNoThrow("Demanded", typeof(string));
         this.m_granted = (string) info.GetValueNoThrow("GrantedSet", typeof(string));
         this.m_refused = (string) info.GetValueNoThrow("RefusedSet", typeof(string));
         this.m_denied = (string) info.GetValueNoThrow("Denied", typeof(string));
         this.m_permitOnly = (string) info.GetValueNoThrow("PermitOnly", typeof(string));
         this.m_assemblyName = (AssemblyName) info.GetValueNoThrow("Assembly", typeof(AssemblyName));
         this.m_serializedMethodInfo = (byte[]) info.GetValueNoThrow("Method", typeof(byte[]));
         this.m_strMethodInfo = (string) info.GetValueNoThrow("Method_String", typeof(string));
         this.m_zone = (SecurityZone) info.GetValue("Zone", typeof(SecurityZone));
         this.m_url = (string) info.GetValueNoThrow("Url", typeof(string));
     }
     catch
     {
         this.m_action = (SecurityAction) 0;
         this.m_permissionThatFailed = "";
         this.m_demanded = "";
         this.m_granted = "";
         this.m_refused = "";
         this.m_denied = "";
         this.m_permitOnly = "";
         this.m_assemblyName = null;
         this.m_serializedMethodInfo = null;
         this.m_strMethodInfo = null;
         this.m_zone = SecurityZone.NoZone;
         this.m_url = "";
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:37,代码来源:SecurityException.cs


示例15: ResolveEvidenceHost

		private void ResolveEvidenceHost (SecurityZone zone, bool unrestricted, bool empty)
		{
			string prefix = zone.ToString () + "-";
			Evidence e = new Evidence ();
			e.AddHost (new Zone (zone));
			PermissionSet ps = SecurityManager.ResolvePolicy (e);
			// as 2.0 use Unrestricted for Identity permissions they have no need to be 
			// kept in resolved permission set
#if NET_2_0
			Assert.IsTrue ((unrestricted || (ps.Count > 0)), prefix + "Count");
#else
			Assert.IsTrue ((ps.Count > 0), prefix + "Count");
#endif
			Assert.AreEqual (empty, ps.IsEmpty (), prefix + "IsEmpty");
			Assert.AreEqual (unrestricted, ps.IsUnrestricted (), prefix + "IsUnrestricted");
#if NET_2_0
			if (unrestricted)
				Assert.IsNull (ps.GetPermission (typeof (ZoneIdentityPermission)), prefix + "GetPermission(ZoneIdentityPermission)");
			else
				Assert.IsNotNull (ps.GetPermission (typeof (ZoneIdentityPermission)), prefix + "GetPermission(ZoneIdentityPermission)");
#else
			Assert.IsNotNull (ps.GetPermission (typeof (ZoneIdentityPermission)), prefix + "GetPermission(ZoneIdentityPermission)");
#endif
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:24,代码来源:SecurityManagerTest.cs


示例16: OnSerialized

 private void OnSerialized(StreamingContext ctx)
 { 
     if ((ctx.State & ~(StreamingContextStates.Clone|StreamingContextStates.CrossAppDomain)) != 0) 
     {
         m_serializedPermission = null; 
         m_zone = SecurityZone.NoZone;
     }
 }
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:8,代码来源:ZoneIdentityPermission.cs


示例17: FromXml

 public override void FromXml(SecurityElement esd) 
 { 
     m_zones = 0;
     CodeAccessPermission.ValidateElement( esd, this ); 
     String eZone = esd.Attribute( "Zone" );
     if (eZone != null)
         SecurityZone = (SecurityZone)Enum.Parse( typeof( SecurityZone ), eZone );
     if(esd.Children != null) 
     {
         foreach(SecurityElement child in esd.Children) 
         { 
             eZone = child.Attribute( "Zone" );
             int enm = (int)Enum.Parse( typeof( SecurityZone ), eZone ); 
             if(enm == (int)SecurityZone.NoZone)
                 continue;
             m_zones |= ((uint)1 << enm);
         } 
     }
 } 
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:19,代码来源:ZoneIdentityPermission.cs


示例18: Resolve_Zone_Unrestricted_Attribute

		private void Resolve_Zone_Unrestricted_Attribute (SecurityZone zone, PolicyStatementAttribute attr)
		{
			IMembershipCondition mc = new ZoneMembershipCondition (zone);
			PolicyStatement ps = new PolicyStatement (new PermissionSet (PermissionState.Unrestricted));
			ps.Attributes = attr;
			PolicyLevel pl = PolicyLevel.CreateAppDomainLevel ();
			pl.RootCodeGroup = new UnionCodeGroup (mc, ps);

			Resolve_Zone (pl, SecurityZone.Internet, attr, (zone == SecurityZone.Internet), 0);
			Resolve_Zone (pl, SecurityZone.Intranet, attr, (zone == SecurityZone.Intranet), 0);
			Resolve_Zone (pl, SecurityZone.MyComputer, attr, (zone == SecurityZone.MyComputer), 0);
			Resolve_Zone (pl, SecurityZone.NoZone, attr, (zone == SecurityZone.NoZone), 0);
			Resolve_Zone (pl, SecurityZone.Trusted, attr, (zone == SecurityZone.Trusted), 0);
			Resolve_Zone (pl, SecurityZone.Untrusted, attr, (zone == SecurityZone.Untrusted), 0);
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:15,代码来源:PolicyLevelTest.cs


示例19:

 /// <internalonly/>
 int IBuiltInEvidence.InitFromBuffer( char[] buffer, int position )
 {
     m_url = null;
     m_zone = (SecurityZone)BuiltInEvidenceHelper.GetIntFromCharArray(buffer, position);
     return position + 2;
 }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:7,代码来源:zone.cs


示例20: GetLocationEvidence

 private static extern void GetLocationEvidence(SafePEFileHandle peFile, out SecurityZone zone, StringHandleOnStack retUrl);
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:1,代码来源:PEFileEvidenceFactory.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Seed类代码示例发布时间:2022-05-24
下一篇:
C# SecurityType类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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