2013-03-23 16:17:19 +01:00
|
|
|
package com.commafeed.backend.model;
|
2013-03-20 20:33:42 +01:00
|
|
|
|
2013-03-28 17:07:37 +01:00
|
|
|
import java.util.Set;
|
|
|
|
|
|
|
|
|
|
import javax.persistence.CascadeType;
|
2013-03-20 20:33:42 +01:00
|
|
|
import javax.persistence.Column;
|
|
|
|
|
import javax.persistence.Entity;
|
2013-03-28 17:07:37 +01:00
|
|
|
import javax.persistence.OneToMany;
|
2013-03-20 20:33:42 +01:00
|
|
|
import javax.persistence.Table;
|
|
|
|
|
|
2013-03-29 11:51:27 +01:00
|
|
|
import org.hibernate.annotations.Index;
|
|
|
|
|
|
2013-03-28 17:07:37 +01:00
|
|
|
import com.google.common.collect.Sets;
|
|
|
|
|
|
2013-03-20 20:33:42 +01:00
|
|
|
@Entity
|
|
|
|
|
@Table(name = "USERS")
|
2013-03-21 08:55:53 +01:00
|
|
|
@SuppressWarnings("serial")
|
2013-03-23 01:49:39 +01:00
|
|
|
public class User extends AbstractModel {
|
2013-03-20 20:33:42 +01:00
|
|
|
|
2013-03-29 11:51:27 +01:00
|
|
|
@Column(length = 32, nullable = false, unique = true)
|
|
|
|
|
@Index(name = "username_index")
|
2013-03-20 20:33:42 +01:00
|
|
|
private String name;
|
|
|
|
|
|
2013-04-05 16:31:42 +02:00
|
|
|
@Column(length = 256, unique = true)
|
|
|
|
|
private String email;
|
|
|
|
|
|
2013-03-29 11:51:27 +01:00
|
|
|
@Column(length = 256, nullable = false)
|
2013-03-20 20:33:42 +01:00
|
|
|
private byte[] password;
|
|
|
|
|
|
2013-03-29 11:51:27 +01:00
|
|
|
@Column(length = 8, nullable = false)
|
2013-03-20 20:33:42 +01:00
|
|
|
private byte[] salt;
|
|
|
|
|
|
2013-03-29 12:59:21 +01:00
|
|
|
@Column(nullable = false)
|
|
|
|
|
private boolean disabled;
|
|
|
|
|
|
2013-03-29 16:05:29 +01:00
|
|
|
@OneToMany(mappedBy = "user", cascade = CascadeType.PERSIST)
|
2013-03-28 17:07:37 +01:00
|
|
|
private Set<UserRole> roles = Sets.newHashSet();
|
|
|
|
|
|
2013-03-20 20:33:42 +01:00
|
|
|
public String getName() {
|
|
|
|
|
return name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setName(String name) {
|
|
|
|
|
this.name = name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public byte[] getPassword() {
|
|
|
|
|
return password;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setPassword(byte[] password) {
|
|
|
|
|
this.password = password;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public byte[] getSalt() {
|
|
|
|
|
return salt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setSalt(byte[] salt) {
|
|
|
|
|
this.salt = salt;
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-28 17:07:37 +01:00
|
|
|
public Set<UserRole> getRoles() {
|
|
|
|
|
return roles;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setRoles(Set<UserRole> roles) {
|
|
|
|
|
this.roles = roles;
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-29 12:59:21 +01:00
|
|
|
public boolean isDisabled() {
|
|
|
|
|
return disabled;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setDisabled(boolean disabled) {
|
|
|
|
|
this.disabled = disabled;
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-20 20:33:42 +01:00
|
|
|
}
|