Skip to content

Commit d1d99d0

Browse files
committed
Add backwards compatibility to ruby 1.8.7 for uuid generate
1 parent f130b9f commit d1d99d0

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

lib/onelogin/ruby-saml/utils.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
1+
if RUBY_VERSION < '1.9'
2+
require 'uuid'
3+
else
4+
require 'securerandom'
5+
end
6+
17
module OneLogin
28
module RubySaml
39

410
# SAML2 Auxiliary class
511
#
612
class Utils
13+
@@uuid_generator = UUID.new if RUBY_VERSION < '1.9'
714

815
DSIG = "http://www.w3.org/2000/09/xmldsig#"
916
XENC = "http://www.w3.org/2001/04/xmlenc#"
@@ -168,7 +175,7 @@ def self.retrieve_plaintext(cipher_text, symmetric_key, algorithm)
168175
end
169176

170177
def self.uuid
171-
"_#{SecureRandom.uuid}"
178+
RUBY_VERSION < '1.9' ? "_#{@@uuid_generator.generate}" : "_#{SecureRandom.uuid}"
172179
end
173180
end
174181
end

ruby-saml.gemspec

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,17 @@ Gem::Specification.new do |s|
2525
s.summary = %q{SAML Ruby Tookit}
2626
s.test_files = `git ls-files test/*`.split("\n")
2727

28+
29+
2830
# Because runtime dependencies are determined at build time, we cannot make
2931
# Nokogiri's version dependent on the Ruby version, even though we would
3032
# have liked to constrain Ruby 1.8.7 to install only the 1.5.x versions.
3133
if defined?(JRUBY_VERSION)
3234
s.add_runtime_dependency('nokogiri', '>= 1.6.0')
3335
s.add_runtime_dependency('jruby-openssl', '>= 0.9.8')
36+
elsif RUBY_VERSION < '1.9'
37+
s.add_runtime_dependency('uuid')
38+
s.add_runtime_dependency('nokogiri', '<= 1.5.11')
3439
else
3540
s.add_runtime_dependency('nokogiri', '>= 1.5.10')
3641
end

0 commit comments

Comments
 (0)