Commit bfa8d2b5 authored by Maxym Borodenko's avatar Maxym Borodenko Committed by Matija Obreza
Browse files

System accounts

parent 3887b124
......@@ -20,6 +20,7 @@ import java.util.Collection;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
import javax.persistence.CollectionTable;
......@@ -30,6 +31,7 @@ import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.MappedSuperclass;
import javax.persistence.PrePersist;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
......@@ -53,9 +55,12 @@ public abstract class BasicUser<R extends GrantedAuthority> extends AuditedVersi
private static final long serialVersionUID = -5318892732608111516L;
public static enum AccountType {
LOCAL, LDAP, GOOGLE
LOCAL, LDAP, GOOGLE, SYSTEM
}
@Column(length = 36, unique = true)
private String uuid;
@JsonView(JsonViews.Public.class)
@Column(nullable = false, unique = true, length = 60)
private String email;
......@@ -97,6 +102,13 @@ public abstract class BasicUser<R extends GrantedAuthority> extends AuditedVersi
@Column(length = 20)
private AccountType accountType = AccountType.LOCAL;
@PrePersist
void ensureUUID() {
if (this.uuid == null) {
this.uuid = UUID.nameUUIDFromBytes(getEmail().getBytes()).toString();
}
}
public String getEmail() {
return email;
}
......@@ -157,6 +169,14 @@ public abstract class BasicUser<R extends GrantedAuthority> extends AuditedVersi
this.roles = roles;
}
public String getUuid() {
return uuid;
}
public void setUuid(final String uuid) {
this.uuid = uuid;
}
@Override
public String toString() {
return MessageFormat.format("id={0} email={1} fullName={2}", getId(), email, fullName);
......@@ -175,7 +195,7 @@ public abstract class BasicUser<R extends GrantedAuthority> extends AuditedVersi
@Override
public String getUsername() {
return email;
return uuid;
}
@Override
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment