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"); }