package net.ihe.xds.users.model; import java.io.Serializable; import java.util.Set; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.JoinTable; import javax.persistence.ManyToMany; import javax.persistence.SequenceGenerator; import javax.persistence.Table; import javax.persistence.UniqueConstraint; import org.hibernate.validator.NotNull; import org.jboss.seam.annotations.security.management.UserEnabled; import org.jboss.seam.annotations.security.management.UserPassword; import org.jboss.seam.annotations.security.management.UserPrincipal; import org.jboss.seam.annotations.security.management.UserRoles; /** * * @author abderrazek boufahja * */ @Entity @Table(uniqueConstraints = @UniqueConstraint(columnNames = "username"), name = "user_account") @SequenceGenerator(name = "user_account_sequence", sequenceName = "user_account_id_seq", allocationSize = 1) public class UserAccount implements Serializable { private static final long serialVersionUID = 6368734442192368866L; private Long id; private String username; private String passwordHash; private boolean enabled; private Set roles; @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "user_account_sequence") public Long getId() { return id; } public void setId(Long id) { this.id = id; } @NotNull @UserPrincipal public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } @UserPassword(hash = "SHA") @Column(name = "password_hash") public String getPasswordHash() { return passwordHash; } public void setPasswordHash(String passwordHash) { this.passwordHash = passwordHash; } @UserEnabled public boolean isEnabled() { return enabled; } public void setEnabled(boolean enabled) { this.enabled = enabled; } @UserRoles @ManyToMany @JoinTable(name = "user_account_role", joinColumns = @JoinColumn(name = "account_id"), inverseJoinColumns = @JoinColumn(name = "member_of_role")) public Set getRoles() { return roles; } public void setRoles(Set roles) { this.roles = roles; } }