0

Trying to port some applications from WebLogic to Tomcat (or maybe JBoss). Some of this code has the following import statements:

import weblogic.utils.encoders.BASE64Decoder;
import weblogic.utils.encoders.BASE64Encoder;

which are then instantiated by

private static BASE64Encoder base64Encoder = new BASE64Encoder();
private static BASE64Decoder base64Decoder = new BASE64Decoder();

Is there an alternative implementation that is available without depending on weblogic code? Ideally one that would change nothing but the import statements?

Thanks.

Update: also needs to be compilable under JDK1.5

Steve Cohen
  • 4,679
  • 9
  • 51
  • 89

1 Answers1

0

Yes, there's java.util.Base64.

There are various factory methods to obtain encoders configured in slightly different ways for encoding characters and line breaks.

erickson
  • 265,237
  • 58
  • 395
  • 493
  • Sorry, didn't mention it needs to work under JDK 1.5 (now updated). java.util.Base64 is new in JDK 1.8, and, in any event is not a drop-in replacement that would enable changing only the import statement. I.e. it has no classes called BASE64Decoder and BASE64Encoder or any classes with the same method signatures as the weblogic classes. Again trying to avoid rewriting a bunch of code. – Steve Cohen Jan 28 '16 at 17:02
  • @SteveCohen In that case, you might use an [Apache Commons library.](https://commons.apache.org/proper/commons-codec/archives/1.7/apidocs/index.html) Like WebLogic's encoders, their precise behavior is poorly specified, and I've answered a lot of questions that revolved around their handling of whitespace. But I would not be surprised if WebLogic took this code and used it after repackaging, so you might find one of them a drop-in replacement. Because your JRE is so ancient, you'll need [version 1.6.](https://commons.apache.org/proper/commons-codec/) Version 1.5 died over 6 years ago, right? – erickson Jan 28 '16 at 17:12
  • Thanks, I am not sure what JRE this will eventually be allowed to run under. Could even be 1.8. But in any case, best thing would probably be to write a wrapper that would be a drop-in replacement for weblogic's, with the same method signatures. – Steve Cohen Jan 28 '16 at 17:23