blob: f2bbb8a2c35063e80f09facbe8b2dc21fc8fedb1 [file] [log] [blame]
Matthias Andreas Benkard734879e2020-01-24 10:47:37 +01001package eu.mulk.mulkcms2.benki;
2
3import java.math.BigInteger;
4import java.util.Collection;
5import javax.persistence.Column;
6import javax.persistence.Entity;
7import javax.persistence.Id;
8import javax.persistence.IdClass;
9import javax.persistence.OneToMany;
10import javax.persistence.Table;
11
12@Entity
13@Table(name = "rsa_keys", schema = "public", catalog = "benki")
14@IdClass(RsaKeyPK.class)
15public class RsaKey {
16
17 private BigInteger modulus;
18 private BigInteger exponent;
19 private Collection<UserRsaKey> users;
20
21 @Id
22 @Column(name = "modulus", nullable = false, precision = 0)
23 public BigInteger getModulus() {
24 return modulus;
25 }
26
27 public void setModulus(BigInteger modulus) {
28 this.modulus = modulus;
29 }
30
31 @Id
32 @Column(name = "exponent", nullable = false, precision = 0)
33 public BigInteger getExponent() {
34 return exponent;
35 }
36
37 public void setExponent(BigInteger exponent) {
38 this.exponent = exponent;
39 }
40
41 @Override
42 public boolean equals(Object o) {
43 if (this == o) {
44 return true;
45 }
46 if (o == null || getClass() != o.getClass()) {
47 return false;
48 }
49
50 RsaKey rsaKey = (RsaKey) o;
51
52 if (modulus != null ? !modulus.equals(rsaKey.modulus) : rsaKey.modulus != null) {
53 return false;
54 }
55 if (exponent != null ? !exponent.equals(rsaKey.exponent) : rsaKey.exponent != null) {
56 return false;
57 }
58
59 return true;
60 }
61
62 @Override
63 public int hashCode() {
64 int result = modulus != null ? modulus.hashCode() : 0;
65 result = 31 * result + (exponent != null ? exponent.hashCode() : 0);
66 return result;
67 }
68
69 @OneToMany(mappedBy = "rsaKey")
70 public Collection<UserRsaKey> getUsers() {
71 return users;
72 }
73
74 public void setUsers(Collection<UserRsaKey> users) {
75 this.users = users;
76 }
77}