当前位置: 首页>>代码示例>>C#>>正文


C# PolicyLevel.GetNamedPermissionSet方法代码示例

本文整理汇总了C#中System.Security.Policy.PolicyLevel.GetNamedPermissionSet方法的典型用法代码示例。如果您正苦于以下问题:C# PolicyLevel.GetNamedPermissionSet方法的具体用法?C# PolicyLevel.GetNamedPermissionSet怎么用?C# PolicyLevel.GetNamedPermissionSet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Security.Policy.PolicyLevel的用法示例。


在下文中一共展示了PolicyLevel.GetNamedPermissionSet方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ToXml

 internal SecurityElement ToXml(PolicyLevel level, bool useInternal)
 {
     SecurityElement element = new SecurityElement("PolicyStatement");
     element.AddAttribute("version", "1");
     if (this.m_attributes != PolicyStatementAttribute.Nothing)
     {
         element.AddAttribute("Attributes", XMLUtil.BitFieldEnumToString(typeof(PolicyStatementAttribute), this.m_attributes));
     }
     lock (this)
     {
         if (this.m_permSet == null)
         {
             return element;
         }
         if (this.m_permSet is NamedPermissionSet)
         {
             NamedPermissionSet permSet = (NamedPermissionSet) this.m_permSet;
             if ((level != null) && (level.GetNamedPermissionSet(permSet.Name) != null))
             {
                 element.AddAttribute("PermissionSetName", permSet.Name);
                 return element;
             }
             if (useInternal)
             {
                 element.AddChild(permSet.InternalToXml());
                 return element;
             }
             element.AddChild(permSet.ToXml());
             return element;
         }
         if (useInternal)
         {
             element.AddChild(this.m_permSet.InternalToXml());
             return element;
         }
         element.AddChild(this.m_permSet.ToXml());
     }
     return element;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:39,代码来源:PolicyStatement.cs

示例2: GetPermissionSet

 static NamedPermissionSet GetPermissionSet( PolicyLevel level, String name )
 {
     NamedPermissionSet permSet = level.GetNamedPermissionSet( name );
     if (permSet == null)
     {
         throw new ArgumentException( String.Format( manager.GetString( "Error_UnknownPermissionSet" ), name ) );
     }
     return permSet;
 }
开发者ID:ArildF,项目名称:masters,代码行数:9,代码来源:caspol.cs

示例3: CreateLocalIntranetSet

 private static NamedPermissionSet CreateLocalIntranetSet() {
     PolicyLevel level = new PolicyLevel(System.Security.PolicyLevelType.User);
     return level.GetNamedPermissionSet("LocalIntranet");
 }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:4,代码来源:policylevel.cs

示例4: ToXml

 internal SecurityElement ToXml( PolicyLevel level, bool useInternal )
 {
     SecurityElement e = new SecurityElement( "PolicyStatement" );
     e.AddAttribute( "version", "1" );
     if (m_attributes != PolicyStatementAttribute.Nothing)
         e.AddAttribute( "Attributes", XMLUtil.BitFieldEnumToString( typeof( PolicyStatementAttribute ), m_attributes ) );            
     
     lock (this)
     {
         if (m_permSet != null)
         {
             if (m_permSet is NamedPermissionSet)
             {
                 // If the named permission set exists in the parent level of this
                 // policy struct, then just save the name of the permission set.
                 // Otherwise, serialize it like normal.
         
                 NamedPermissionSet namedPermSet = (NamedPermissionSet)m_permSet;
                 if (level != null && level.GetNamedPermissionSet( namedPermSet.Name ) != null)
                 {
                     e.AddAttribute( "PermissionSetName", namedPermSet.Name );
                 }
                 else
                 {
                     if (useInternal)
                         e.AddChild( namedPermSet.InternalToXml() );
                     else
                         e.AddChild( namedPermSet.ToXml() );
                 }
             }
             else
             {
                 if (useInternal)
                     e.AddChild( m_permSet.InternalToXml() );
                 else
                     e.AddChild( m_permSet.ToXml() );
             }
         }
     }
     
     return e;
 }
开发者ID:uQr,项目名称:referencesource,代码行数:42,代码来源:policystatement.cs

示例5: CreateLocalIntranetSet

 internal static NamedPermissionSet CreateLocalIntranetSet()
 {
     PolicyLevel level = new PolicyLevel( "Temp" );
     
     return level.GetNamedPermissionSet( "LocalIntranet" );
 }            
开发者ID:ArildF,项目名称:masters,代码行数:6,代码来源:policylevel.cs

示例6: ToXml

	public SecurityElement ToXml(PolicyLevel level)
			{
				SecurityElement element;
				element = new SecurityElement("CodeGroup");
				element.AddAttribute
					("class",
					 SecurityElement.Escape(GetType().AssemblyQualifiedName));
				element.AddAttribute("version", "1");
				element.AddChild(membershipCondition.ToXml(level));
				if(policy != null)
				{
					PermissionSet permSet = policy.PermissionSetNoCopy;
					if(permSet is NamedPermissionSet && level != null &&
					   level.GetNamedPermissionSet
					   		(((NamedPermissionSet)permSet).Name) != null)
					{
						element.AddAttribute
							("PermissionSetName",
							 ((NamedPermissionSet)permSet).Name);
					}
					else if(!permSet.IsEmpty())
					{
						element.AddChild(permSet.ToXml());
					}
					if(policy.Attributes != PolicyStatementAttribute.Nothing)
					{
						element.AddAttribute
							("Attributes", policy.Attributes.ToString());
					}
					foreach(CodeGroup group in Children)
					{
						element.AddChild(group.ToXml(level));
					}
				}
				if(name != null)
				{
					element.AddAttribute("Name", SecurityElement.Escape(name));
				}
				if(description != null)
				{
					element.AddAttribute
						("Description", SecurityElement.Escape(description));
				}
				CreateXml(element, level);
				return element;
			}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:46,代码来源:CodeGroup.cs

示例7: MakePluginCodeGroup

 static void MakePluginCodeGroup(PolicyLevel level, CodeGroup root, String url)
 {
     // Create a membership condition for our path
       IMembershipCondition membership =
      new UrlMembershipCondition(url);
       // Get the internet permissiion set
       PermissionSet permissions =
      level.GetNamedPermissionSet("Internet");
       permissions.GetType(); // Again, no nulls allowed
       // Create a policy statement from the permissions and condition
       PolicyStatement statement = new PolicyStatement(permissions,
      PolicyStatementAttribute.Exclusive |
      PolicyStatementAttribute.LevelFinal);
       // New code group
       UnionCodeGroup group = new UnionCodeGroup(membership, statement);
       group.Description=String.Format(
      "Code group that restricts permissions on "+
      "assemblies in {0}, to support secure loading of plugins. "+
      "This group was added by application: {1}", url,
      Assembly.GetEntryAssembly().CodeBase);
       group.Name = GenerateCodeGroupName(url);
       root.AddChild(group);
       SecurityManager.SavePolicyLevel(level);
 }
开发者ID:truonghinh,项目名称:TnX,代码行数:24,代码来源:PluginManager.cs

示例8: FromXml

		public void FromXml (SecurityElement e, PolicyLevel level)
		{
			if (null == e)
				throw new ArgumentNullException("e");

			PermissionSet ps = null;
			string psetname = e.Attribute ("PermissionSetName");
			if ((psetname != null) && (level != null)) {
				ps = level.GetNamedPermissionSet (psetname);
			}
			else {
				SecurityElement pset = e.SearchForChildByTag ("PermissionSet");
				if (pset != null) {
					Type classType = Type.GetType (pset.Attribute ("class"));
					ps = (PermissionSet) Activator.CreateInstance (classType, true);
					ps.FromXml (pset);
				}
				else {
					ps = new PermissionSet (new PermissionSet (PermissionState.None));
				}
			}
			m_policy = new PolicyStatement (ps);

			m_children.Clear ();
			if ((e.Children != null) && (e.Children.Count > 0)) {
				foreach (SecurityElement se in e.Children) {
					if (se.Tag == "CodeGroup") {
						this.AddChild (CodeGroup.CreateFromXml (se, level));
					}
				}
			}
			
			m_membershipCondition = null;
			SecurityElement mc = e.SearchForChildByTag ("IMembershipCondition");
			if (mc != null) {
				string className = mc.Attribute ("class");
				Type classType = Type.GetType (className);
				if (classType == null)
					classType = Type.GetType ("System.Security.Policy." + className);
				m_membershipCondition = (IMembershipCondition) Activator.CreateInstance (classType, true);
				m_membershipCondition.FromXml (mc, level);
			}

			m_name = e.Attribute("Name");
			m_description = e.Attribute("Description");

			// seems like we might need this to Resolve() in subclasses
			//m_level = level;

			ParseXml (e, level);
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:51,代码来源:CodeGroup.cs

示例9: SetTrustParameters

 private void SetTrustParameters(TrustSection trustSection, SecurityPolicySection securityPolicySection, PolicyLevel policyLevel)
 {
   this._trustLevel = trustSection.Level;
   if (!(this._trustLevel != "Full"))
     return;
   this._namedPermissionSet = policyLevel.GetNamedPermissionSet(trustSection.PermissionSetName);
   this._policyLevel = policyLevel;
   this._hostSecurityPolicyResolverType = trustSection.HostSecurityPolicyResolverType;
   this._fcm.StartMonitoringFile(securityPolicySection.TrustLevels[trustSection.Level].PolicyFileExpanded, new FileChangeEventHandler(this.OnSecurityPolicyFileChange));
 }
开发者ID:consumentor,项目名称:Server,代码行数:10,代码来源:HttpRuntime.cs


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