@Test public void restrictedToAdminsTest() throws Exception { config.setRestrictedToAdmins(true); writeLogin(CHARACTER_NAME, CHARACTER_PASSWORD, CLIENT_MAJOR, CLIENT_MINOR, CLIENT_VERSION, "", CHARACTER_RACE, CHARACTER_GENDER, CHARACTER_ARCHETYPE, CHARACTER_HEAD, CHARACTER_MAIL, CHARACTER_HOMELAND); packet.handle(inputBuffer, connection); verify(connection).send(errPacket.capture()); assertEquals(LoginServiceImpl.ONLY_ADMINS_ERROR, errPacket.getValue().getMessage()); }
@Override public boolean handle(DataBuffer buffer, Connection connection) throws ArrayIndexOutOfBoundsException, UnsupportedEncodingException { if (buffer.getReadableBytes() < 12 + security.getPasswordHashLength() + security.getClientHashLength()) { return false; } String nick = buffer.getASCIIString(); String password = buffer.getASCIIStringFixed(security.getPasswordHashLength()); String version = buffer.get() + "." + buffer.get() + "." + buffer.get(); String clientHash = buffer.getASCIIStringFixed(security.getClientHashLength()); byte race = buffer.get(); byte gender = buffer.get(); byte archetype = buffer.get(); int head = buffer.get(); String mail = buffer.getASCIIString(); byte homeland = buffer.get(); try { service.connectNewCharacter((ConnectedUser) connection.getUser(), nick, password, race, gender, archetype, head, mail, homeland, clientHash, version); } catch (LoginErrorException e) { loginError(connection, e.getMessage()); } return true; }
LoginNewCharacterPacket implements IncomingPacket { @Override public boolean handle(DataBuffer buffer, Connection connection) throws ArrayIndexOutOfBoundsException, UnsupportedEncodingException { if (buffer.getReadableBytes() < 12 + security.getPasswordHashLength() + security.getClientHashLength()) { return false; } String nick = buffer.getASCIIString(); String password = buffer.getASCIIStringFixed(security.getPasswordHashLength()); String version = buffer.get() + "." + buffer.get() + "." + buffer.get(); String clientHash = buffer.getASCIIStringFixed(security.getClientHashLength()); byte race = buffer.get(); byte gender = buffer.get(); byte archetype = buffer.get(); int head = buffer.get(); String mail = buffer.getASCIIString(); byte homeland = buffer.get(); try { service.connectNewCharacter((ConnectedUser) connection.getUser(), nick, password, race, gender, archetype, head, mail, homeland, clientHash, version); } catch (LoginErrorException e) { loginError(connection, e.getMessage()); } return true; } }
LoginNewCharacterPacket implements IncomingPacket { @Override public boolean handle(DataBuffer buffer, Connection connection) throws ArrayIndexOutOfBoundsException, UnsupportedEncodingException { if (buffer.getReadableBytes() < 12 + security.getPasswordHashLength() + security.getClientHashLength()) { return false; } String nick = buffer.getASCIIString(); String password = buffer.getASCIIStringFixed(security.getPasswordHashLength()); String version = buffer.get() + "." + buffer.get() + "." + buffer.get(); String clientHash = buffer.getASCIIStringFixed(security.getClientHashLength()); byte race = buffer.get(); byte gender = buffer.get(); byte archetype = buffer.get(); int head = buffer.get(); String mail = buffer.getASCIIString(); byte homeland = buffer.get(); try { service.connectNewCharacter((ConnectedUser) connection.getUser(), nick, password, race, gender, archetype, head, mail, homeland, clientHash, version); } catch (LoginErrorException e) { loginError(connection, e.getMessage()); } return true; }  }
LoginNewCharacterPacket implements IncomingPacket { @Override public boolean handle(DataBuffer buffer, Connection connection) throws ArrayIndexOutOfBoundsException, UnsupportedEncodingException { if (buffer.getReadableBytes() < 12 + security.getPasswordHashLength() + security.getClientHashLength()) { return false; } String nick = buffer.getASCIIString(); String password = buffer.getASCIIStringFixed(security.getPasswordHashLength()); String version = buffer.get() + "." + buffer.get() + "." + buffer.get(); String clientHash = buffer.getASCIIStringFixed(security.getClientHashLength()); byte race = buffer.get(); byte gender = buffer.get(); byte archetype = buffer.get(); int head = buffer.get(); String mail = buffer.getASCIIString(); byte homeland = buffer.get(); try { service.connectNewCharacter((ConnectedUser) connection.getUser(), nick, password, race, gender, archetype, head, mail, homeland, clientHash, version); } catch (LoginErrorException e) { loginError(connection, e.getMessage()); } return true; }  @Override boolean handle(DataBuffer buffer, Connection connection); }
LoginNewCharacterPacket implements IncomingPacket { @Override public boolean handle(DataBuffer buffer, Connection connection) throws ArrayIndexOutOfBoundsException, UnsupportedEncodingException { if (buffer.getReadableBytes() < 12 + security.getPasswordHashLength() + security.getClientHashLength()) { return false; } String nick = buffer.getASCIIString(); String password = buffer.getASCIIStringFixed(security.getPasswordHashLength()); String version = buffer.get() + "." + buffer.get() + "." + buffer.get(); String clientHash = buffer.getASCIIStringFixed(security.getClientHashLength()); byte race = buffer.get(); byte gender = buffer.get(); byte archetype = buffer.get(); int head = buffer.get(); String mail = buffer.getASCIIString(); byte homeland = buffer.get(); try { service.connectNewCharacter((ConnectedUser) connection.getUser(), nick, password, race, gender, archetype, head, mail, homeland, clientHash, version); } catch (LoginErrorException e) { loginError(connection, e.getMessage()); } return true; }  @Override boolean handle(DataBuffer buffer, Connection connection);  }