scashin133-rsaml 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. data/.autotest +10 -0
  2. data/.gitignore +2 -0
  3. data/LICENSE +0 -0
  4. data/README +13 -0
  5. data/Rakefile +141 -0
  6. data/lib/rsaml/action.rb +57 -0
  7. data/lib/rsaml/action_namespace.rb +63 -0
  8. data/lib/rsaml/advice.rb +34 -0
  9. data/lib/rsaml/assertion.rb +192 -0
  10. data/lib/rsaml/attribute.rb +76 -0
  11. data/lib/rsaml/audience.rb +19 -0
  12. data/lib/rsaml/authentication_context.rb +34 -0
  13. data/lib/rsaml/authn_context/README +1 -0
  14. data/lib/rsaml/authn_context/authentication_context_declaration.rb +42 -0
  15. data/lib/rsaml/authn_context/identification.rb +10 -0
  16. data/lib/rsaml/authn_context/physical_verification.rb +24 -0
  17. data/lib/rsaml/condition.rb +13 -0
  18. data/lib/rsaml/conditions.rb +107 -0
  19. data/lib/rsaml/encrypted.rb +12 -0
  20. data/lib/rsaml/errors.rb +16 -0
  21. data/lib/rsaml/evidence.rb +21 -0
  22. data/lib/rsaml/ext/string.rb +5 -0
  23. data/lib/rsaml/identifier/base.rb +23 -0
  24. data/lib/rsaml/identifier/issuer.rb +28 -0
  25. data/lib/rsaml/identifier/name.rb +55 -0
  26. data/lib/rsaml/identifier.rb +9 -0
  27. data/lib/rsaml/parser.rb +23 -0
  28. data/lib/rsaml/protocol/artifact_resolve.rb +14 -0
  29. data/lib/rsaml/protocol/assertion_id_request.rb +18 -0
  30. data/lib/rsaml/protocol/authn_request.rb +91 -0
  31. data/lib/rsaml/protocol/idp_entry.rb +18 -0
  32. data/lib/rsaml/protocol/idp_list.rb +28 -0
  33. data/lib/rsaml/protocol/message.rb +65 -0
  34. data/lib/rsaml/protocol/name_id_policy.rb +31 -0
  35. data/lib/rsaml/protocol/query/attribute_query.rb +56 -0
  36. data/lib/rsaml/protocol/query/authn_query.rb +30 -0
  37. data/lib/rsaml/protocol/query/authz_decision_query.rb +40 -0
  38. data/lib/rsaml/protocol/query/subject_query.rb +22 -0
  39. data/lib/rsaml/protocol/query.rb +12 -0
  40. data/lib/rsaml/protocol/request.rb +27 -0
  41. data/lib/rsaml/protocol/requested_authn_context.rb +34 -0
  42. data/lib/rsaml/protocol/response.rb +56 -0
  43. data/lib/rsaml/protocol/scoping.rb +33 -0
  44. data/lib/rsaml/protocol/status.rb +38 -0
  45. data/lib/rsaml/protocol/status_code.rb +84 -0
  46. data/lib/rsaml/protocol.rb +21 -0
  47. data/lib/rsaml/proxy_restriction.rb +30 -0
  48. data/lib/rsaml/statement/attribute_statement.rb +27 -0
  49. data/lib/rsaml/statement/authentication_statement.rb +57 -0
  50. data/lib/rsaml/statement/authorization_decision_statement.rb +53 -0
  51. data/lib/rsaml/statement/base.rb +9 -0
  52. data/lib/rsaml/statement.rb +10 -0
  53. data/lib/rsaml/subject.rb +37 -0
  54. data/lib/rsaml/subject_confirmation.rb +34 -0
  55. data/lib/rsaml/subject_confirmation_data.rb +45 -0
  56. data/lib/rsaml/subject_locality.rb +27 -0
  57. data/lib/rsaml/validatable.rb +21 -0
  58. data/lib/rsaml/version.rb +9 -0
  59. data/lib/rsaml.rb +51 -0
  60. data/lib/xml_enc.rb +3 -0
  61. data/lib/xml_sig/canonicalization_method.rb +43 -0
  62. data/lib/xml_sig/key_info.rb +55 -0
  63. data/lib/xml_sig/reference.rb +57 -0
  64. data/lib/xml_sig/signature.rb +29 -0
  65. data/lib/xml_sig/signature_method.rb +20 -0
  66. data/lib/xml_sig/signed_info.rb +27 -0
  67. data/lib/xml_sig/transform.rb +37 -0
  68. data/lib/xml_sig.rb +11 -0
  69. data/scashin133-rsaml.gemspec +180 -0
  70. data/test/action_namespace_test.rb +93 -0
  71. data/test/action_test.rb +51 -0
  72. data/test/advice_test.rb +25 -0
  73. data/test/assertion_test.rb +192 -0
  74. data/test/attribute_test.rb +60 -0
  75. data/test/authentication_context_test.rb +26 -0
  76. data/test/conditions_test.rb +84 -0
  77. data/test/evidence_test.rb +33 -0
  78. data/test/identifier_test.rb +22 -0
  79. data/test/issuer_test.rb +32 -0
  80. data/test/name_test.rb +32 -0
  81. data/test/parser_test.rb +32 -0
  82. data/test/protocol/assertion_id_request_test.rb +19 -0
  83. data/test/protocol/attribute_query_test.rb +30 -0
  84. data/test/protocol/authn_query_test.rb +20 -0
  85. data/test/protocol/authn_request_test.rb +56 -0
  86. data/test/protocol/authz_decision_query_test.rb +31 -0
  87. data/test/protocol/idp_list_test.rb +15 -0
  88. data/test/protocol/request_test.rb +66 -0
  89. data/test/protocol/response_test.rb +68 -0
  90. data/test/protocol/scoping_test.rb +20 -0
  91. data/test/protocol/status_code_test.rb +34 -0
  92. data/test/protocol/status_test.rb +16 -0
  93. data/test/proxy_restriction_test.rb +20 -0
  94. data/test/rsaml_test.rb +12 -0
  95. data/test/sample_data/attribute_query.xml +8 -0
  96. data/test/statement_test.rb +101 -0
  97. data/test/subject_locality_test.rb +27 -0
  98. data/test/subject_test.rb +44 -0
  99. data/test/test_helper.rb +16 -0
  100. data/test/xml_sig/canonicalization_test.rb +19 -0
  101. data/test/xml_sig/iso-8859-1.txt +1 -0
  102. metadata +206 -0
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0"?>
2
+
3
+ <samlp:AttributeQuery>
4
+ <saml:Subject>
5
+ <saml:NameID>Anthony Eden</saml:NameID>
6
+ </saml:Subject>
7
+ <saml:Attribute Name="Name" />
8
+ </samlp:AttributeQuery>
@@ -0,0 +1,101 @@
1
+ require File.dirname(__FILE__) + '/test_helper'
2
+
3
+ class StatementTest < Test::Unit::TestCase
4
+ context "an authentication statement" do
5
+ setup do
6
+ @statement = AuthenticationStatement.new(AuthenticationContext.new())
7
+ end
8
+ should "always have a UTC time for authn_instant" do
9
+ assert_not_nil @statement.authn_instant
10
+ assert @statement.authn_instant.utc?
11
+ end
12
+ should "be valid" do
13
+ assert_nothing_raised do
14
+ @statement.validate
15
+ end
16
+ end
17
+ should "be invalid if authn_instant is not UTC" do
18
+ @statement.authn_instant = Time.now
19
+ assert_raise ValidationError do
20
+ @statement.validate
21
+ end
22
+ end
23
+ context "when producing xml" do
24
+ should "always include authn_instant" do
25
+ assert_match(/<saml:AuthnStatement AuthnInstant="#{date_match}">/, @statement.to_xml)
26
+ end
27
+ should "always include authn_context" do
28
+ assert_match(/<saml:AuthnContext>/, @statement.to_xml)
29
+ end
30
+ should "optionally include a session index" do
31
+ @statement.session_index = '12345'
32
+ assert_match(/SessionIndex="\d+"/, @statement.to_xml)
33
+ end
34
+ should "optionally include a session not on or after date" do
35
+ @statement.session_not_on_or_after = (Time.now + 5.days).utc
36
+ assert_match(/SessionNotOnOrAfter="#{date_match}"/, @statement.to_xml)
37
+ end
38
+ end
39
+ end
40
+ context "an attribute statement" do
41
+ setup do
42
+ @statement = AttributeStatement.new
43
+ @statement.attributes << Attribute.new('email', 'someone@someplace.com')
44
+ end
45
+ should "be valid" do
46
+ assert_nothing_raised { @statement.validate }
47
+ end
48
+ should "not be valid if empty attributes" do
49
+ assert_raise ValidationError do
50
+ @statement.attributes.clear
51
+ @statement.validate
52
+ end
53
+ end
54
+ context "when producing xml" do
55
+ should "include at least on attribute" do
56
+ assert_match(/<saml:AttributeStatement><saml:Attribute Name="email"><saml:AttributeValue>someone@someplace.com<\/saml:AttributeValue><\/saml:Attribute><\/saml:AttributeStatement>/, @statement.to_xml)
57
+ end
58
+ end
59
+ end
60
+
61
+ context "an authorization decision statement" do
62
+ setup do
63
+ @statement = AuthorizationDecisionStatement.new
64
+ @statement.resource = 'file://some/resource'
65
+ @statement.decision = 'Permit'
66
+ @statement.actions << Action.new('Read')
67
+ end
68
+ should "be valid" do
69
+ assert_nothing_raised { @statement.validate }
70
+ end
71
+ should "not be valid if resource is nil" do
72
+ assert_raise ValidationError do
73
+ @statement.resource = nil
74
+ @statement.validate
75
+ end
76
+ end
77
+ should "not be valid if decision is nil" do
78
+ assert_raise ValidationError do
79
+ @statement.decision = nil
80
+ @statement.validate
81
+ end
82
+ end
83
+ should "not be valid if no actions are specified" do
84
+ assert_raise ValidationError do
85
+ @statement.actions.clear
86
+ @statement.validate
87
+ end
88
+ end
89
+ context "when producing xml" do
90
+ should "include the AuthzStatement tag" do
91
+ assert_match(%Q(<saml:AuthzStatement), @statement.to_xml)
92
+ end
93
+ should "include a Resource attribute" do
94
+ assert_match(%Q(Resource="file://some/resource"), @statement.to_xml)
95
+ end
96
+ should "include a Decision attribute" do
97
+ assert_match(%Q(Decision="Permit"), @statement.to_xml)
98
+ end
99
+ end
100
+ end
101
+ end
@@ -0,0 +1,27 @@
1
+ require File.dirname(__FILE__) + '/test_helper'
2
+
3
+ class SubjectLocalityTest < Test::Unit::TestCase
4
+ context "a subject locality" do
5
+ setup do
6
+ @subject_locality = SubjectLocality.new
7
+ end
8
+ context "when validating" do
9
+ should "validate the address" do
10
+ @subject_locality.address = 'x'
11
+ assert_raise ValidationError do
12
+ @subject_locality.validate
13
+ end
14
+ end
15
+ end
16
+ context "when producing xml" do
17
+ should "optionally include an address" do
18
+ @subject_locality.address = '1.2.3.4'
19
+ assert_equal '<saml:SubjectLocality Address="1.2.3.4"/>', @subject_locality.to_xml
20
+ end
21
+ should "optionally include a dns name" do
22
+ @subject_locality.dns_name = 'example.com'
23
+ assert_equal '<saml:SubjectLocality DNSName="example.com"/>', @subject_locality.to_xml
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,44 @@
1
+ require File.dirname(__FILE__) + '/test_helper'
2
+
3
+ class SubjectTest < Test::Unit::TestCase
4
+ context "a subject with an identifier" do
5
+ setup do
6
+ @identifier = Identifier::Name.new('example')
7
+ @subject = Subject.new(@identifier)
8
+ end
9
+ should "have an identifier" do
10
+ assert_equal @identifier, @subject.identifier
11
+ end
12
+ context "when producing xml" do
13
+ should "should include the identifier" do
14
+ assert_equal '<saml:Subject><saml:NameID Format="urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified">example</saml:NameID></saml:Subject>', @subject.to_xml
15
+ end
16
+ end
17
+ end
18
+ context "a subject with subject confirmations" do
19
+ setup do
20
+ @subject = Subject.new
21
+ @subject.subject_confirmations << SubjectConfirmation.new(SubjectConfirmation.methods[:holder_of_key])
22
+ end
23
+
24
+ context "when producing xml" do
25
+ should "optionally include subject confirmations" do
26
+ assert_equal '<saml:Subject><saml:SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:holder-of-key"/></saml:Subject>', @subject.to_xml
27
+ end
28
+ end
29
+ end
30
+
31
+ context "a subject with an identifier and subject confirmations" do
32
+ setup do
33
+ @identifier = Identifier::Name.new('example')
34
+ @subject = Subject.new(@identifier)
35
+ @subject.subject_confirmations << SubjectConfirmation.new(SubjectConfirmation.methods[:holder_of_key])
36
+ end
37
+
38
+ context "when producing xml" do
39
+ should "include the identifier followed by the subject confirmations" do
40
+ assert_equal '<saml:Subject><saml:NameID Format="urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified">example</saml:NameID><saml:SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:holder-of-key"/></saml:Subject>', @subject.to_xml
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,16 @@
1
+ require 'test/unit'
2
+ require 'rubygems'
3
+ require 'shoulda'
4
+
5
+ require File.dirname(__FILE__) + '/../lib/rsaml'
6
+ include RSAML
7
+ include RSAML::Statement
8
+
9
+ class Test::Unit::TestCase
10
+ def date_match
11
+ '\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z'
12
+ end
13
+ def uuid_match
14
+ '[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}'
15
+ end
16
+ end
@@ -0,0 +1,19 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class CanonicalizationTest < Test::Unit::TestCase
4
+ context "a c14n without comments" do
5
+ setup do
6
+ @c14n = XmlSig::XMLC14NWithoutComments.new
7
+ end
8
+ should "convert to UTF-8" do
9
+ assert_equal "Café ñ", @c14n.convert_to_utf8(File.read(File.dirname(__FILE__) + '/iso-8859-1.txt'), 'iso-8859-1')
10
+ end
11
+ should "convert line breaks" do
12
+ assert_equal "line1\nline2\n", @c14n.convert_linebreaks("line1\r\nline2\r")
13
+ assert_equal "\n", @c14n.convert_linebreaks("\n")
14
+ assert_equal "\n", @c14n.convert_linebreaks("\r")
15
+ assert_equal "\n", @c14n.convert_linebreaks("\r\n")
16
+ assert_equal "\n\n", @c14n.convert_linebreaks("\n\n")
17
+ end
18
+ end
19
+ end
@@ -0,0 +1 @@
1
+ Caf� �
metadata ADDED
@@ -0,0 +1,206 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: scashin133-rsaml
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Anthony Eden
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-02-12 00:00:00 -08:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: activesupport
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 2.3.4
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: uuid
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 2.1.1
34
+ version:
35
+ description: "RSAML is a SAML implementation in Ruby. RSAML currently implements the elements defined in the SAML-Core 2.0 \n specification by defining an object model that mimics the structure of SAML. Method names and attributes have been made \n ruby-friendly and documentation is provided for each class and method. In certain cases the SAML specification is \n referenced directly and should be considered the final say whenever a question arises regarding SAML implementation.\n "
36
+ email:
37
+ - anthonyeden@gmail.com
38
+ - scashin133@gmail.com
39
+ executables: []
40
+
41
+ extensions: []
42
+
43
+ extra_rdoc_files:
44
+ - LICENSE
45
+ - README
46
+ files:
47
+ - .autotest
48
+ - .gitignore
49
+ - LICENSE
50
+ - README
51
+ - Rakefile
52
+ - lib/rsaml.rb
53
+ - lib/rsaml/action.rb
54
+ - lib/rsaml/action_namespace.rb
55
+ - lib/rsaml/advice.rb
56
+ - lib/rsaml/assertion.rb
57
+ - lib/rsaml/attribute.rb
58
+ - lib/rsaml/audience.rb
59
+ - lib/rsaml/authentication_context.rb
60
+ - lib/rsaml/authn_context/README
61
+ - lib/rsaml/authn_context/authentication_context_declaration.rb
62
+ - lib/rsaml/authn_context/identification.rb
63
+ - lib/rsaml/authn_context/physical_verification.rb
64
+ - lib/rsaml/condition.rb
65
+ - lib/rsaml/conditions.rb
66
+ - lib/rsaml/encrypted.rb
67
+ - lib/rsaml/errors.rb
68
+ - lib/rsaml/evidence.rb
69
+ - lib/rsaml/ext/string.rb
70
+ - lib/rsaml/identifier.rb
71
+ - lib/rsaml/identifier/base.rb
72
+ - lib/rsaml/identifier/issuer.rb
73
+ - lib/rsaml/identifier/name.rb
74
+ - lib/rsaml/parser.rb
75
+ - lib/rsaml/protocol.rb
76
+ - lib/rsaml/protocol/artifact_resolve.rb
77
+ - lib/rsaml/protocol/assertion_id_request.rb
78
+ - lib/rsaml/protocol/authn_request.rb
79
+ - lib/rsaml/protocol/idp_entry.rb
80
+ - lib/rsaml/protocol/idp_list.rb
81
+ - lib/rsaml/protocol/message.rb
82
+ - lib/rsaml/protocol/name_id_policy.rb
83
+ - lib/rsaml/protocol/query.rb
84
+ - lib/rsaml/protocol/query/attribute_query.rb
85
+ - lib/rsaml/protocol/query/authn_query.rb
86
+ - lib/rsaml/protocol/query/authz_decision_query.rb
87
+ - lib/rsaml/protocol/query/subject_query.rb
88
+ - lib/rsaml/protocol/request.rb
89
+ - lib/rsaml/protocol/requested_authn_context.rb
90
+ - lib/rsaml/protocol/response.rb
91
+ - lib/rsaml/protocol/scoping.rb
92
+ - lib/rsaml/protocol/status.rb
93
+ - lib/rsaml/protocol/status_code.rb
94
+ - lib/rsaml/proxy_restriction.rb
95
+ - lib/rsaml/statement.rb
96
+ - lib/rsaml/statement/attribute_statement.rb
97
+ - lib/rsaml/statement/authentication_statement.rb
98
+ - lib/rsaml/statement/authorization_decision_statement.rb
99
+ - lib/rsaml/statement/base.rb
100
+ - lib/rsaml/subject.rb
101
+ - lib/rsaml/subject_confirmation.rb
102
+ - lib/rsaml/subject_confirmation_data.rb
103
+ - lib/rsaml/subject_locality.rb
104
+ - lib/rsaml/validatable.rb
105
+ - lib/rsaml/version.rb
106
+ - lib/xml_enc.rb
107
+ - lib/xml_sig.rb
108
+ - lib/xml_sig/canonicalization_method.rb
109
+ - lib/xml_sig/key_info.rb
110
+ - lib/xml_sig/reference.rb
111
+ - lib/xml_sig/signature.rb
112
+ - lib/xml_sig/signature_method.rb
113
+ - lib/xml_sig/signed_info.rb
114
+ - lib/xml_sig/transform.rb
115
+ - scashin133-rsaml.gemspec
116
+ - test/action_namespace_test.rb
117
+ - test/action_test.rb
118
+ - test/advice_test.rb
119
+ - test/assertion_test.rb
120
+ - test/attribute_test.rb
121
+ - test/authentication_context_test.rb
122
+ - test/conditions_test.rb
123
+ - test/evidence_test.rb
124
+ - test/identifier_test.rb
125
+ - test/issuer_test.rb
126
+ - test/name_test.rb
127
+ - test/parser_test.rb
128
+ - test/protocol/assertion_id_request_test.rb
129
+ - test/protocol/attribute_query_test.rb
130
+ - test/protocol/authn_query_test.rb
131
+ - test/protocol/authn_request_test.rb
132
+ - test/protocol/authz_decision_query_test.rb
133
+ - test/protocol/idp_list_test.rb
134
+ - test/protocol/request_test.rb
135
+ - test/protocol/response_test.rb
136
+ - test/protocol/scoping_test.rb
137
+ - test/protocol/status_code_test.rb
138
+ - test/protocol/status_test.rb
139
+ - test/proxy_restriction_test.rb
140
+ - test/rsaml_test.rb
141
+ - test/sample_data/attribute_query.xml
142
+ - test/statement_test.rb
143
+ - test/subject_locality_test.rb
144
+ - test/subject_test.rb
145
+ - test/test_helper.rb
146
+ - test/xml_sig/canonicalization_test.rb
147
+ - test/xml_sig/iso-8859-1.txt
148
+ has_rdoc: true
149
+ homepage: http://github.com/scashin133/rsaml
150
+ licenses: []
151
+
152
+ post_install_message:
153
+ rdoc_options:
154
+ - --charset=UTF-8
155
+ require_paths:
156
+ - lib
157
+ required_ruby_version: !ruby/object:Gem::Requirement
158
+ requirements:
159
+ - - ">="
160
+ - !ruby/object:Gem::Version
161
+ version: "0"
162
+ version:
163
+ required_rubygems_version: !ruby/object:Gem::Requirement
164
+ requirements:
165
+ - - ">="
166
+ - !ruby/object:Gem::Version
167
+ version: "0"
168
+ version:
169
+ requirements: []
170
+
171
+ rubyforge_project:
172
+ rubygems_version: 1.3.5
173
+ signing_key:
174
+ specification_version: 3
175
+ summary: Ruby implementation of the SAML 2.0 Specification
176
+ test_files:
177
+ - test/action_namespace_test.rb
178
+ - test/action_test.rb
179
+ - test/advice_test.rb
180
+ - test/assertion_test.rb
181
+ - test/attribute_test.rb
182
+ - test/authentication_context_test.rb
183
+ - test/conditions_test.rb
184
+ - test/evidence_test.rb
185
+ - test/identifier_test.rb
186
+ - test/issuer_test.rb
187
+ - test/name_test.rb
188
+ - test/parser_test.rb
189
+ - test/protocol/assertion_id_request_test.rb
190
+ - test/protocol/attribute_query_test.rb
191
+ - test/protocol/authn_query_test.rb
192
+ - test/protocol/authn_request_test.rb
193
+ - test/protocol/authz_decision_query_test.rb
194
+ - test/protocol/idp_list_test.rb
195
+ - test/protocol/request_test.rb
196
+ - test/protocol/response_test.rb
197
+ - test/protocol/scoping_test.rb
198
+ - test/protocol/status_code_test.rb
199
+ - test/protocol/status_test.rb
200
+ - test/proxy_restriction_test.rb
201
+ - test/rsaml_test.rb
202
+ - test/statement_test.rb
203
+ - test/subject_locality_test.rb
204
+ - test/subject_test.rb
205
+ - test/test_helper.rb
206
+ - test/xml_sig/canonicalization_test.rb