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

C# SecurityElement类代码示例

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

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



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

示例1: Element

		// snippet moved from FileIOPermission (nickd) to be reused in all derived classes
		internal static SecurityElement Element (Type type, int version) 
		{
			SecurityElement se = new SecurityElement ("IPermission");
			se.AddAttribute ("class", type.FullName + ", " + type.Assembly.ToString ().Replace ('\"', '\''));
			se.AddAttribute ("version", version.ToString ());
			return se;
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:8,代码来源:PermissionHelper.cs


示例2: 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


示例3: ToXml

 public SecurityElement ToXml( PolicyLevel level )
 {
     SecurityElement root = new SecurityElement( "IMembershipCondition" );
     System.Security.Util.XMLUtil.AddClassAttribute( root, this.GetType(), this.GetType().FullName );
     root.AddAttribute( "version", "1" );
     return root;
 }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:7,代码来源:GACMembershipCondition.cs


示例4: ApplicationTrustCallMethods

 public static void ApplicationTrustCallMethods()
 {
     ApplicationTrust at = new ApplicationTrust();
     SecurityElement se = new SecurityElement("");
     at.FromXml(se);
     se = at.ToXml();
 }
开发者ID:dotnet,项目名称:corefx,代码行数:7,代码来源:EvidenceBaseTests.cs


示例5: FromXml

		public void FromXml (SecurityElement e, PolicyLevel level)
		{
			MembershipConditionHelper.CheckSecurityElement (e, "e", version, version);
			if (!Boolean.TryParse (e.Attribute ("LookAtDir"), out _lookAtDir))
				_lookAtDir = false;
			// PolicyLevel isn't used as there's no need to resolve NamedPermissionSet references
		}
开发者ID:runefs,项目名称:Marvin,代码行数:7,代码来源:ApplicationMembershipCondition.cs


示例6: 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


示例7: SignatureDescription

	public SignatureDescription(SecurityElement el)
			{
				if(el == null)
				{
					throw new ArgumentNullException("el");
				}
				foreach(SecurityElement e in el.Children)
				{
					if(e.Tag == "Deformatter")
					{
						deformatter = e.Text;
					}
					else if(e.Tag == "Digest")
					{
						digest = e.Text;
					}
					else if(e.Tag == "Formatter")
					{
						formatter = e.Text;
					}
					else if(e.Tag == "Key")
					{
						key = e.Text;
					}
				}
			}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:26,代码来源:SignatureDescription.cs


示例8: FromXml

		public override void FromXml (SecurityElement securityElement)
		{
			// General validation in CodeAccessPermission
			CheckSecurityElement (securityElement, "securityElement", version, version);
			// Note: we do not (yet) care about the return value 
			// as we only accept version 1 (min/max values)
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:7,代码来源:GacIdentityPermission.cs


示例9: IDRole

 internal IDRole(SecurityElement e)
 {
     string elAuth = e.Attribute("Authenticated");
     Authenticated = elAuth == null ? false : string.Equals(elAuth, "true", StringComparison.OrdinalIgnoreCase);
     ID = e.Attribute("ID");
     Role = e.Attribute("Role");
 }
开发者ID:dotnet,项目名称:corefx,代码行数:7,代码来源:IDRole.cs


示例10: CheckSecurityElement

		internal static int CheckSecurityElement (SecurityElement se, string parameterName, int minimumVersion, int maximumVersion) 
		{
			if (se == null)
				throw new ArgumentNullException (parameterName);

			if (se.Attribute ("class") == null) {
				string msg = Locale.GetText ("Missing 'class' attribute.");
				throw new ArgumentException (msg, parameterName);
			}

			// we assume minimum version if no version number is supplied
			int version = minimumVersion;
			string v = se.Attribute ("version");
			if (v != null) {
				try {
					version = Int32.Parse (v);
				}
				catch (Exception e) {
					string msg = Locale.GetText ("Couldn't parse version from '{0}'.");
					msg = String.Format (msg, v);
					throw new ArgumentException (msg, parameterName, e);
				}
			}

			if ((version < minimumVersion) || (version > maximumVersion)) {
				string msg = Locale.GetText ("Unknown version '{0}', expected versions between ['{1}','{2}'].");
				msg = String.Format (msg, version, minimumVersion, maximumVersion);
				throw new ArgumentException (msg, parameterName);
			}
			return version;
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:31,代码来源:PermissionHelper.cs


示例11: TestSecurityElementConstructor

	// Test the constructor.
	public void TestSecurityElementConstructor()
			{
				SecurityElement e;

				try
				{
					e = new SecurityElement(null);
					Fail("Constructor (1)");
				}
				catch(ArgumentNullException)
				{
					// Success.
				}
				try
				{
					e = new SecurityElement("");
					Fail("Constructor (2)");
				}
				catch(ArgumentException)
				{
					// Success.
				}
				try
				{
					e = new SecurityElement("<");
					Fail("Constructor (3)");
				}
				catch(ArgumentException)
				{
					// Success.
				}
				try
				{
					e = new SecurityElement("a", "<");
					Fail("Constructor (4)");
				}
				catch(ArgumentException)
				{
					// Success.
				}
				try
				{
					e = new SecurityElement("&amp;");
					Fail("Constructor (5)");
				}
				catch(ArgumentException)
				{
					// Success.
				}
				e = new SecurityElement("foo", "bar");
				AssertEquals("Constructor (6)", "foo", e.Tag);
				AssertEquals("Constructor (7)", "bar", e.Text);
				e = new SecurityElement("foo");
				AssertEquals("Constructor (8)", "foo", e.Tag);
				AssertNull("Constructor (9)", e.Text);
				e = new SecurityElement("foo", "&amp;");
				AssertEquals("Constructor (10)", "foo", e.Tag);
				AssertEquals("Constructor (11)", "&", e.Text);
			}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:60,代码来源:TestSecurityElement.cs


示例12: FromXml

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

            if (!e.Tag.Equals( "IMembershipCondition" ))
                throw new ArgumentException( Environment.GetResourceString( "Argument_MembershipConditionElement" ) );
        }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:8,代码来源:gacmembershipcondition.cs


示例13: SignatureDescription

 public SignatureDescription(SecurityElement el) {
     if (el == null) throw new ArgumentNullException("el");
     Contract.EndContractBlock();
     _strKey = el.SearchForTextOfTag("Key");
     _strDigest = el.SearchForTextOfTag("Digest");
     _strFormatter = el.SearchForTextOfTag("Formatter");
     _strDeformatter = el.SearchForTextOfTag("Deformatter");
 }
开发者ID:uQr,项目名称:referencesource,代码行数:8,代码来源:signaturedescription.cs


示例14: ToXml

  } //Union()

  public override SecurityElement ToXml() 
  {
    SecurityElement s = new SecurityElement("IPermission");
    s.AddAttribute("class","myperm, myperm, Version=1.0.1.0, Culture=neutral, PublicKeyToken=0e8dcc8628396732");
    s.AddAttribute("version", "1");
    s.AddAttribute("Unrestricted", "true");
    return s;
  } //ToXml()
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:10,代码来源:myperm.cs


示例15: Constructor_SecurityElement_Empty

 public void Constructor_SecurityElement_Empty()
 {
     SecurityElement se = new SecurityElement("xml");
     SignatureDescription sig = new SignatureDescription(se);
     Assert.Null(sig.KeyAlgorithm);
     Assert.Null(sig.DigestAlgorithm);
     Assert.Null(sig.FormatterAlgorithm);
     Assert.Null(sig.DeformatterAlgorithm);
 }
开发者ID:dotnet,项目名称:corefx,代码行数:9,代码来源:SignatureDescriptionTests.cs


示例16: SignatureDescription

 public SignatureDescription(SecurityElement el)
 {
     if (el == null)
         throw new ArgumentNullException(nameof(el));
     KeyAlgorithm = el.SearchForTextOfTag("Key");
     DigestAlgorithm = el.SearchForTextOfTag("Digest");
     FormatterAlgorithm = el.SearchForTextOfTag("Formatter");
     DeformatterAlgorithm = el.SearchForTextOfTag("Deformatter");
 }
开发者ID:dotnet,项目名称:corefx,代码行数:9,代码来源:SignatureDescription.cs


示例17: PermissionRequestEvidenceCallMethods

 public static void PermissionRequestEvidenceCallMethods()
 {
     PermissionSet ps = new PermissionSet(new PermissionState());
     PermissionRequestEvidence pre = new PermissionRequestEvidence(ps, ps, ps);
     PermissionRequestEvidence obj = pre.Copy();
     string str = ps.ToString();
     SecurityElement se = new SecurityElement("");
     ps.FromXml(se);
     se = ps.ToXml();
 }
开发者ID:dotnet,项目名称:corefx,代码行数:10,代码来源:EvidenceBaseTests.cs


示例18: GetAllConfig

	private static SecurityElement GetAllConfig()
	{
		if (m_allConfig == null)
		{
			SecurityElement doc = SecurityElement.FromString(StreamingAssetHelper.ReadFileText(Path.Combine("config", "all_platform_config.xml")));
			m_allConfig = doc.SearchForChildByTag(GetPlatForm());
		}

		return m_allConfig;
	}
开发者ID:fengqk,项目名称:Art,代码行数:10,代码来源:PlatformConfig.cs


示例19: FromXmlWrongVersion

 public void FromXmlWrongVersion()
 {
     PrincipalPermission p = new PrincipalPermission(PermissionState.None);
     SecurityElement se = p.ToXml();
     // can't modify - so we create our own
     SecurityElement se2 = new SecurityElement(se.Tag, se.Text);
     se2.AddAttribute("class", se.Attribute("class"));
     se2.AddAttribute("version", "2");
     Assert.Throws<ArgumentException>(() => p.FromXml(se2));
 }
开发者ID:dotnet,项目名称:corefx,代码行数:10,代码来源:PrincipalPermissionTests.cs


示例20: ToString

		public override string ToString ()
		{
			SecurityElement se = new SecurityElement ("System.Security.Policy.Publisher");
			se.AddAttribute ("version", "1");
			SecurityElement cert = new SecurityElement ("X509v3Certificate");
			string data = m_cert.GetRawCertDataString ();
			if (data != null)
				cert.Text = data;
			se.AddChild (cert);
			return se.ToString ();
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:11,代码来源:Publisher.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# SecurityId类代码示例发布时间:2022-05-24
下一篇:
C# SecurityContextSource类代码示例发布时间: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