secu + merge resolution

This commit is contained in:
Thomas Cardon 2022-03-02 14:11:50 +01:00
commit 1003f1c7c9
21 changed files with 750 additions and 12 deletions

View file

@ -0,0 +1,14 @@
package fr.cardon.simpleat.model;
import org.springframework.security.core.GrantedAuthority;
public enum EnumRole implements GrantedAuthority {
ROLE_ADMIN, ROLE_CREATOR, ROLE_READER;
@Override
public String getAuthority() {
return name();
}
}

View file

@ -3,10 +3,15 @@ package fr.cardon.simpleat.model;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
@ -18,6 +23,8 @@ import javax.persistence.OneToMany;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
@Entity
public class Personne {
@ -28,6 +35,7 @@ public class Personne {
private String password;
private Collection<Role> roles = new ArrayList<Role>();
private Collection<Preference> preference = new ArrayList<Preference>();
private List<EnumRole> roleList;
public Personne() {
@ -35,6 +43,30 @@ public class Personne {
// TODO Auto-generated constructor stub
}
public Personne(String nom, String prenom, String email, String password, List<EnumRole> roleList) {
super();
this.nom = nom;
this.prenom = prenom;
this.email = email;
this.password = password;
this.roleList = roleList;
}
public Personne(String email, String password, List<EnumRole> roleList) {
super();
this.email = email;
this.password = password;
this.roleList = roleList;
}
public Personne(String nom, String prenom, String email, String password) {
super();
@ -45,17 +77,20 @@ public class Personne {
}
public Personne(String nom, String prenom, String email, String password, Collection<Role> roles) {
public Personne(String nom, String prenom, String email, String password,
Collection<fr.cardon.simpleat.model.Role> roles, Collection<Preference> preference,
List<EnumRole> roleList) {
super();
this.nom = nom;
this.prenom = prenom;
this.email = email;
this.password = password;
this.roles = roles;
this.preference = preference;
this.roleList = roleList;
}
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id_personne")
@ -113,7 +148,7 @@ public class Personne {
@OneToMany(mappedBy = "preferencePK.personne", cascade = CascadeType.REMOVE)
@JsonIgnore
//@JsonIgnore
public Collection<Preference> getPreference() {
return preference;
}
@ -123,4 +158,17 @@ public class Personne {
this.preference = preference;
}
}
@ElementCollection(fetch = FetchType.EAGER)
@Enumerated(EnumType.STRING)
public List<EnumRole> getRoleList() {
return roleList;
}
public void setRoleList(List<EnumRole> roleList) {
this.roleList = roleList;
}
}

View file

@ -10,6 +10,7 @@ import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.PrimaryKeyJoinColumn;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
@ -39,7 +40,7 @@ public class PreferencePK implements Serializable {
@ManyToOne
@PrimaryKeyJoinColumn(name="id_personne", referencedColumnName ="id_personne" )
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
@JsonIgnore
public Personne getPersonne() {
return personne;
}