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,8 +20,9 @@ public class LoginCredentials implements Serializable { | |||||||
| 	private final String	identifier; | 	private final String	identifier; | ||||||
| 	private final byte[]	passwordHash; | 	private final byte[]	passwordHash; | ||||||
| 	private final boolean	registration; | 	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}. | 	 * Creates an instance of {@link LoginCredentials} for a new {@link User}. | ||||||
| @@ -30,12 +31,14 @@ public class LoginCredentials implements Serializable { | |||||||
| 	 * @param password      the password of the user (will be converted to a hash) | 	 * @param password      the password of the user (will be converted to a hash) | ||||||
| 	 * @param registration  signifies that these credentials are used for user | 	 * @param registration  signifies that these credentials are used for user | ||||||
| 	 *                      registration instead of user login | 	 *                      registration instead of user login | ||||||
|  | 	 * @param clientVersion the version of the client sending these credentials | ||||||
| 	 * @since Envoy Common v0.2-alpha | 	 * @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; | 		this.identifier		= identifier; | ||||||
| 		passwordHash		= getSha256(toByteArray(password)); | 		passwordHash		= getSha256(toByteArray(password)); | ||||||
| 		this.registration	= registration; | 		this.registration	= registration; | ||||||
|  | 		this.clientVersion	= clientVersion; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	private byte[] getSha256(byte[] input) { | 	private byte[] getSha256(byte[] input) { | ||||||
| @@ -84,4 +87,10 @@ public class LoginCredentials implements Serializable { | |||||||
| 	 * @since Envoy Common v0.2-alpha | 	 * @since Envoy Common v0.2-alpha | ||||||
| 	 */ | 	 */ | ||||||
| 	public boolean isRegistration() { return registration; } | 	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