From bb6360d2a720b63f9e07519b95a9761b1e29b2d3 Mon Sep 17 00:00:00 2001 From: kske Date: Fri, 19 Jun 2020 15:56:45 +0200 Subject: [PATCH] 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. --- .../java/envoy/data/LoginCredentials.java | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/main/java/envoy/data/LoginCredentials.java b/src/main/java/envoy/data/LoginCredentials.java index e097047..afffd4b 100644 --- a/src/main/java/envoy/data/LoginCredentials.java +++ b/src/main/java/envoy/data/LoginCredentials.java @@ -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; } }