canonix 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.4
1
+ 0.1.5
data/canonix.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{canonix}
8
- s.version = "0.1.4"
8
+ s.version = "0.1.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Brendon Muir"]
12
- s.date = %q{2011-07-12}
12
+ s.date = %q{2011-10-04}
13
13
  s.description = %q{This is based on andrewferk's rewrite for Ruby 1.9 compatibility, but applies
14
14
  relevance's fix to ensure proper canonicalisation. It is intended that this be the new official
15
15
  Ruby XML Canonicaliser as the other project seems to be abandoned.}
@@ -31,6 +31,8 @@ Gem::Specification.new do |s|
31
31
  "test/helper.rb",
32
32
  "test/saml_assertion.xml",
33
33
  "test/saml_expected_canonical_form.xml",
34
+ "test/saml_with_default_namespace.xml",
35
+ "test/saml_with_default_namespace_expected_canonical_form.xml",
34
36
  "test/saml_with_inclusive_ns_assertion.xml",
35
37
  "test/saml_with_inclusive_ns_expected_canonical_form.xml",
36
38
  "test/test_xmlcanonicalizer.rb",
@@ -165,7 +165,11 @@ module XML
165
165
  }
166
166
  end
167
167
 
168
- list.sort!()
168
+ if list.delete('xmlns')
169
+ list = ["xmlns"] + list.sort
170
+ else
171
+ list.sort!
172
+ end
169
173
  list.each{|prefix|
170
174
  next if (prefix == "")
171
175
  ns = node.namespace(prefix)
data/test/expected.xml CHANGED
@@ -1,4 +1,4 @@
1
- <samlp:ArtifactResponse xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" xmlns="urn:oasis:names:tc:SAML:2.0:assertion" ID="122401A9D1742640618954CDD50CEC459150836A" IssueInstant="2010-09-10T00:00:50-05:00" Version="2.0"><samlp:Status><samlp:StatusCode ID="A6B45394506685EAD93131AD335775015C49B52C" Value="urn:oasis:names:tc:SAML:2.0:status:Failure"></samlp:StatusCode></samlp:Status><samlp:Assertion ID="11B542652811C7A1AC8B8265D92AB293CCA66B26" IssueInstant="2010-09-10T00:00:50-05:00"><Issuer>example.net</Issuer><Subject><NameID Format="urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress"></NameID><SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer"></SubjectConfirmation></Subject><Conditions NotBefore="2010-09-10T00:00:50-05:00" NotOnOrAfter="2010-09-10T12:00:50-05:00"></Conditions><AuthnStatement AuthnInstant="2010-09-10T00:00:50-05:00"><AuthnContext><AuthnContextClassRef>urn:oasis:names:tc:SAML:2.0:ac:classes:PreviousSession</AuthnContextClassRef></AuthnContext></AuthnStatement><AttributeStatement><Attribute Name="urn:example:profiles"><AttributeValue FriendlyName="type" type="example:profile:attribute">Person</AttributeValue><AttributeValue FriendlyName="SessionID" type="example:profile:attribute">02b5e2df689b97067dc51a0cd2029510</AttributeValue><AttributeValue FriendlyName="Role" type="example:profile:role">Public</AttributeValue></Attribute></AttributeStatement></samlp:Assertion><ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#"><ds:SignedInfo><ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"></ds:CanonicalizationMethod><ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"></ds:SignatureMethod><ds:Reference URI="122401A9D1742640618954CDD50CEC459150836A"><ds:Transforms><ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"></ds:Transform><ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"><InclusiveNamespaces PrefixList="#default saml ds xs xsi"></InclusiveNamespaces></ds:Transform></ds:Transforms><ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></ds:DigestMethod><ds:DigestValue>dQskOs0c6N7GbFJ13SbozqhEQTM=
1
+ <samlp:ArtifactResponse xmlns="urn:oasis:names:tc:SAML:2.0:assertion" xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" ID="122401A9D1742640618954CDD50CEC459150836A" IssueInstant="2010-09-10T00:00:50-05:00" Version="2.0"><samlp:Status><samlp:StatusCode ID="A6B45394506685EAD93131AD335775015C49B52C" Value="urn:oasis:names:tc:SAML:2.0:status:Failure"></samlp:StatusCode></samlp:Status><samlp:Assertion ID="11B542652811C7A1AC8B8265D92AB293CCA66B26" IssueInstant="2010-09-10T00:00:50-05:00"><Issuer>example.net</Issuer><Subject><NameID Format="urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress"></NameID><SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer"></SubjectConfirmation></Subject><Conditions NotBefore="2010-09-10T00:00:50-05:00" NotOnOrAfter="2010-09-10T12:00:50-05:00"></Conditions><AuthnStatement AuthnInstant="2010-09-10T00:00:50-05:00"><AuthnContext><AuthnContextClassRef>urn:oasis:names:tc:SAML:2.0:ac:classes:PreviousSession</AuthnContextClassRef></AuthnContext></AuthnStatement><AttributeStatement><Attribute Name="urn:example:profiles"><AttributeValue FriendlyName="type" type="example:profile:attribute">Person</AttributeValue><AttributeValue FriendlyName="SessionID" type="example:profile:attribute">02b5e2df689b97067dc51a0cd2029510</AttributeValue><AttributeValue FriendlyName="Role" type="example:profile:role">Public</AttributeValue></Attribute></AttributeStatement></samlp:Assertion><ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#"><ds:SignedInfo><ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"></ds:CanonicalizationMethod><ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"></ds:SignatureMethod><ds:Reference URI="122401A9D1742640618954CDD50CEC459150836A"><ds:Transforms><ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"></ds:Transform><ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"><InclusiveNamespaces PrefixList="#default saml ds xs xsi"></InclusiveNamespaces></ds:Transform></ds:Transforms><ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></ds:DigestMethod><ds:DigestValue>dQskOs0c6N7GbFJ13SbozqhEQTM=
2
2
  </ds:DigestValue></ds:Reference></ds:SignedInfo><ds:SignatureValue>d2rgUtclTSl7q68kZTkaFo8/rBZk/NEmkeKT7qM5doiVhHF4FrMuv7NdQVbQ
3
3
  Vi//wyYk6i9u8s13tsYnliSo+4xGbWl112LrAp8U2E8pLjMxqLYQHXw6qV3h
4
4
  TLhKw/k8sYS54nOye9t7M0VxHl+sKfX+YZFr8EI3ST2/BKFqm5c=
@@ -0,0 +1,10 @@
1
+ <saml:Assertion ID='s272db1ff577ed4463edc408a3d7f3571aebf1696a' IssueInstant='2010-10-28T13:35:36Z' Version='2.0' xmlns='urn:oasis:names:tc:SAML:2.0:protocol' xmlns:saml='urn:oasis:names:tc:SAML:2.0:assertion'>
2
+ <saml:Issuer>http://dev.example.com:8080/opensso</saml:Issuer><saml:Subject>
3
+ <saml:NameID Format='urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress' NameQualifier='http://dev.example.com:8080/opensso'>person@example.com</saml:NameID><saml:SubjectConfirmation Method='urn:oasis:names:tc:SAML:2.0:cm:bearer'>
4
+ <saml:SubjectConfirmationData InResponseTo='294e5540-c4c6-012d-1a98-0017f2dcb387' NotOnOrAfter='2010-10-28T13:45:36Z' Recipient='http://localhost:3000/auth/authenticate'/></saml:SubjectConfirmation>
5
+ </saml:Subject><saml:Conditions NotBefore='2010-10-28T13:25:36Z' NotOnOrAfter='2010-10-28T13:45:36Z'>
6
+ <saml:AudienceRestriction>
7
+ <saml:Audience>saml-example</saml:Audience>
8
+ </saml:AudienceRestriction>
9
+ </saml:Conditions>
10
+ <saml:AuthnStatement AuthnInstant='2010-10-28T13:35:36Z' SessionIndex='s2eddbcf944c22056cec33d0ea24a54217a164f601'><saml:AuthnContext><saml:AuthnContextClassRef>urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport</saml:AuthnContextClassRef></saml:AuthnContext></saml:AuthnStatement><saml:AttributeStatement><saml:Attribute Name='name'><saml:AttributeValue xsi:type='xs:string' xmlns:xs='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>happy</saml:AttributeValue></saml:Attribute><saml:Attribute Name='uuid'><saml:AttributeValue xsi:type='xs:string' xmlns:xs='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>3c678d50-c357-012d-1a87-0017f2dcb387</saml:AttributeValue></saml:Attribute></saml:AttributeStatement></saml:Assertion>
@@ -0,0 +1,10 @@
1
+ <saml:Assertion xmlns="urn:oasis:names:tc:SAML:2.0:protocol" xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" ID="s272db1ff577ed4463edc408a3d7f3571aebf1696a" IssueInstant="2010-10-28T13:35:36Z" Version="2.0">
2
+ <saml:Issuer>http://dev.example.com:8080/opensso</saml:Issuer><saml:Subject>
3
+ <saml:NameID Format="urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress" NameQualifier="http://dev.example.com:8080/opensso">person@example.com</saml:NameID><saml:SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer">
4
+ <saml:SubjectConfirmationData InResponseTo="294e5540-c4c6-012d-1a98-0017f2dcb387" NotOnOrAfter="2010-10-28T13:45:36Z" Recipient="http://localhost:3000/auth/authenticate"></saml:SubjectConfirmationData></saml:SubjectConfirmation>
5
+ </saml:Subject><saml:Conditions NotBefore="2010-10-28T13:25:36Z" NotOnOrAfter="2010-10-28T13:45:36Z">
6
+ <saml:AudienceRestriction>
7
+ <saml:Audience>saml-example</saml:Audience>
8
+ </saml:AudienceRestriction>
9
+ </saml:Conditions>
10
+ <saml:AuthnStatement AuthnInstant="2010-10-28T13:35:36Z" SessionIndex="s2eddbcf944c22056cec33d0ea24a54217a164f601"><saml:AuthnContext><saml:AuthnContextClassRef>urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport</saml:AuthnContextClassRef></saml:AuthnContext></saml:AuthnStatement><saml:AttributeStatement><saml:Attribute Name="name"><saml:AttributeValue xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:string">happy</saml:AttributeValue></saml:Attribute><saml:Attribute Name="uuid"><saml:AttributeValue xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:string">3c678d50-c357-012d-1a87-0017f2dcb387</saml:AttributeValue></saml:Attribute></saml:AttributeStatement></saml:Assertion>
@@ -91,6 +91,16 @@ class TestXmlCanonicalizer < Test::Unit::TestCase
91
91
  xml_expect = fixture("saml_expected_canonical_form.xml")
92
92
  assert_equal xml_expect, xml_canonicalized
93
93
  end
94
+
95
+ should "canonicalize a saml xml file with default namespace correctly" do
96
+ xml_canonicalizer = XML::Util::XmlCanonicalizer.new(false,true)
97
+
98
+ rexml = rexml_fixture("saml_with_default_namespace.xml")
99
+ xml_canonicalized = xml_canonicalizer.canonicalize(rexml)
100
+
101
+ xml_expect = fixture("saml_with_default_namespace_expected_canonical_form.xml")
102
+ assert_equal xml_expect, xml_canonicalized
103
+ end
94
104
 
95
105
  should "canonicalize a saml file with inclusive namespaces" do
96
106
  xml_canonicalizer = XML::Util::XmlCanonicalizer.new(false,true)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: canonix
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 4
10
- version: 0.1.4
9
+ - 5
10
+ version: 0.1.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Brendon Muir
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-07-12 00:00:00 +12:00
18
+ date: 2011-10-04 00:00:00 +13:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -57,6 +57,8 @@ files:
57
57
  - test/helper.rb
58
58
  - test/saml_assertion.xml
59
59
  - test/saml_expected_canonical_form.xml
60
+ - test/saml_with_default_namespace.xml
61
+ - test/saml_with_default_namespace_expected_canonical_form.xml
60
62
  - test/saml_with_inclusive_ns_assertion.xml
61
63
  - test/saml_with_inclusive_ns_expected_canonical_form.xml
62
64
  - test/test_xmlcanonicalizer.rb