package envoy.data; import java.io.Serializable; import java.time.Instant; /** * Contains a {@link User}'s login / registration information as well as the * client version. *
* Project: envoy-common
* File: LoginCredentials.java
* Created: 29.12.2019
*
* @author Kai S. K. Engelbart
* @since Envoy Common v0.2-alpha
*/
public final class LoginCredentials implements Serializable {
private final String identifier, password, clientVersion;
private final boolean registration;
private final Instant lastSync;
private static final long serialVersionUID = 3;
/**
* Initializes login credentials for a handshake.
*
* @param identifier the identifier of the user
* @param password the password of the user
* @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
* @param lastSync the time stamp of the last synchronization
* @since Envoy Common v0.2-beta
*/
public LoginCredentials(String identifier, String password, boolean registration, String clientVersion, Instant lastSync) {
this.identifier = identifier;
this.password = password;
this.registration = registration;
this.clientVersion = clientVersion;
this.lastSync = lastSync;
}
@Override
public String toString() {
return String.format("LoginCredentials[identifier=%s,registration=%b,clientVersion=%s,lastSync=%s]",
identifier,
registration,
clientVersion,
lastSync);
}
/**
* @return the identifier of the user performing the login
* @since Envoy Common v0.2-alpha
*/
public String getIdentifier() { return identifier; }
/**
* @return the password of the user performing the login
* @since Envoy Common v0.1-beta
*/
public String getPassword() { return password; }
/**
* @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; }
/**
* @return the version of the client sending these credentials
* @since Envoy Common v0.1-beta
*/
public String getClientVersion() { return clientVersion; }
/**
* @return the time stamp of the last synchronization
* @since Envoy Common v0.2-beta
*/
public Instant getLastSync() { return lastSync; }
}