* @throws GSSException
*/
private static void doHandShake(int localPort) throws IOException,
GSSException {
ServerSocket ss = new ServerSocket(localPort);
GSSManager manager = GSSManager.getInstance();
/*
* Create a GSSContext to receive the incoming request from the client.
* Use null for the server credentials passed in to tell the underlying
* mechanism to use whatever credentials it has available that can be
* used to accept this connection.
*/
GSSCredential serverCreds = manager.createCredential(manager
.createName(SERVICE_NAME, null),
GSSCredential.DEFAULT_LIFETIME, new Oid(
SocksProxyConstants.KERBEROS_V5_OID),
GSSCredential.ACCEPT_ONLY);
while (true) {
logger.debug("Waiting for incoming connection on port {} ...",
localPort);
GSSContext context = manager.createContext(serverCreds);
Socket socket = ss.accept();
try {
DataInputStream inStream = new DataInputStream(socket
.getInputStream());