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


C# SecurityElement.AddChild方法代码示例

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


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

示例1: Test

    public static Boolean Test()
    {
        Boolean bRes = true;

		SecurityElement el = new SecurityElement("whatever");
//		el.Text = "<Key>RSA</Key><Digest>SHA1</Digest><Formatter>System.Security.Cryptography.RSAPKCS1SignatureFormatter</Formatter><Deformatter>System.Security.Cryptography.RSAPKCS1SignatureFormatter</Deformatter>";
		SecurityElement el_key = new SecurityElement("Key");
		el_key.Text = "RSA";
		SecurityElement el_digest = new SecurityElement("Digest");
		el_digest.Text = "SHA1";
		SecurityElement el_form = new SecurityElement("Formatter");
		el_form.Text = "System.Security.Cryptography.RSAPKCS1SignatureFormatter";
		SecurityElement el_deform = new SecurityElement("Deformatter");
		el_deform.Text = "System.Security.Cryptography.RSAPKCS1SignatureDeformatter";

		el.AddChild(el_key);
		el.AddChild(el_digest);
		el.AddChild(el_form);
		el.AddChild(el_deform);

		SignatureDescription sd_empty = new SignatureDescription();
		
		SignatureDescription sd = new SignatureDescription(el);

		Console.WriteLine(sd.CreateDigest());
		Console.WriteLine(sd.CreateFormatter(RSA.Create()));
		Console.WriteLine(sd.CreateDeformatter(RSA.Create()));

        return bRes;
    }
开发者ID:koson,项目名称:.NETMF_for_LPC17xx,代码行数:30,代码来源:SignDesc.cs

示例2: Constructor_SecurityElement_RSA

        public void Constructor_SecurityElement_RSA()
        {
            SecurityElement se = new SecurityElement("RSASignature");
            se.AddChild(new SecurityElement("Key", "System.Security.Cryptography.RSACryptoServiceProvider"));
            se.AddChild(new SecurityElement("Digest", "System.Security.Cryptography.SHA1CryptoServiceProvider"));
            se.AddChild(new SecurityElement("Formatter", "System.Security.Cryptography.RSAPKCS1SignatureFormatter"));
            se.AddChild(new SecurityElement("Deformatter", "System.Security.Cryptography.RSAPKCS1SignatureDeformatter"));

            SignatureDescription sig = new SignatureDescription(se);
            Assert.Equal("System.Security.Cryptography.RSACryptoServiceProvider", sig.KeyAlgorithm);
            Assert.Equal("System.Security.Cryptography.SHA1CryptoServiceProvider", sig.DigestAlgorithm);
            Assert.Equal("System.Security.Cryptography.RSAPKCS1SignatureFormatter", sig.FormatterAlgorithm);
            Assert.Equal("System.Security.Cryptography.RSAPKCS1SignatureDeformatter", sig.DeformatterAlgorithm);
        }
开发者ID:dotnet,项目名称:corefx,代码行数:14,代码来源:SignatureDescriptionTests.cs

示例3: ToString

	// Convert this object into a string.
	public override String ToString()
			{
				SecurityElement element = new SecurityElement
					("System.Security.Policy.PermissionRequestEvidence");
				SecurityElement child;
				element.AddAttribute("version", "1");
				if(request != null)
				{
					child = new SecurityElement("Request");
					child.AddChild(request.ToXml());
					element.AddChild(child);
				}
				if(optional != null)
				{
					child = new SecurityElement("Optional");
					child.AddChild(optional.ToXml());
					element.AddChild(child);
				}
				if(denied != null)
				{
					child = new SecurityElement("Denied");
					child.AddChild(denied.ToXml());
					element.AddChild(child);
				}
				return element.ToString();
			}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:27,代码来源:PermissionRequestEvidence.cs

示例4: ToString

		public override string ToString () 
		{
			SecurityElement se = new SecurityElement ("System.Security.Policy.PermissionRequestEvidence");
			se.AddAttribute ("version", "1");

			if (requested != null) {
				SecurityElement requestElement = new SecurityElement ("Request");
				requestElement.AddChild (requested.ToXml ());
				se.AddChild (requestElement);
			}
			if (optional != null) {
				SecurityElement optionalElement = new SecurityElement ("Optional");
				optionalElement.AddChild (optional.ToXml ());
				se.AddChild (optionalElement);
			}
			if (denied != null) {
				SecurityElement deniedElement = new SecurityElement ("Denied");
				deniedElement.AddChild (denied.ToXml ());
				se.AddChild (deniedElement);
			}
			return se.ToString ();
		}
开发者ID:runefs,项目名称:Marvin,代码行数:22,代码来源:PermissionRequestEvidence.cs

示例5: FromXml

        public void FromXml()
        {
            PrincipalPermission p = new PrincipalPermission(PermissionState.None);
            SecurityElement se = p.ToXml();
            Assert.NotNull(se);

            PrincipalPermission p2 = (PrincipalPermission)p.Copy();
            p2.FromXml(se);
            Assert.Equal(p.ToString(), p2.ToString());

            string className = (string)se.Attributes["class"];
            string version = (string)se.Attributes["version"];

            SecurityElement se2 = new SecurityElement(se.Tag);
            se2.AddAttribute("class", className);
            se2.AddAttribute("version", version);
            p2.FromXml(se2);

            SecurityElement sec = new SecurityElement("Identity");
            sec.AddAttribute("Authenticated", "true");
            se2.AddChild(sec);
            p2.FromXml(se2);
            Assert.True(p2.IsUnrestricted());
        }
开发者ID:dotnet,项目名称:corefx,代码行数:24,代码来源:PrincipalPermissionTests.cs

示例6: EventLogPermission

		private static SecurityElement EventLogPermission (string name, string access)
		{
			SecurityElement se = new SecurityElement ("IPermission");
			se.AddAttribute ("class", EventLogPermissionClass);
			se.AddAttribute ("version", "1");

			SecurityElement child = new SecurityElement ("Machine");
			child.AddAttribute ("name", name);
			child.AddAttribute ("access", access);

			se.AddChild (child);
			return se;
		}
开发者ID:runefs,项目名称:Marvin,代码行数:13,代码来源:DefaultPolicies.cs

示例7: ToXml

        internal SecurityElement ToXml()
        {
            SecurityElement elem = new SecurityElement( "System.Security.Policy.Site" );
            // If you hit this assert then most likely you are trying to change the name of this class. 
            // This is ok as long as you change the hard coded string above and change the assert below.
            Contract.Assert( this.GetType().FullName.Equals( "System.Security.Policy.Site" ), "Class name changed!" );

            elem.AddAttribute( "version", "1" );
            
            if(m_name != null)
                elem.AddChild( new SecurityElement( "Name", m_name.ToString() ) );
                
            return elem;
        }
开发者ID:uQr,项目名称:referencesource,代码行数:14,代码来源:site.cs

示例8: ToXml

        [System.Security.SecuritySafeCritical]  // auto-generated
        public SecurityElement ToXml() {
            // Make sure we have loaded everything and that all the
            // permission sets are loaded.

            CheckLoaded();
            LoadAllPermissionSets();

            IEnumerator enumerator;
            SecurityElement e = new SecurityElement("PolicyLevel");
            e.AddAttribute("version", "1");

            Hashtable classes = new Hashtable();
            lock (this) {
                SecurityElement elPermSets = new SecurityElement("NamedPermissionSets");
                enumerator = m_namedPermissionSets.GetEnumerator();
                while (enumerator.MoveNext()) {
                    elPermSets.AddChild(NormalizeClassDeep(((NamedPermissionSet)enumerator.Current).ToXml(), classes));
                }

                SecurityElement elCodeGroup = NormalizeClassDeep(m_rootCodeGroup.ToXml(this), classes);

                SecurityElement elFullTrust = new SecurityElement("FullTrustAssemblies");
                enumerator = m_fullTrustAssemblies.GetEnumerator();
                while (enumerator.MoveNext()) {
                    elFullTrust.AddChild(NormalizeClassDeep(((StrongNameMembershipCondition)enumerator.Current).ToXml(), classes));
                }

                SecurityElement elClasses = new SecurityElement("SecurityClasses");
                IDictionaryEnumerator dicEnumerator = classes.GetEnumerator();
                while (dicEnumerator.MoveNext()) {
                    SecurityElement elClass = new SecurityElement("SecurityClass");
                    elClass.AddAttribute("Name", (string)dicEnumerator.Value);
                    elClass.AddAttribute("Description", (string)dicEnumerator.Key);
                    elClasses.AddChild(elClass);
                }

                e.AddChild(elClasses);
                e.AddChild(elPermSets);
                e.AddChild(elCodeGroup);
                e.AddChild(elFullTrust);
            }

            return e;
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:45,代码来源:PolicyLevel.cs

示例9: ToXml

        internal SecurityElement ToXml()
        {
            SecurityElement root = new SecurityElement( "System.Security.Policy.ApplicationDirectory" );
            // If you hit this assert then most likely you are trying to change the name of this class. 
            // This is ok as long as you change the hard coded string above and change the assert below.
            Contract.Assert( this.GetType().FullName.Equals( "System.Security.Policy.ApplicationDirectory" ), "Class name changed!" );

            root.AddAttribute( "version", "1" );
            
            if (m_appDirectory != null)
                root.AddChild( new SecurityElement( "Directory", m_appDirectory.ToString() ) );
            
            return root;
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:14,代码来源:applicationdirectory.cs

示例10: SetFactoryPermissionSets

        private void SetFactoryPermissionSets() {
            lock (this) {
                m_namedPermissionSets = new ArrayList();
                string[] repStrs = new string[s_FactoryPolicySearchStrings.Length];

                repStrs[0] = ThisAssembly.Version;
                repStrs[1] = Environment.GetResourceString("Policy_PS_FullTrust");
                repStrs[2] = Environment.GetResourceString("Policy_PS_Everything");
                repStrs[3] = Environment.GetResourceString("Policy_PS_Nothing");
                repStrs[4] = Environment.GetResourceString("Policy_PS_SkipVerification"); 
                repStrs[5] = Environment.GetResourceString("Policy_PS_Execution");

                m_permSetElement = new Parser(PolicyLevelData.s_defaultPermissionSets, s_FactoryPolicySearchStrings, repStrs).GetTopElement();
                m_permSetElement.AddChild(GetInternetElement());
                m_permSetElement.AddChild(GetLocalIntranetElement());
            }
        }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:17,代码来源:policylevel.cs

示例11: SaveRecord

	private Boolean SaveRecord()
	{
		SecurityElement xmlRoot = new SecurityElement("expansion_pack_record");

		lock (m_lock)
		{
			foreach (var item in m_packRecordMap)
			{
				String packId = item.Key;
				ExpansionPackRecord record = item.Value;

				SecurityElement xmlItem = new SecurityElement("item");
				xmlRoot.AddChild(xmlItem);

				xmlItem.AddAttribute("id", packId);
				xmlItem.AddAttribute("state", ((Int32)record.state).ToString());
			}
		}

		try
		{
			CreateDirectoryForFile(GetRecordFilePath());
			File.WriteAllText(GetRecordFilePath(), xmlRoot.ToString());
			return true;
		}
		catch (IOException e)
		{
			Debug.LogException(e);
			return false;
		}
	}
开发者ID:fengqk,项目名称:Art,代码行数:31,代码来源:ExpansionPackManager.cs

示例12: ToXml

        public SecurityElement ToXml () {
            SecurityElement elRoot = new SecurityElement("ApplicationTrust");
            elRoot.AddAttribute("version", "1");
 
#if FEATURE_CLICKONCE
            if (m_appId != null) { 
                elRoot.AddAttribute("FullName", SecurityElement.Escape(m_appId.FullName)); 
            }
            if (m_appTrustedToRun) { 
                elRoot.AddAttribute("TrustedToRun", "true");
            }
            if (m_persist) {
                elRoot.AddAttribute("Persist", "true"); 
            }
#endif // FEATURE_CLICKONCE 
 
            if (m_psDefaultGrant != null) {
                SecurityElement elDefaultGrant = new SecurityElement("DefaultGrant"); 
                elDefaultGrant.AddChild(m_psDefaultGrant.ToXml());
                elRoot.AddChild(elDefaultGrant);
            }
            if (m_fullTrustAssemblies.Count > 0) { 
                SecurityElement elFullTrustAssemblies = new SecurityElement("FullTrustAssemblies");
                foreach (StrongName fullTrustAssembly in m_fullTrustAssemblies) { 
                    elFullTrustAssemblies.AddChild(fullTrustAssembly.ToXml()); 
                }
                elRoot.AddChild(elFullTrustAssemblies); 
            }

#if FEATURE_CLICKONCE
            if (ExtraInfo != null) { 
                elRoot.AddChild(ObjectToXml("ExtraInfo", ExtraInfo));
            } 
#endif // FEATURE_CLICKONCE 
            return elRoot;
        } 
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:36,代码来源:ApplicationTrust.cs

示例13: ToString

		public override string ToString ()
		{
			// MS "by design" behaviour (see FDBK14362)
			ThrowOnInvalid (Directory);
			SecurityElement element = new SecurityElement ("System.Security.Policy.ApplicationDirectory");
			element.AddAttribute ("version", "1");
			element.AddChild (new SecurityElement ("Directory", directory));
			return element.ToString ();
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:9,代码来源:ApplicationDirectory.cs

示例14: ToXml

		public SecurityElement ToXml () 
		{
			SecurityElement se = new SecurityElement ("Permission");
			Type type = this.GetType ();
			se.AddAttribute ("class", type.FullName + ", " + type.Assembly.ToString ().Replace ('\"', '\''));
			se.AddAttribute ("version", version.ToString ());

			foreach (PrincipalInfo pi in principals) {
				SecurityElement sec = new SecurityElement ("Identity");
				if (pi.Name != null)
					sec.AddAttribute ("ID", pi.Name);
				if (pi.Role != null)
					sec.AddAttribute ("Role", pi.Role);
				if (pi.IsAuthenticated)
					sec.AddAttribute ("Authenticated", "true");
				se.AddChild (sec);
			}
			return se;
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:19,代码来源:PrincipalPermission.cs

示例15: ToXml

		public SecurityElement ToXml () 
		{
			SecurityElement se = new SecurityElement ("ApplicationTrust");
			se.AddAttribute ("version", "1");

			if (_appid != null) {
				se.AddAttribute ("FullName", _appid.FullName);
			}

			if (_trustrun) {
				se.AddAttribute ("TrustedToRun", "true");
			}

			if (_persist) {
				se.AddAttribute ("Persist", "true");
			}

			SecurityElement defaultGrant = new SecurityElement ("DefaultGrant");
			defaultGrant.AddChild (DefaultGrantSet.ToXml ());
			se.AddChild (defaultGrant);

			if (_xtranfo != null) {
				byte[] data = null;
				using (MemoryStream ms = new MemoryStream ()) {
					BinaryFormatter bf = new BinaryFormatter ();
					bf.Serialize (ms, _xtranfo);
					data = ms.ToArray ();
				}
				SecurityElement xtra = new SecurityElement ("ExtraInfo");
				xtra.AddAttribute ("Data", CryptoConvert.ToHex (data));
				se.AddChild (xtra);
			}

			return se;
		}
开发者ID:Profit0004,项目名称:mono,代码行数:35,代码来源:ApplicationTrust.cs


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