@Test public void testHandleOutOfDateClient() throws Exception { LoginServiceImpl service = (LoginServiceImpl) ApplicationContext.getInstance(LoginService.class); service.setCurrentClientVersion(CLIENT_MAJOR + "." + CLIENT_MINOR + "." + CLIENT_REVISION); writeLogin(CHARACTER_NAME, CHARACTER_PASSWORD, (byte) 0, (byte) 0, (byte) 0, ""); packet.handle(inputBuffer, connection); verify(connection).send(errPacket.capture()); assertEquals(String.format(LoginServiceImpl.CLIENT_OUT_OF_DATE_ERROR_FORMAT, CLIENT_MAJOR + "." + CLIENT_MINOR + "." + CLIENT_REVISION), errPacket.getValue().getMessage()); }
@Override public boolean handle(DataBuffer buffer, Connection connection) throws IndexOutOfBoundsException, UnsupportedEncodingException { if (buffer.getReadableBytes() < 5 + security.getPasswordHashLength() + security.getClientHashLength()) { return false; } String username = buffer.getASCIIString(); String password = buffer.getASCIIStringFixed(security.getPasswordHashLength()); String version = buffer.get() + "." + buffer.get() + "." + buffer.get(); String clientHash = buffer.getASCIIStringFixed(security.getClientHashLength()); try { loginService.connectExistingCharacter((ConnectedUser) connection.getUser(), username, password, version, clientHash); } catch (LoginErrorException e) { loginError(connection, e.getMessage()); } return true; }
LoginExistingCharacterPacket implements IncomingPacket { @Override public boolean handle(DataBuffer buffer, Connection connection) throws IndexOutOfBoundsException, UnsupportedEncodingException { if (buffer.getReadableBytes() < 5 + security.getPasswordHashLength() + security.getClientHashLength()) { return false; } String username = buffer.getASCIIString(); String password = buffer.getASCIIStringFixed(security.getPasswordHashLength()); String version = buffer.get() + "." + buffer.get() + "." + buffer.get(); String clientHash = buffer.getASCIIStringFixed(security.getClientHashLength()); try { loginService.connectExistingCharacter((ConnectedUser) connection.getUser(), username, password, version, clientHash); } catch (LoginErrorException e) { loginError(connection, e.getMessage()); } return true; } }
LoginExistingCharacterPacket implements IncomingPacket { @Override public boolean handle(DataBuffer buffer, Connection connection) throws IndexOutOfBoundsException, UnsupportedEncodingException { if (buffer.getReadableBytes() < 5 + security.getPasswordHashLength() + security.getClientHashLength()) { return false; } String username = buffer.getASCIIString(); String password = buffer.getASCIIStringFixed(security.getPasswordHashLength()); String version = buffer.get() + "." + buffer.get() + "." + buffer.get(); String clientHash = buffer.getASCIIStringFixed(security.getClientHashLength()); try { loginService.connectExistingCharacter((ConnectedUser) connection.getUser(), username, password, version, clientHash); } catch (LoginErrorException e) { loginError(connection, e.getMessage()); } return true; }  }
LoginExistingCharacterPacket implements IncomingPacket { @Override public boolean handle(DataBuffer buffer, Connection connection) throws IndexOutOfBoundsException, UnsupportedEncodingException { if (buffer.getReadableBytes() < 5 + security.getPasswordHashLength() + security.getClientHashLength()) { return false; } String username = buffer.getASCIIString(); String password = buffer.getASCIIStringFixed(security.getPasswordHashLength()); String version = buffer.get() + "." + buffer.get() + "." + buffer.get(); String clientHash = buffer.getASCIIStringFixed(security.getClientHashLength()); try { loginService.connectExistingCharacter((ConnectedUser) connection.getUser(), username, password, version, clientHash); } catch (LoginErrorException e) { loginError(connection, e.getMessage()); } return true; }  @Override boolean handle(DataBuffer buffer, Connection connection); }
LoginExistingCharacterPacket implements IncomingPacket { @Override public boolean handle(DataBuffer buffer, Connection connection) throws IndexOutOfBoundsException, UnsupportedEncodingException { if (buffer.getReadableBytes() < 5 + security.getPasswordHashLength() + security.getClientHashLength()) { return false; } String username = buffer.getASCIIString(); String password = buffer.getASCIIStringFixed(security.getPasswordHashLength()); String version = buffer.get() + "." + buffer.get() + "." + buffer.get(); String clientHash = buffer.getASCIIStringFixed(security.getClientHashLength()); try { loginService.connectExistingCharacter((ConnectedUser) connection.getUser(), username, password, version, clientHash); } catch (LoginErrorException e) { loginError(connection, e.getMessage()); } return true; }  @Override boolean handle(DataBuffer buffer, Connection connection);  }