2019-12-29 10:47:35 +01:00
|
|
|
package envoy.data;
|
|
|
|
|
|
|
|
import java.io.Serializable;
|
2020-07-16 17:04:35 +02:00
|
|
|
import java.time.Instant;
|
2019-12-29 10:47:35 +01:00
|
|
|
|
|
|
|
/**
|
2020-07-08 12:32:24 +02:00
|
|
|
* Contains a {@link User}'s login / registration information as well as the
|
|
|
|
* client version.
|
|
|
|
* <p>
|
2019-12-29 10:47:35 +01:00
|
|
|
* Project: <strong>envoy-common</strong><br>
|
|
|
|
* File: <strong>LoginCredentials.java</strong><br>
|
|
|
|
* Created: <strong>29.12.2019</strong><br>
|
2019-12-30 18:49:48 +01:00
|
|
|
*
|
2019-12-29 10:47:35 +01:00
|
|
|
* @author Kai S. K. Engelbart
|
|
|
|
* @since Envoy Common v0.2-alpha
|
|
|
|
*/
|
2020-07-08 12:32:24 +02:00
|
|
|
public final class LoginCredentials implements Serializable {
|
2019-12-29 10:47:35 +01:00
|
|
|
|
2020-07-08 12:32:24 +02:00
|
|
|
private final String identifier, password, clientVersion;
|
2020-01-18 10:27:29 +01:00
|
|
|
private final boolean registration;
|
2020-07-16 17:04:35 +02:00
|
|
|
private final Instant lastSync;
|
2019-12-29 10:47:35 +01:00
|
|
|
|
2020-07-16 17:04:35 +02:00
|
|
|
private static final long serialVersionUID = 3;
|
2019-12-31 10:16:52 +01:00
|
|
|
|
2019-12-29 10:47:35 +01:00
|
|
|
/**
|
2020-07-08 12:32:24 +02:00
|
|
|
* Initializes login credentials for a handshake.
|
2019-12-30 18:49:48 +01:00
|
|
|
*
|
2020-06-19 15:56:45 +02:00
|
|
|
* @param identifier the identifier of the user
|
2020-07-08 12:32:24 +02:00
|
|
|
* @param password the password of the user
|
2020-06-19 15:56:45 +02:00
|
|
|
* @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
|
2020-07-16 17:04:35 +02:00
|
|
|
* @param lastSync the time stamp of the last synchronization
|
|
|
|
* @since Envoy Common v0.2-beta
|
2019-12-29 10:47:35 +01:00
|
|
|
*/
|
2020-07-16 17:04:35 +02:00
|
|
|
public LoginCredentials(String identifier, String password, boolean registration, String clientVersion, Instant lastSync) {
|
2020-02-07 22:37:48 +01:00
|
|
|
this.identifier = identifier;
|
2020-07-08 12:32:24 +02:00
|
|
|
this.password = password;
|
2020-02-08 09:47:59 +01:00
|
|
|
this.registration = registration;
|
2020-06-19 15:56:45 +02:00
|
|
|
this.clientVersion = clientVersion;
|
2020-07-16 17:04:35 +02:00
|
|
|
this.lastSync = lastSync;
|
2019-12-29 10:47:35 +01:00
|
|
|
}
|
|
|
|
|
2019-12-30 18:49:48 +01:00
|
|
|
@Override
|
|
|
|
public String toString() {
|
2020-07-16 17:04:35 +02:00
|
|
|
return String.format("LoginCredentials[identifier=%s,registration=%b,clientVersion=%s,lastSync=%s]",
|
|
|
|
identifier,
|
|
|
|
registration,
|
|
|
|
clientVersion,
|
|
|
|
lastSync);
|
2019-12-29 10:47:35 +01:00
|
|
|
}
|
2019-12-31 10:20:35 +01:00
|
|
|
|
|
|
|
/**
|
2020-02-07 22:37:48 +01:00
|
|
|
* @return the identifier of the user performing the login
|
2019-12-31 10:20:35 +01:00
|
|
|
* @since Envoy Common v0.2-alpha
|
|
|
|
*/
|
2020-02-07 22:37:48 +01:00
|
|
|
public String getIdentifier() { return identifier; }
|
2019-12-31 10:20:35 +01:00
|
|
|
|
|
|
|
/**
|
2020-07-08 12:32:24 +02:00
|
|
|
* @return the password of the user performing the login
|
|
|
|
* @since Envoy Common v0.1-beta
|
2019-12-31 10:20:35 +01:00
|
|
|
*/
|
2020-07-08 12:32:24 +02:00
|
|
|
public String getPassword() { return password; }
|
2020-01-18 10:27:29 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return {@code true} if these credentials are used for user registration
|
|
|
|
* instead of user login
|
|
|
|
* @since Envoy Common v0.2-alpha
|
|
|
|
*/
|
|
|
|
public boolean isRegistration() { return registration; }
|
2020-06-19 15:56:45 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return the version of the client sending these credentials
|
|
|
|
* @since Envoy Common v0.1-beta
|
|
|
|
*/
|
|
|
|
public String getClientVersion() { return clientVersion; }
|
2020-07-16 17:04:35 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return the time stamp of the last synchronization
|
|
|
|
* @since Envoy Common v0.2-beta
|
|
|
|
*/
|
|
|
|
public Instant getLastSync() { return lastSync; }
|
2020-03-22 14:52:38 +01:00
|
|
|
}
|