Java Reference
In-Depth Information
{
System.out.println(protocols[i]);
}
System.out.println(“Waiting for client...”);
SSLSocket socket = (SSLSocket) serverSocket.accept();
System.out.println(“Starting handshake...”);
socket.startHandshake();
System.out.println(“Just connected to “
+ socket.getRemoteSocketAddress());
}catch(IOException e)
{
e.printStackTrace();
}
}
}
I want to make a few comments about the SSLServerDemo program:
The getDefault() method declares that it returns a ServerSocketFactory,
but its actual data type is SSLServerSocketFactory, so I cast it to this type.
■■
Similarly, the createServerSocket() method declares that it returns
a ServerSocket reference. However, because we are using the
SSLServerSocketFactory, the actual return type is SSLServerSocket, so I
had to cast this return value as well.
■■
This program displays the supported cipher suites and protocols for the
environment it is executed in. The output in Figure 17.4 was generated
by using the JSSE implementation of the J2SE 1.4.
■■
I enabled all the cipher suites that are supported on this platform with
the following statement:
serverSocket.setEnabledCipherSuites(suites);
■■
Figure 17.4
Output of the SSLServerDemo program.
Search WWH ::




Custom Search