Friday, February 11, 2005

Got TiVo

Got TiVo yesterday. Java API being made available made me buy TiVo. I am already impressed by what I can do with my TiVo.
One problem is that the software on latest TiVo is still 5.3.x and 7.1 is required to use java api. So signed up to priority list and waiting for the upgrade to occur. (Was told this might take several weeks).

Sunday, December 19, 2004

JSSE: How to ignore CertificateException: Couldn't find trusted certificate"?

While testing SecureSocket code, sometimes you would need code to ingore certificate validation.
JSSE provides a simple way to do this by writing your own TrustManager. The below sample code lets you write simple clients ignore certificate validation:

01 
02 
03 import java.io.InputStream;
04 import java.io.OutputStream;
05 
06 import javax.net.ssl.SSLContext;
07 import javax.net.ssl.SSLSocket;
08 import javax.net.ssl.SSLSocketFactory;
09 import javax.net.ssl.TrustManager;
10 import javax.net.ssl.X509TrustManager;
11 
12 /*
13  * This example demostrates how to use a SSLSocket as client to
14  * send and recieve Data while ignoring the certificate validation.
15  */
16 
17 public class SSLClient {
18 
19     public static void main(String[] argsthrows Exception {
20 
21         // Create a trust manager that does not validate certificate chains like the default TrustManager
22         TrustManager[] trustAllCerts = new TrustManager[]{
23             new X509TrustManager() {
24 
25                 public java.security.cert.X509Certificate[] getAcceptedIssuers() {
26                     return null;
27                 }
28 
29                 public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType) {
30                     //No need to implement.
31                 }
32 
33                 public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType) {
34                     //No need to implement.
35                 }
36             }
37         };
38 
39         // Let us create the factory where we can set some parameters for the connection
40         SSLContext sc = SSLContext.getInstance("SSL");
41         sc.init(null, trustAllCerts, new java.security.SecureRandom());
42 
43         SSLSocketFactory factory =sc.getSocketFactory();
44         SSLSocket socket =(SSLSocket)factory.createSocket(args[0], Integer.parseInt(args[1]));
45         socket.startHandshake();
46 
47 
48         OutputStream out = socket.getOutputStream();
49         InputStream in = socket.getInputStream();
50 
51         //Do- Fun stuff with I/O classes.
52     }
53 }

Mustang: 2 new methods in String class.

Two new helper methods are added to String class. The changes are described in bug#6189137.

1. boolean isEmpty() { return length() == 0; }
2. boolean contains(String s) { return indexOf(s) >= 0; }

Thursday, December 16, 2004

BEA: Diablo (weblogic9 Beta) available for download

BEA made Diablo (Weblogic9 Beta) available for download as promised today.
Download it here.
Documentation is here.
What's new in 9.0 is here.

The changes to me looked like this release should have been 8.2 instead of 9. There are lot of little goodies but nothing that really make me want to move to 9 from 8.1. The most exciting change is support for JDK5.0

Tuesday, December 14, 2004

Google: Is this really possible?

Google did amazing JavaScript again with google suggest. I always hated Javascript and have to agree what google is doing is really amazing because its really cool and flaw less work with JavaScript and XMLHTTP.

Here is a link to the compresses javascript used by google (Don't you wonder why so few sites really compress js?).

Thursday, November 18, 2004

Why is Bill Gates so concerned about spam

Microsoft has been talking about Spam for a while. So why is Bill Gates so concerned about Spam? Apparently thats because he world's most spammed man.

Wednesday, November 17, 2004

J2SE 6.0 Snapshot Releases

Sun released a snapshot release of Mustang. You can download binaries and Source bundle too. Detailed list of changes is available (Thanks to Graham Hamilton for quickly providing a change list).

java -version output:
java version "1.6.0-ea"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-ea-b12)
Java HotSpot(TM) Client VM (build 1.6.0-ea-b12, mixed mode, sharing)


This snapshot release mostly contains bug fixes. One of my favourite bug fix in 1.6 is:
4921296:ClassCastException needs more verbose detailMessage

Consider the following code:

1 public class ExceptionTest {
2     public static void main(String args[]) {
3         String s = (Stringnew Object();
4     }
5 }


This used to give a not so useful message till mustang:

Exception in thread "main" java.lang.ClassCastException
at ExceptionTest.main(ExceptionTest.java:3)


Mustang includes both target and object class names in the message:

Exception in thread "main" java.lang.ClassCastException: java.lang.Object cannot be cast to java.lang.String
at ExceptionTest.main(ExceptionTest.java:3)