本文整理汇总了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
});
}