Skip to content

Commit 3905e83

Browse files
committed
Merge pull request SAML-Toolkits#234 from ylansegal/feature/jruby_support_0.9
Add explicit support for JRuby
2 parents 35fc801 + 7d86fe2 commit 3905e83

File tree

9 files changed

+32
-30
lines changed

9 files changed

+32
-30
lines changed

.travis.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ rvm:
66
- 2.1.5
77
- 2.2.0
88
- ree
9+
- jruby-1.7.21
10+
- jruby-9.0.0.0
911
gemfile:
1012
- Gemfile
1113
- gemfiles/nokogiri-1.5.gemfile
@@ -15,3 +17,7 @@ matrix:
1517
gemfile: Gemfile
1618
- rvm: ree
1719
gemfile: Gemfile
20+
- rvm: jruby-9.0.0.0
21+
gemfile: gemfiles/nokogiri-1.5.gemfile
22+
- rvm: jruby-1.7.21
23+
gemfile: gemfiles/nokogiri-1.5.gemfile

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ We created a demo project for Rails4 that uses the latest version of this librar
3131
* 1.9.x
3232
* 2.1.x
3333
* 2.2.x
34+
* JRuby 1.7.19
35+
* JRuby 9.0.0.0
3436

3537
## Adding Features, Pull Requests
3638
* Fork the repository

Rakefile

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,3 @@ end
2525
task :test
2626

2727
task :default => :test
28-
29-
# require 'rake/rdoctask'
30-
# Rake::RDocTask.new do |rdoc|
31-
# if File.exist?('VERSION')
32-
# version = File.read('VERSION')
33-
# else
34-
# version = ""
35-
# end
36-
37-
# rdoc.rdoc_dir = 'rdoc'
38-
# rdoc.title = "ruby-saml #{version}"
39-
# rdoc.rdoc_files.include('README*')
40-
# rdoc.rdoc_files.include('lib/**/*.rb')
41-
#end

lib/onelogin/ruby-saml/saml_message.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class SamlMessage
2323
# @return [Nokogiri::XML::Schema] Gets the schema object of the SAML 2.0 Protocol schema
2424
#
2525
def self.schema
26-
@schema ||= Mutex.new.synchronize do
26+
Mutex.new.synchronize do
2727
Dir.chdir(File.expand_path("../../../schemas", __FILE__)) do
2828
::Nokogiri::XML::Schema(File.read("saml-schema-protocol-2.0.xsd"))
2929
end

lib/xml_security.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ def extract_inclusive_namespaces
360360
prefix_list = element.attributes.get_attribute("PrefixList").value
361361
prefix_list.split(" ")
362362
else
363-
[]
363+
nil
364364
end
365365
end
366366

ruby-saml.gemspec

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,12 @@ Gem::Specification.new do |s|
3030
# Because runtime dependencies are determined at build time, we cannot make
3131
# Nokogiri's version dependent on the Ruby version, even though we would
3232
# have liked to constrain Ruby 1.8.7 to install only the 1.5.x versions.
33-
s.add_runtime_dependency('nokogiri', '>= 1.5.10')
33+
if defined?(JRUBY_VERSION)
34+
s.add_runtime_dependency('nokogiri', '>= 1.6.0')
35+
s.add_runtime_dependency('jruby-openssl', '>= 0.9.8')
36+
else
37+
s.add_runtime_dependency('nokogiri', '>= 1.5.10')
38+
end
3439

3540
s.add_development_dependency('minitest', '~> 5.5')
3641
s.add_development_dependency('mocha', '~> 0.14')
@@ -40,7 +45,10 @@ Gem::Specification.new do |s|
4045
s.add_development_dependency('systemu', '~> 2')
4146
s.add_development_dependency('timecop', '<= 0.6.0')
4247

43-
if RUBY_VERSION < '1.9'
48+
if defined?(JRUBY_VERSION)
49+
# All recent versions of JRuby play well with pry
50+
s.add_development_dependency('pry')
51+
elsif RUBY_VERSION < '1.9'
4452
# 1.8.7
4553
s.add_development_dependency('ruby-debug', '~> 0.10.4')
4654
elsif RUBY_VERSION < '2.0'

test/response_test.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class RubySamlTest < Minitest::Test
5656

5757
describe "Prevent XEE attack" do
5858
before do
59-
@response = OneLogin::RubySaml::Response.new(fixture(:attackxee))
59+
@response = OneLogin::RubySaml::Response.new(fixture(:attackxee))
6060
end
6161

6262
it "false when evil attack vector is present, soft = true" do
@@ -419,7 +419,7 @@ class RubySamlTest < Minitest::Test
419419
assert response_valid_signed.send(:validate_issuer)
420420

421421
response_valid_signed.settings.idp_entity_id = 'https://app.onelogin.com/saml2'
422-
assert response_valid_signed.send(:validate_issuer)
422+
assert response_valid_signed.send(:validate_issuer)
423423
end
424424

425425
it "return false when the issuer of the Message does not match the IdP entityId" do
@@ -501,7 +501,7 @@ class RubySamlTest < Minitest::Test
501501
response = OneLogin::RubySaml::Response.new(response_document_valid_signed, :settings => settings, :matches_request_id => "_fc4a34b0-7efb-012e-caae-782bcb13bb38")
502502
assert response.send(:validate_in_response_to)
503503
assert_empty response.errors
504-
end
504+
end
505505

506506
it "return true when no Request ID is provided for checking" do
507507
response = OneLogin::RubySaml::Response.new(response_document_valid_signed, :settings => settings)
@@ -898,7 +898,7 @@ class RubySamlTest < Minitest::Test
898898
it 'is not possible when encryptID inside the assertion but no private key' do
899899
response_encrypted_nameid.settings = settings
900900
assert_raises(OneLogin::RubySaml::ValidationError, "An EncryptedID found and no SP private key found on the settings to decrypt it") do
901-
assert_equal "[email protected]", response_encrypted_nameid.nameid
901+
assert_equal "[email protected]", response_encrypted_nameid.nameid
902902
end
903903
end
904904

@@ -1017,7 +1017,7 @@ class RubySamlTest < Minitest::Test
10171017
describe "check right settings" do
10181018

10191019
it "is not possible to decrypt the assertion if no private key" do
1020-
response = OneLogin::RubySaml::Response.new(signed_message_encrypted_unsigned_assertion, :settings => settings)
1020+
response = OneLogin::RubySaml::Response.new(signed_message_encrypted_unsigned_assertion, :settings => settings)
10211021

10221022
encrypted_assertion_node = REXML::XPath.first(
10231023
response.document,
@@ -1033,7 +1033,7 @@ class RubySamlTest < Minitest::Test
10331033
end
10341034

10351035
it "is possible to decrypt the assertion if private key" do
1036-
response = OneLogin::RubySaml::Response.new(signed_message_encrypted_unsigned_assertion, :settings => settings)
1036+
response = OneLogin::RubySaml::Response.new(signed_message_encrypted_unsigned_assertion, :settings => settings)
10371037

10381038
encrypted_assertion_node = REXML::XPath.first(
10391039
response.document,
@@ -1100,9 +1100,9 @@ class RubySamlTest < Minitest::Test
11001100
assert_equal "_ce3d2948b4cf20146dee0a0b3dd6f69b6cf86f62d7", response.nameid
11011101
end
11021102
end
1103-
1103+
11041104
end
1105-
describe "test qualified name id in attributes" do
1105+
describe "test qualified name id in attributes" do
11061106

11071107
it "parsed the nameid" do
11081108
response = OneLogin::RubySaml::Response.new(read_response("signed_nameid_in_atts.xml"), :settings => settings)
@@ -1113,7 +1113,7 @@ class RubySamlTest < Minitest::Test
11131113
end
11141114
end
11151115

1116-
describe "test unqualified name id in attributes" do
1116+
describe "test unqualified name id in attributes" do
11171117

11181118
it "parsed the nameid" do
11191119
response = OneLogin::RubySaml::Response.new(read_response("signed_unqual_nameid_in_atts.xml"), :settings => settings)

test/test_helper.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
require 'bundler'
1111
require 'minitest/autorun'
1212
require 'mocha/setup'
13+
require 'timecop'
1314

1415
Bundler.require :default, :test
1516

test/xml_security_test.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
require File.expand_path(File.join(File.dirname(__FILE__), "test_helper"))
22
require 'xml_security'
3-
require 'timecop'
43

54
class XmlSecurityTest < Minitest::Test
65
include XMLSecurity
@@ -215,14 +214,14 @@ class XmlSecurityTest < Minitest::Test
215214
assert response.is_valid?
216215
end
217216

218-
it "return an empty list when inclusive namespace element is missing" do
217+
it "return nil when inclusive namespace element is missing" do
219218
response = fixture(:no_signature_ns, false)
220219
response.slice! %r{<InclusiveNamespaces xmlns="http://www.w3.org/2001/10/xml-exc-c14n#" PrefixList="#default saml ds xs xsi"/>}
221220

222221
document = XMLSecurity::SignedDocument.new(response)
223222
inclusive_namespaces = document.send(:extract_inclusive_namespaces)
224223

225-
assert inclusive_namespaces.empty?
224+
assert inclusive_namespaces.nil?
226225
end
227226
end
228227

0 commit comments

Comments
 (0)