blob: 556568eefcec129e67ccc0f864d7576d830ea3bf [file] [log] [blame]
Matthias Andreas Benkard2f0b3702020-01-12 15:46:34 +01001package eu.mulk.entity;
2
3import io.quarkus.hibernate.orm.panache.PanacheEntityBase;
4import java.util.Arrays;
5import java.util.Objects;
6import javax.persistence.Column;
7import javax.persistence.Entity;
8import javax.persistence.Id;
9import javax.persistence.IdClass;
10import javax.persistence.JoinColumn;
11import javax.persistence.ManyToOne;
12import javax.persistence.Table;
13
14@Entity
15@Table(name = "login_certificates", schema = "public", catalog = "mulkcms")
16@IdClass(LoginCertificatePK.class)
17public class LoginCertificate extends PanacheEntityBase {
18
19 private int userId;
20 private byte[] certificate;
21 private User user;
22
23 @Id
24 @Column(name = "user", nullable = false)
25 public int getUserId() {
26 return userId;
27 }
28
29 public void setUserId(int userId) {
30 this.userId = userId;
31 }
32
33 @Id
34 @Column(name = "certificate", nullable = false)
35 public byte[] getCertificate() {
36 return certificate;
37 }
38
39 public void setCertificate(byte[] certificate) {
40 this.certificate = certificate;
41 }
42
43 @Override
44 public boolean equals(Object o) {
45 if (this == o) {
46 return true;
47 }
48 if (o == null || getClass() != o.getClass()) {
49 return false;
50 }
51 LoginCertificate that = (LoginCertificate) o;
52 return userId == that.userId &&
53 Arrays.equals(certificate, that.certificate);
54 }
55
56 @Override
57 public int hashCode() {
58 int result = Objects.hash(userId);
59 result = 31 * result + Arrays.hashCode(certificate);
60 return result;
61 }
62
63 @ManyToOne
64 @JoinColumn(name = "user", referencedColumnName = "id", nullable = false, insertable = false, updatable = false)
65 public User getUser() {
66 return user;
67 }
68
69 public void setUser(User user) {
70 this.user = user;
71 }
72}