diff --git a/lib/onelogin/ruby-saml/utils.rb b/lib/onelogin/ruby-saml/utils.rb index ca5ac748..40ad313e 100644 --- a/lib/onelogin/ruby-saml/utils.rb +++ b/lib/onelogin/ruby-saml/utils.rb @@ -32,7 +32,9 @@ class Utils (\d+)W # 8: Weeks ) $)x.freeze - UUID_PREFIX = +'_' + + UUID_PREFIX = '_' + @@prefix = '_'.freeze # Checks if the x509 cert provided is expired. # @@ -252,6 +254,8 @@ def self.verify_signature(params) # @param status_message [Strig] StatusMessage value # @return [String] The status error message def self.status_error_msg(error_msg, raw_status_code = nil, status_message = nil) + error_msg = error_msg.dup + unless raw_status_code.nil? if raw_status_code.include? "|" status_codes = raw_status_code.split(' | ') @@ -262,11 +266,11 @@ def self.status_error_msg(error_msg, raw_status_code = nil, status_message = nil else printable_code = raw_status_code.split(':').last end - error_msg += ', was ' + printable_code + error_msg << ', was ' + printable_code end unless status_message.nil? - error_msg += ' -> ' + status_message + error_msg << ' -> ' + status_message end error_msg @@ -400,11 +404,15 @@ def self.retrieve_plaintext(cipher_text, symmetric_key, algorithm) end def self.set_prefix(value) - UUID_PREFIX.replace value + @@prefix = value + end + + def self.prefix + @@prefix end def self.uuid - "#{UUID_PREFIX}" + (RUBY_VERSION < '1.9' ? "#{@@uuid_generator.generate}" : "#{SecureRandom.uuid}") + "#{prefix}" + (RUBY_VERSION < '1.9' ? "#{@@uuid_generator.generate}" : "#{SecureRandom.uuid}") end # Given two strings, attempt to match them as URIs using Rails' parse method. If they can be parsed,