package com.ufund.api.ufundapi.model;
import java.time.LocalDateTime;
import java.util.UUID;
import com.fasterxml.jackson.annotation.JsonProperty;
public class UserAuth {
@JsonProperty("key") String key;
@JsonProperty("username") String username;
@JsonProperty("expiration") LocalDateTime expiration;
public UserAuth(@JsonProperty("key") String key, @JsonProperty("username") String username, @JsonProperty("expiration") LocalDateTime expiration) {
this.key = key;
this.username = username;
this.expiration = expiration;
}
/**
* Generate a new user authentication profile
*
* @param username the username the key will belong to
* @return The new user authentication profile
*/
public static UserAuth generate(String username) {
return new UserAuth(
UUID.randomUUID().toString(),
username,
LocalDateTime.now().plusDays(30)
);
}
public String getKey() {
return key;
}
public String getUsername() {
return username;
}
public LocalDateTime getExpiration() {
return expiration;
}
}