From: francan on
In my Tomcat 6.0.20 container I am using sun.misc.BASE64Encoder to get
NTLM Intranet username and everything works. Unfortunately I get the
below warning message after I compile the class:
-----------------------
Auth.java:3: warning: sun.misc.BASE64Encoder is Sun proprietary API
and
may be removed in a future release import sun.misc.BASE64Encoder;
^
1 warning
----------------------------

It seems the sun.misc.BASE64Encoder is Sun proprietary API and is
available from the rt.jar? I was wondering if I should put the rt.jar
in my web app lib folder (\WEB-INF\lib) just in case it is removed
from the jvm in the future?
From: Arne Vajhøj on
On 03-03-2010 20:55, francan wrote:
> In my Tomcat 6.0.20 container I am using sun.misc.BASE64Encoder to get
> NTLM Intranet username and everything works. Unfortunately I get the
> below warning message after I compile the class:
> -----------------------
> Auth.java:3: warning: sun.misc.BASE64Encoder is Sun proprietary API
> and
> may be removed in a future release import sun.misc.BASE64Encoder;
> ^
> 1 warning
> ----------------------------
>
> It seems the sun.misc.BASE64Encoder is Sun proprietary API and is
> available from the rt.jar? I was wondering if I should put the rt.jar
> in my web app lib folder (\WEB-INF\lib) just in case it is removed
> from the jvm in the future?

No.

You should be using the supported Base64 API.

The one in javax.mail.

See some code below for example of usage.

Arne

==============

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import javax.mail.MessagingException;
import javax.mail.internet.MimeUtility;

public class B64 {
public static String b64encode(byte[] b) throws MessagingException,
IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream b64os = MimeUtility.encode(baos, "base64");
b64os.write(b);
b64os.close();
return new String(baos.toByteArray());
}
public static byte[] b64decode(String s) throws
MessagingException, IOException {
ByteArrayInputStream bais = new ByteArrayInputStream(s.getBytes());
InputStream b64is = MimeUtility.decode(bais, "Base64");
byte[] tmp = new byte[s.length()];
int n = b64is.read(tmp);
byte[] res = new byte[n];
System.arraycopy(tmp, 0, res, 0, n);
return res;
}
}

From: Roedy Green on
On Wed, 3 Mar 2010 17:55:45 -0800 (PST), francan <francan00(a)yahoo.com>
wrote, quoted or indirectly quoted someone who said :

>In my Tomcat 6.0.20 container I am using sun.misc.BASE64Encoder to get
>NTLM Intranet username and everything works. Unfortunately I get the
>below warning message after I compile the class:
>-----------------------
>Auth.java:3: warning: sun.misc.BASE64Encoder is Sun proprietary API
>and
> may be removed in a future release import sun.misc.BASE64Encoder;

It is designed for Sun's exclusive use. They are warning you the code
could change or disappear.

For code without that problem, see
http://mindprod.com/jgloss/base64.html
--
Roedy Green Canadian Mind Products
http://mindprod.com

The major difference between a thing that might go wrong and a thing that cannot possibly go wrong is that when a thing that cannot possibly go wrong goes wrong it usually turns out to be impossible to get at or repair.
~ Douglas Adams (born: 1952-03-11 died: 2001-05-11 at age: 49)