Skip to content
This repository was archived by the owner on Oct 18, 2023. It is now read-only.
This repository was archived by the owner on Oct 18, 2023. It is now read-only.

It is possible to specify the name of the Id attribute in the Xmldsig gem #7

@davideluque

Description

@davideluque

Change:

@doc = NemID::XMLDSig::Document.new(string)

to:

@doc = NemID::XMLDSig::Document.new(string, id_attr: 'Id')

and change:

@doc = NemID::XMLDSig::Document.new(Base64.decode64(string))

to:

@doc = NemID::XMLDSig::Document.new(Base64.decode64(string), id_attr: 'Id')

And the following code is not needed anymore:

# The "referenced_node" method needs to be overridden since NemID uses
# "Id" (as opposed to ID or wsu:Id) as the attribute name in the "Signature"
# element of the XML document.
Xmldsig::Reference.class_eval do
def referenced_node
if reference_uri && reference_uri != ""
id = reference_uri[1..-1]
if ref = document.dup.at_xpath("//*[@ID='#{id}' or @Id='#{id}' or @wsu:Id='#{id}']", NAMESPACES)
ref
else
raise(
ReferencedNodeNotFound,
"Could not find the referenced node #{id}'"
)
end
else
document.dup.root
end
end
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions