I have a an object that I d like to grab the contents of in java. The only problem is that is is currently in ruby.
irb(main):050:0> blah
=> "BAh7ByIeYXV0aGVudGljYXRpb25fc3RyYXRlZ2llczAiCXVzZXJpBg%253D%253D-
-0cdecf4edfaa5cbe4693c9fb83b204c1256a54a6"
irb(main):049:0> Marshal.load(Base64.decode64(blah))
=> {"authentication_strategies"=>nil, "user"=>1}
I got the base64 portion allright -- so now everything is in bytes. How would i access that 2nd string? I presume something can be done with jruby but I ve never used it before and would have no clue where to start.
let me elaborate on my problem here.
1) these are cookies that I m trying to share between a servlet on tomcat and a merb app on apache
2) I am not going to be storing them in the database. I have thought about using them in memcached but for other reasons I d like to store them as cookies (yes I m well aware of the security implications involved)
I am currently looking at jruby s Red Bridge/jruby-embed, however since this is only like 70 bytes I need to look at I think it s ridiculous to call up all that overhead for something so simple.
rather than start up a new question.... code I have right now looks like so:
// using commons
Base64 b64 = new Base64();
byte[] decoded = b64.decode(cookie.getValue().getBytes());
ScriptingContainer container = new ScriptingContainer();
container.runScriptlet("la = Marshal.load("" + decoded + ""); puts la.to_s;");
obviously this isn t going to work cause marshal is going to check the first 2 bytes of decoded and freak out since it doesn t match jruby s major/minor version....hrmss..