Skip to content
This repository has been 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

Open
davideluque opened this issue Aug 23, 2020 · 0 comments
Labels
enhancement New feature or request

Comments

@davideluque
Copy link
Owner

davideluque commented Aug 23, 2020

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

@davideluque davideluque added the enhancement New feature or request label Aug 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant