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


C# SecurityElement类代码示例

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


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


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