Matthias Andreas Benkard | 734879e | 2020-01-24 10:47:37 +0100 | [diff] [blame^] | 1 | package eu.mulk.mulkcms2.benki; |
| 2 | |
| 3 | import java.math.BigInteger; |
| 4 | import java.util.Collection; |
| 5 | import javax.persistence.Column; |
| 6 | import javax.persistence.Entity; |
| 7 | import javax.persistence.Id; |
| 8 | import javax.persistence.IdClass; |
| 9 | import javax.persistence.OneToMany; |
| 10 | import javax.persistence.Table; |
| 11 | |
| 12 | @Entity |
| 13 | @Table(name = "rsa_keys", schema = "public", catalog = "benki") |
| 14 | @IdClass(RsaKeyPK.class) |
| 15 | public 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 | } |