pub struct SignContext<'a> { /* private fields */ }Expand description
XMLDSig signing context.
Implementations§
Source§impl<'a> SignContext<'a>
impl<'a> SignContext<'a>
Sourcepub fn new(signing_key: &'a dyn SigningKey) -> Self
pub fn new(signing_key: &'a dyn SigningKey) -> Self
Create a signing context using the supplied private key.
Sourcepub fn policy(self, policy: SigningPolicy) -> Self
pub fn policy(self, policy: SigningPolicy) -> Self
Replace the complete immutable signing policy snapshot.
Sourcepub fn provider(self, provider: &'a dyn CryptoProvider) -> Self
pub fn provider(self, provider: &'a dyn CryptoProvider) -> Self
Select the cryptographic provider for digest and randomness operations.
Sourcepub fn key_info_writer(self, writer: &'a dyn KeyInfoWriter) -> Self
pub fn key_info_writer(self, writer: &'a dyn KeyInfoWriter) -> Self
Configure signing to populate the direct <Signature>/<KeyInfo> placeholder.
Sourcepub fn start_node_id(self, id: &'a str) -> Self
pub fn start_node_id(self, id: &'a str) -> Self
Select an operation start node by ID and scope template selection to its subtree.
Self::sign_with_builder instead uses the selected node as the append
location and signs the newly appended direct <Signature> child.
Sourcepub fn signature_template_selection(
self,
selection: SignatureTemplateSelection,
) -> Self
pub fn signature_template_selection( self, selection: SignatureTemplateSelection, ) -> Self
Select which existing <Signature> template Self::sign_template signs.
The default is SignatureTemplateSelection::LastDescendant, preserving
append-then-sign behavior. Compatibility boundaries that model donor
document-order lookup can explicitly select FirstDescendant.
Sourcepub fn id_attributes(self, registrations: &'a [IdAttributeRegistration]) -> Self
pub fn id_attributes(self, registrations: &'a [IdAttributeRegistration]) -> Self
Add caller-declared ID attributes for start-node and Reference lookup.
Sourcepub fn xpath_here_semantics(self, semantics: XPathHereSemantics) -> Self
pub fn xpath_here_semantics(self, semantics: XPathHereSemantics) -> Self
Select the node returned by XPath’s here() extension function.
The default follows XMLDSig and returns the <XPath> parameter.
XPathHereSemantics::XmlSecLegacy is available only for producing
signatures compatible with libxmlsec1’s <Transform> interpretation.
Sourcepub fn sign_template(&self, xml: &str) -> Result<String, SigningError>
pub fn sign_template(&self, xml: &str) -> Result<String, SigningError>
Sign XML that already contains a <Signature> template.
The template must include empty <DigestValue> and <SignatureValue>
targets. The pipeline first materializes configured <KeyInfo> content,
then fills reference digests, reparses the result, canonicalizes
<SignedInfo>, signs those canonical bytes, and fills the base64
<SignatureValue>. This ordering permits <KeyInfo> to be referenced
from <SignedInfo> without producing a stale digest.
Sourcepub fn sign_with_builder(
&self,
xml: &str,
builder: &SignatureBuilder,
) -> Result<String, SigningError>
pub fn sign_with_builder( &self, xml: &str, builder: &SignatureBuilder, ) -> Result<String, SigningError>
Build a signature template, append it to the selected start node (or the document root when no selector is set), then sign that new template.