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


C# NamespaceManager.AddNamespace方法代码示例

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


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

示例1: Index

		public ActionResult Index() {

			// Instantiate the XmlElementSignatureStarter class, responsible for receiving the signature elements and start the
			// signature process
			var signatureStarter = new FullXmlSignatureStarter(Util.GetRestPkiClient());

			// Set the XML to be signed, a sample XML Document
			signatureStarter.SetXml(Util.GetSampleXmlDocument());

			// Set the signature policy
			signatureStarter.SetSignaturePolicy(StandardXmlSignaturePolicies.XadesBes);

			// Set a SecurityContext to be used to determine trust in the certificate chain
			signatureStarter.SetSecurityContext(StandardSecurityContexts.PkiBrazil);
			// Note: By changing the SecurityContext above you can accept only certificates from a certain PKI, for instance,
			// ICP-Brasil (\Lacuna\StandardSecurityContexts::PKI_BRAZIL).

			// Set the location on which to insert the signature node. If the location is not specified, the signature will appended
			// to the root element (which is most usual with enveloped signatures).
			var nsm = new NamespaceManager();
			nsm.AddNamespace("ls", "http://www.lacunasoftware.com/sample");
			signatureStarter.SetSignatureElementLocation("//ls:signaturePlaceholder", Api.XmlSignature.XmlInsertionOptions.AppendChild, nsm);

			// Call the StartWithWebPki() method, which initiates the signature. This yields the token, a 43-character
			// case-sensitive URL-safe string, which identifies this signature process. We'll use this value to call the
			// signWithRestPki() method on the Web PKI component (see javascript on the view) and also to complete the signature
			// on the POST action below (this should not be mistaken with the API access token).
			var token = signatureStarter.StartWithWebPki();

			// The token acquired above can only be used for a single signature attempt. In order to retry the signature it is
			// necessary to get a new token. This can be a problem if the user uses the back button of the browser, since the
			// browser might show a cached page that we rendered previously, with a now stale token. To prevent this from happening,
			// we call the method SetNoCacheHeaders() (in BaseController) which sets HTTP headers to prevent caching of the page.
			base.SetNoCacheHeaders();

			// Render the signature page with the token obtained from REST PKI
			return View(new XmlSignatureModel() {
				Token = token
			});
		}
开发者ID:willyscampos,项目名称:RestPkiSamples,代码行数:40,代码来源:XmlFullSignatureController.cs


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