Thread: 614 Passwords..?

Results 1 to 3 of 3
  1. #1 614 Passwords..? 
    Banned

    Join Date
    Mar 2008
    Posts
    2,595
    Thanks given
    128
    Thanks received
    191
    Rep Power
    0
    Fixed.
     

  2. #2  
    Registered Member

    Join Date
    Oct 2012
    Posts
    1,461
    Thanks given
    560
    Thanks received
    323
    Rep Power
    122
    Remove forum integration, save the account file into a folder in the server. Upon login, load the password and check if it matches the password from the account file. If it doesn't, don't allow a login, otherwise allow the login.

    Example of how I get the login result for a player attempting a login. This is just the way I have done it in the past, works without any problems & bugs. You may wish to use any other parsing you like. I used json in this case.

    Code:
    	@Override
    	public LoginResult getLoginResult(PlayerDetails playerDetails) {
    		/**
    		 * The return code, default set to a successful login.
    		 */
    		int returnCode = LoginConstants.LOGIN_SUCCESS.getReturnCode();
    		/**
    		 * The registeree currently, is nobody.
    		 */
    		Player registeree = null;
    		/**
    		 * Check if the player actually exists.
    		 * If it does, read their account password from their file.
    		 * If its equal to their entered password, allow them to login.
    		 * Otherwise return the code for the invalid username or password.
    		 * Also check for any punishments which needs to prevent login such as ban.
    		 */
    		if (exists(playerDetails.getLoginName())) {
    			JsonObject obj = null;
    			Gson builder = new GsonBuilder().setPrettyPrinting().create();
    			try {
    				obj = new JsonParser().parse(new FileReader(
    						new File(SAVE_PATH, playerDetails.getLoginName() + EXTENSION))).getAsJsonObject();
    			} catch (JsonIOException | JsonSyntaxException | FileNotFoundException e) {
    				e.printStackTrace();
    				returnCode = LoginConstants.ERROR_LOADING_PROFILE.getReturnCode();
    			}
    			/**
    			 * Check if the account has a punishment on it.
    			 * These punishments are the ones which affect login.
    			 */
    			Punishment punishment = builder.fromJson(obj.get("punishment"), Punishment.class) == null ? Punishment.NONE : 
    				builder.fromJson(obj.get("punishment"), Punishment.class);
    			switch(punishment) {
    			case BAN:
    				returnCode = LoginConstants.ACCOUNT_BANNED.getReturnCode();
    				break;
    			case IP_BAN:
    				returnCode = LoginConstants.COMPUTER_ADDRESS_BLOCKED.getReturnCode();
    				break;
    			case LOCK:
    				returnCode = LoginConstants.ACCOUNT_LOCKED.getReturnCode();
    				break;
    			case PERMANENT_BAN:
    				returnCode = LoginConstants.ACCOUNT_BANNED.getReturnCode();
    				break;
    			case NONE:
    				returnCode = LoginConstants.LOGIN_SUCCESS.getReturnCode();
    				break;
    			default:
    				returnCode = LoginConstants.LOGIN_SUCCESS.getReturnCode();
    				break;
    			}
    			/**
    			 * Check if the account is already logged on.
    			 */
    			if (Game.getWorld().getPlayerInGame(playerDetails.getLoginName(), true) != null) 
    				returnCode = LoginConstants.ALREADY_ONLINE.getReturnCode();
    			/**
    			 * Read the player's actual password from their account file.
    			 */
    			String password = obj.get("password").getAsString();
    			/**
    			 * Compare the actual password to the password entered.
    			 * If it isn't correct, notify.
    			 */
    			if (!playerDetails.getPassword().equalsIgnoreCase(password)) {
    				returnCode = LoginConstants.INVALID_USERNAME_OR_PASSWORD.getReturnCode();
    			}
    		}
    		/**
    		 * If the player doesn't exist, create the new player.
    		 */
    		if (returnCode == LoginConstants.CONNECTION_ID.getReturnCode() || returnCode == LoginConstants.LOGIN_SUCCESS.getReturnCode()) {
    			registeree = new Player(playerDetails);
    			registeree.setCreatedDate(registeree.getCreationDate());
    		}
    		return new LoginResult(registeree, returnCode);
    	}
    In the login decoder, you could have something like this (please note this is not entirely done, I have removed most of the code since I won't spoon feed you it) :

    Code:
    	/**
    	 * Loads the player by the details they've entered.
    	 * @param details
    	 * @param loggingIntoLobby
    	 */
    	public void loadPlayer(final PlayerDetails details, final boolean loggingIntoLobby) {
    		/**
    		 * Check the login result.
    		 */
    		LoginResult loginResult = persistence.getLoginResult(details);
    		Player player = loginResult.getPlayer();
    		PacketBuilder bldr = new PacketBuilder();
    		bldr.writeByte(loginResult.getReturnCode());
    		/**
    		 * Write the login result return code.
    		 */
    		details.getChannel().write(bldr.buildPacket());
    		/**
    		 * If it is a successful login.
    		 */
    		if (loginResult.getReturnCode() == LoginConstants.LOGIN_SUCCESS.getReturnCode()) {
    			/**
    			 * Set if the player is in lobby or not.
    			 */
    			player.setIsInLobby(loggingIntoLobby);
    			/**
    			 * Register the player into the required network.
    			 * Whether it is the lobby or directly into the game.
    			 */
    			if (loggingIntoLobby) {
    				//Do this part yourself.
    			} else {
    				//Do this part yourself.
    			}
    		}
    	}

    “I have not failed. I've just found 10,000 ways that won't work.”
    ― Thomas A. Edison


    Attached image


     

  3. #3  
    Banned

    Join Date
    Mar 2008
    Posts
    2,595
    Thanks given
    128
    Thanks received
    191
    Rep Power
    0
    Quote Originally Posted by Magnito View Post
    Remove forum integration, save the account file into a folder in the server. Upon login, load the password and check if it matches the password from the account file. If it doesn't, don't allow a login, otherwise allow the login.

    Example of how I get the login result for a player attempting a login. This is just the way I have done it in the past, works without any problems & bugs. You may wish to use any other parsing you like. I used json in this case.

    Code:
    	@Override
    	public LoginResult getLoginResult(PlayerDetails playerDetails) {
    		/**
    		 * The return code, default set to a successful login.
    		 */
    		int returnCode = LoginConstants.LOGIN_SUCCESS.getReturnCode();
    		/**
    		 * The registeree currently, is nobody.
    		 */
    		Player registeree = null;
    		/**
    		 * Check if the player actually exists.
    		 * If it does, read their account password from their file.
    		 * If its equal to their entered password, allow them to login.
    		 * Otherwise return the code for the invalid username or password.
    		 * Also check for any punishments which needs to prevent login such as ban.
    		 */
    		if (exists(playerDetails.getLoginName())) {
    			JsonObject obj = null;
    			Gson builder = new GsonBuilder().setPrettyPrinting().create();
    			try {
    				obj = new JsonParser().parse(new FileReader(
    						new File(SAVE_PATH, playerDetails.getLoginName() + EXTENSION))).getAsJsonObject();
    			} catch (JsonIOException | JsonSyntaxException | FileNotFoundException e) {
    				e.printStackTrace();
    				returnCode = LoginConstants.ERROR_LOADING_PROFILE.getReturnCode();
    			}
    			/**
    			 * Check if the account has a punishment on it.
    			 * These punishments are the ones which affect login.
    			 */
    			Punishment punishment = builder.fromJson(obj.get("punishment"), Punishment.class) == null ? Punishment.NONE : 
    				builder.fromJson(obj.get("punishment"), Punishment.class);
    			switch(punishment) {
    			case BAN:
    				returnCode = LoginConstants.ACCOUNT_BANNED.getReturnCode();
    				break;
    			case IP_BAN:
    				returnCode = LoginConstants.COMPUTER_ADDRESS_BLOCKED.getReturnCode();
    				break;
    			case LOCK:
    				returnCode = LoginConstants.ACCOUNT_LOCKED.getReturnCode();
    				break;
    			case PERMANENT_BAN:
    				returnCode = LoginConstants.ACCOUNT_BANNED.getReturnCode();
    				break;
    			case NONE:
    				returnCode = LoginConstants.LOGIN_SUCCESS.getReturnCode();
    				break;
    			default:
    				returnCode = LoginConstants.LOGIN_SUCCESS.getReturnCode();
    				break;
    			}
    			/**
    			 * Check if the account is already logged on.
    			 */
    			if (Game.getWorld().getPlayerInGame(playerDetails.getLoginName(), true) != null) 
    				returnCode = LoginConstants.ALREADY_ONLINE.getReturnCode();
    			/**
    			 * Read the player's actual password from their account file.
    			 */
    			String password = obj.get("password").getAsString();
    			/**
    			 * Compare the actual password to the password entered.
    			 * If it isn't correct, notify.
    			 */
    			if (!playerDetails.getPassword().equalsIgnoreCase(password)) {
    				returnCode = LoginConstants.INVALID_USERNAME_OR_PASSWORD.getReturnCode();
    			}
    		}
    		/**
    		 * If the player doesn't exist, create the new player.
    		 */
    		if (returnCode == LoginConstants.CONNECTION_ID.getReturnCode() || returnCode == LoginConstants.LOGIN_SUCCESS.getReturnCode()) {
    			registeree = new Player(playerDetails);
    			registeree.setCreatedDate(registeree.getCreationDate());
    		}
    		return new LoginResult(registeree, returnCode);
    	}
    In the login decoder, you could have something like this (please note this is not entirely done, I have removed most of the code since I won't spoon feed you it) :

    Code:
    	/**
    	 * Loads the player by the details they've entered.
    	 * @param details
    	 * @param loggingIntoLobby
    	 */
    	public void loadPlayer(final PlayerDetails details, final boolean loggingIntoLobby) {
    		/**
    		 * Check the login result.
    		 */
    		LoginResult loginResult = persistence.getLoginResult(details);
    		Player player = loginResult.getPlayer();
    		PacketBuilder bldr = new PacketBuilder();
    		bldr.writeByte(loginResult.getReturnCode());
    		/**
    		 * Write the login result return code.
    		 */
    		details.getChannel().write(bldr.buildPacket());
    		/**
    		 * If it is a successful login.
    		 */
    		if (loginResult.getReturnCode() == LoginConstants.LOGIN_SUCCESS.getReturnCode()) {
    			/**
    			 * Set if the player is in lobby or not.
    			 */
    			player.setIsInLobby(loggingIntoLobby);
    			/**
    			 * Register the player into the required network.
    			 * Whether it is the lobby or directly into the game.
    			 */
    			if (loggingIntoLobby) {
    				//Do this part yourself.
    			} else {
    				//Do this part yourself.
    			}
    		}
    	}
    Very neat code, I appreciate it, I'm going to attempt to follow your code myself to see if I can fix my issue.
    Thank you tho.
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. Replies: 39
    Last Post: 07-13-2016, 09:58 PM
  2. [614] Adding Fully working Korasi! [614]
    By Jesse 1422 in forum Snippets
    Replies: 3
    Last Post: 10-28-2015, 06:52 PM
  3. Legacy 614, SRS. Password DUMP?
    By DamoRSPS in forum Humor
    Replies: 0
    Last Post: 07-29-2014, 09:49 AM
  4. [614 Dementhium] Master password
    By Sonicforce41 in forum Snippets
    Replies: 2
    Last Post: 07-01-2011, 04:26 PM
  5. 614 demethium passwords...
    By Deathbyu in forum Help
    Replies: 3
    Last Post: 05-21-2011, 03:39 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •