int negotiateAuthenticationTight() throws Exception { int nAuthTypes = is.readInt(); if (nAuthTypes == 0) return AuthNone; readCapabilityList(authCaps, nAuthTypes); for (int i = 0; i < authCaps.numEnabled(); i++) { int authType = authCaps.getByOrder(i); if (authType == AuthNone || authType == AuthVNC) { writeInt(authType); return authType; } } throw new Exception("No suitable authentication scheme found"); }
void readCapabilityList(CapsContainer caps, int count) throws IOException { int code; byte[] vendor = new byte[4]; byte[] name = new byte[8]; for (int i = 0; i < count; i++) { code = is.readInt(); readFully(vendor); readFully(name); caps.enable(new CapabilityInfo(code, vendor, name)); } }
void initCapabilities() { tunnelCaps = new CapsContainer(); authCaps = new CapsContainer(); serverMsgCaps = new CapsContainer(); clientMsgCaps = new CapsContainer(); encodingCaps = new CapsContainer(); // Supported authentication methods authCaps.add(AuthNone, StandardVendor, SigAuthNone, "No authentication"); authCaps.add(AuthVNC, StandardVendor, SigAuthVNC, "Standard VNC password authentication"); // Supported encoding types encodingCaps.add( EncodingCopyRect, StandardVendor, SigEncodingCopyRect, "Standard CopyRect encoding"); encodingCaps.add(EncodingRRE, StandardVendor, SigEncodingRRE, "Standard RRE encoding"); encodingCaps.add(EncodingCoRRE, StandardVendor, SigEncodingCoRRE, "Standard CoRRE encoding"); encodingCaps.add( EncodingHextile, StandardVendor, SigEncodingHextile, "Standard Hextile encoding"); encodingCaps.add(EncodingZRLE, StandardVendor, SigEncodingZRLE, "Standard ZRLE encoding"); encodingCaps.add(EncodingZlib, TridiaVncVendor, SigEncodingZlib, "Zlib encoding"); encodingCaps.add(EncodingTight, TightVncVendor, SigEncodingTight, "Tight encoding"); // Supported pseudo-encoding types encodingCaps.add( EncodingCompressLevel0, TightVncVendor, SigEncodingCompressLevel0, "Compression level"); encodingCaps.add( EncodingQualityLevel0, TightVncVendor, SigEncodingQualityLevel0, "JPEG quality level"); encodingCaps.add( EncodingXCursor, TightVncVendor, SigEncodingXCursor, "X-style cursor shape update"); encodingCaps.add( EncodingRichCursor, TightVncVendor, SigEncodingRichCursor, "Rich-color cursor shape update"); encodingCaps.add( EncodingPointerPos, TightVncVendor, SigEncodingPointerPos, "Pointer position update"); encodingCaps.add( EncodingLastRect, TightVncVendor, SigEncodingLastRect, "LastRect protocol extension"); encodingCaps.add( EncodingNewFBSize, TightVncVendor, SigEncodingNewFBSize, "Framebuffer size change"); }