xmldsig 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -58,11 +58,11 @@ end
58
58
  # Validation
59
59
 
60
60
  signed_document = Xmldsig::SignedDocument.new(signed_xml)
61
- document.verify(certificate)
61
+ signed_document.verify(certificate)
62
62
 
63
63
  # With block
64
64
  signed_document = Xmldsig::SignedDocument.new(signed_xml)
65
- document.verify do |signature_value, data|
65
+ signed_document.verify do |signature_value, data|
66
66
  certificate.public_key.verify(OpenSSL::Digest::SHA256.new, signature_value, data)
67
67
  end
68
68
  ```
@@ -19,7 +19,7 @@ module Xmldsig
19
19
  if reference_uri && reference_uri != ""
20
20
  document.dup.at_xpath("//*[@ID='#{reference_uri[1..-1]}']")
21
21
  else
22
- document.dup.at_xpath(signature.parent.path)
22
+ document.root
23
23
  end
24
24
  end
25
25
 
@@ -81,7 +81,7 @@ module Xmldsig
81
81
  end
82
82
 
83
83
  def digest_value=(digest_value)
84
- signed_info.at_xpath("descendant::ds:DigestValue").content =
84
+ signed_info.at_xpath("descendant::ds:DigestValue", NAMESPACES).content =
85
85
  Base64.encode64(digest_value).chomp
86
86
  end
87
87
 
@@ -97,7 +97,7 @@ module Xmldsig
97
97
  end
98
98
 
99
99
  def signature_value=(signature_value)
100
- signature.at_xpath("descendant::ds:SignatureValue").content =
100
+ signature.at_xpath("descendant::ds:SignatureValue", NAMESPACES).content =
101
101
  Base64.encode64(signature_value).chomp
102
102
  end
103
103
 
@@ -1,3 +1,3 @@
1
1
  module Xmldsig
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -0,0 +1,33 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
3
+ <soapenv:Body>
4
+ <samlp:ArtifactResponse xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#" ID="_91e79cb2e8cded9a7fd4d68dc480b49d2d1adf88" Version="2.0" IssueInstant="2013-01-17T09:02:44Z">
5
+ <ds:Signature>
6
+ <ds:SignedInfo>
7
+ <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
8
+ <ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/>
9
+ <ds:Reference>
10
+ <ds:Transforms>
11
+ <ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
12
+ <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
13
+ <ec:InclusiveNamespaces PrefixList="ds saml samlp xs"/>
14
+ </ds:Transform>
15
+ </ds:Transforms>
16
+ <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
17
+ <ds:DigestValue></ds:DigestValue>
18
+ </ds:Reference>
19
+ </ds:SignedInfo>
20
+ <ds:SignatureValue></ds:SignatureValue>
21
+ <ds:KeyInfo/>
22
+ </ds:Signature>
23
+ <samlp:Status>
24
+ <samlp:StatusCode/>
25
+ </samlp:Status>
26
+ <samlp:Response ID="_5a88b4aeb1d290c86073874278e5ef302da66739" Version="2.0" IssueInstant="2013-01-17T09:02:44Z">
27
+ <samlp:Status>
28
+ <samlp:StatusCode/>
29
+ </samlp:Status>
30
+ </samlp:Response>
31
+ </samlp:ArtifactResponse>
32
+ </soapenv:Body>
33
+ </soapenv:Envelope>
@@ -29,7 +29,7 @@ describe Xmldsig::Signature do
29
29
  it "returns the referenced node by parent" do
30
30
  signature.stub(:reference_uri).and_return("")
31
31
  signature.referenced_node.to_s.should ==
32
- document.at_xpath("//*[@ID='foo']").to_s
32
+ document.root.to_s
33
33
  end
34
34
  end
35
35
 
@@ -5,17 +5,9 @@ describe Xmldsig do
5
5
  let(:certificate) { OpenSSL::X509::Certificate.new(File.read("spec/fixtures/certificate.cer")) }
6
6
 
7
7
  describe "Sign unsigned documents" do
8
-
9
- %w(
10
- canonicalizer_1_0
11
- canonicalizer_1_1
12
- canonicalizer_exc
13
- digest_sha1
14
- without_namespace_prefix
15
- without_reference_uri
16
- ).each do |document|
8
+ Dir["spec/fixtures/unsigned/*.xml"].each do |document|
17
9
  describe "#{document}" do
18
- let(:unsigned_xml) { File.read("spec/fixtures/unsigned/#{document}.xml") }
10
+ let(:unsigned_xml) { File.read(document) }
19
11
  let(:unsigned_document) { Xmldsig::SignedDocument.new(unsigned_xml) }
20
12
 
21
13
  it "should be signable an validateable" do
File without changes
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xmldsig
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-13 00:00:00.000000000 Z
12
+ date: 2013-01-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
@@ -60,6 +60,7 @@ files:
60
60
  - spec/fixtures/unsigned/canonicalizer_1_1.xml
61
61
  - spec/fixtures/unsigned/canonicalizer_exc.xml
62
62
  - spec/fixtures/unsigned/digest_sha1.xml
63
+ - spec/fixtures/unsigned/with_soap_envelope.xml
63
64
  - spec/fixtures/unsigned/without_namespace_prefix.xml
64
65
  - spec/fixtures/unsigned/without_reference_uri.xml
65
66
  - spec/fixtures/unsigned_nested_signature.xml
@@ -68,7 +69,7 @@ files:
68
69
  - spec/lib/xmldsig/transforms/transform_spec.rb
69
70
  - spec/lib/xmldsig_spec.rb
70
71
  - spec/spec_helper.rb
71
- - xmlsec.gemspec
72
+ - xmldsig.gemspec
72
73
  homepage: https://github.com/benoist/xmldsig
73
74
  licenses: []
74
75
  post_install_message:
@@ -103,6 +104,7 @@ test_files:
103
104
  - spec/fixtures/unsigned/canonicalizer_1_1.xml
104
105
  - spec/fixtures/unsigned/canonicalizer_exc.xml
105
106
  - spec/fixtures/unsigned/digest_sha1.xml
107
+ - spec/fixtures/unsigned/with_soap_envelope.xml
106
108
  - spec/fixtures/unsigned/without_namespace_prefix.xml
107
109
  - spec/fixtures/unsigned/without_reference_uri.xml
108
110
  - spec/fixtures/unsigned_nested_signature.xml