Module: JavaToBase64::ClassMethods

Defined in:
lib/java_to_base64.rb

Instance Method Summary collapse

Instance Method Details

#from_base64(base64_string) ⇒ Object



39
40
41
42
43
44
45
46
47
# File 'lib/java_to_base64.rb', line 39

def from_base64(base64_string)
  decoded_form = org.apache.commons.codec.binary.Base64.decodeBase64(base64_string) 
  byte_array_input_stream = java.io.ByteArrayInputStream.new(decoded_form)
  # NOTE: JRuby ObjectInputStream https://github.com/ribrdb/jruby/commit/8ab064f4fffc86f89d5ceca1cbf29a6783b83802
  # Overrides the class loader to allow for JRuby objects to be deserialized correctly
  jruby_input_stream = org.jruby.util.JRubyObjectInputStream.new(::JRuby.runtime, byte_array_input_stream)

  return jruby_input_stream.read_object
end