Add read-only clientVersion property to LoginCredentials
This is just a regular string that can be used to confirm the compatibility between client and server.
This commit is contained in:
		@@ -20,22 +20,25 @@ public class LoginCredentials implements Serializable {
 | 
			
		||||
	private final String	identifier;
 | 
			
		||||
	private final byte[]	passwordHash;
 | 
			
		||||
	private final boolean	registration;
 | 
			
		||||
	private final String	clientVersion;
 | 
			
		||||
 | 
			
		||||
	private static final long serialVersionUID = -7395245059059523314L;
 | 
			
		||||
	private static final long serialVersionUID = 1;
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Creates an instance of {@link LoginCredentials} for a new {@link User}.
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param identifier   the identifier of the user
 | 
			
		||||
	 * @param password     the password of the user (will be converted to a hash)
 | 
			
		||||
	 * @param registration signifies that these credentials are used for user
 | 
			
		||||
	 *                     registration instead of user login
 | 
			
		||||
	 * @param identifier    the identifier of the user
 | 
			
		||||
	 * @param password      the password of the user (will be converted to a hash)
 | 
			
		||||
	 * @param registration  signifies that these credentials are used for user
 | 
			
		||||
	 *                      registration instead of user login
 | 
			
		||||
	 * @param clientVersion the version of the client sending these credentials
 | 
			
		||||
	 * @since Envoy Common v0.2-alpha
 | 
			
		||||
	 */
 | 
			
		||||
	public LoginCredentials(String identifier, char[] password, boolean registration) {
 | 
			
		||||
	public LoginCredentials(String identifier, char[] password, boolean registration, String clientVersion) {
 | 
			
		||||
		this.identifier		= identifier;
 | 
			
		||||
		passwordHash		= getSha256(toByteArray(password));
 | 
			
		||||
		this.registration	= registration;
 | 
			
		||||
		this.clientVersion	= clientVersion;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	private byte[] getSha256(byte[] input) {
 | 
			
		||||
@@ -84,4 +87,10 @@ public class LoginCredentials implements Serializable {
 | 
			
		||||
	 * @since Envoy Common v0.2-alpha
 | 
			
		||||
	 */
 | 
			
		||||
	public boolean isRegistration() { return registration; }
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * @return the version of the client sending these credentials
 | 
			
		||||
	 * @since Envoy Common v0.1-beta
 | 
			
		||||
	 */
 | 
			
		||||
	public String getClientVersion() { return clientVersion; }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user