public static final void login(String username, MapleClient c, String pwd) {
    String login = username;
    int loginok = 0;
    boolean isBanned = c.hasBannedIP() || c.hasBannedMac() || c.hasProxyBan();
    loginok = c.login(login, pwd, isBanned);
    Calendar tempbannedTill = c.getTempBanCalendar();

    if ((loginok == 0) && (isBanned)) {
      loginok = 3;
    }
    if (loginok != 0) {
      if (!loginFailCount(c)) {
        c.clearInformation();
        c.getSession().write(LoginPacket.getLoginFailed(loginok));
      } else {
        c.getSession().close(true);
      }
    } else if (tempbannedTill.getTimeInMillis() != 0L) {
      if (!loginFailCount(c)) {
        c.clearInformation();
        c.getSession()
            .write(
                LoginPacket.getTempBan(
                    PacketHelper.getTime(tempbannedTill.getTimeInMillis()), c.getBanReason()));
      } else {
        c.getSession().close(true);
      }
    } else {
      c.loginAttempt = 0;
      LoginWorker.registerClient(c);
    }
  }
Example #2
0
  public static final void login(final LittleEndianAccessor slea, final MapleClient c) {
    String login = c.isLocalhost() ? "admin" : slea.readMapleAsciiString();
    String pwd = c.isLocalhost() ? "admin" : slea.readMapleAsciiString();

    int loginok = 0;
    final boolean ipBan = c.hasBannedIP();
    final boolean macBan = c.hasBannedMac();

    if (AutoRegister.getAccountExists(login) != false) {
      loginok = c.login(login, pwd, ipBan || macBan);
    } else if (AutoRegister.autoRegister != false && (!c.hasBannedIP() || !c.hasBannedMac())) {
      AutoRegister.createAccount(login, pwd, c.getSession().getRemoteAddress().toString());
      if (AutoRegister.success != false) {
        loginok = c.login(login, pwd, ipBan || macBan);
      }
    }
    final Calendar tempbannedTill = c.getTempBanCalendar();

    if (loginok == 0 && (ipBan || macBan) && !c.isGm()) {
      loginok = 3;
      if (macBan) {
        // this is only an ipban o.O" - maybe we should refactor this a bit so it's more readable
        MapleCharacter.ban(
            c.getSession().getRemoteAddress().toString().split(":")[0],
            "Enforcing account ban, account " + login,
            false,
            4,
            false);
      }
    }
    if (loginok != 0) {
      if (!loginFailCount(c)) {
        c.clearInformation();
        c.getSession().write(LoginPacket.getLoginFailed(loginok));
      } else {
        c.getSession().close();
      }
    } else if (tempbannedTill.getTimeInMillis() != 0) {
      if (!loginFailCount(c)) {
        c.clearInformation();
        c.getSession()
            .write(
                LoginPacket.getTempBan(
                    PacketHelper.getTime(tempbannedTill.getTimeInMillis()), c.getBanReason()));
      } else {
        c.getSession().close();
      }
    } else {
      c.loginAttempt = 0;
      LoginWorker.registerClient(c);
    }
  }