Warning message with proprietary class

F

francan

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?
 
A

Arne Vajhøj

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;
}
}
 
R

Roedy Green

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:

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top