I am trying to learn more about client/server java programming and
design patterns and decided to attempt to write a VNCClient to gain this
knowledge. I have a number of classes that I am planning on using to
establish the connection, but have been unable to get the
VNCAuthentication to work and was wondering if someone could tell me
where I am going wrong.
When the application is started it has a single class that creates a
socket connection to the server and then gets a DataInputStream and
outputStream. Itthen successfully reads the server protocol and sends
the client version "RFB 003.003\n" back as a response. At this point the
control is passed to a securityController that reads the security type
and calls the process method on each SecurityHandler in a List. The
following is the only SecurityHandler I have at this time. It is for the
VNC Authentication and is pretty much copied from the Java VNC Client,
but it still fails and I was wondering if someone can see why? (The
SecurityHandler Interface defines the NOT_HANDLED int value as -1)
package vncClient.security;
import java.io.IOException;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.log4j.Logger;
import vncClient.DesCipher;
import vncClient.VNCClientConnector;
public class SecurityVNCAuthentication implements SecurityHandler {
private Logger logger = Logger.getLogger(this.getClass());
public static final int SECURITY_TYPE = 2;
public static final String SECURITY_TYPE_NAME = "VNC Authentication";
public int process(VNCClientConnector aConnector, int aSecurityType)
throws IOException {
int lResult = NOT_HANDLED;
if (SECURITY_TYPE == aSecurityType) {
String lPassword = aConnector.getHostConfiguration().getPassword();
byte[] lChallenge = new byte[16];
aConnector.getInputStream().readFully(lChallenge);
if (lPassword.length() > 8) {
lPassword = lPassword.substring(0, 8);
}
// vncEncryptBytes in the UNIX libvncauth truncates password
// after the first zero byte. We do to.
int firstZero = lPassword.indexOf(0);
if (firstZero != -1)
lPassword = lPassword.substring(0, firstZero);
byte[] key = {0, 0, 0, 0, 0, 0, 0, 0};
System.arraycopy(lPassword.getBytes(), 0, key, 0,
lPassword.length());
DesCipher des = new DesCipher(key);
des.encrypt(lChallenge, 0, lChallenge, 0);
des.encrypt(lChallenge, 8, lChallenge, 8);
aConnector.getOutputStream().write(lChallenge);
lResult = aConnector.getInputStream().readInt();
System.err.println("RESULT = " + lResult);
}
return lResult;
}
public int getSecurityType() {
return SECURITY_TYPE;
}
public String getSecurityTypeName() {
return SECURITY_TYPE_NAME;
}
}
Also, Does anyone know if the DES Library can be
replaced with the JCE implementation. I have been
unsuccessful in finding a method that will produce the
same output as the Library provided with the Java
Viewer.
Thanks,
Chad
Delete Reply Forward
_______________________________________________
VNC-List mailing list
[email protected]
To remove yourself from the list visit:
http://www.realvnc.com/mailman/listinfo/vnc-list