|
1 /* |
|
2 * otr4j, the open source java otr library. |
|
3 * |
|
4 * Distributable under LGPL license. |
|
5 * See terms of license at gnu.org. |
|
6 */ |
|
7 package net.java.otr4j.io.messages; |
|
8 |
|
9 import java.security.PublicKey; |
|
10 |
|
11 import javax.crypto.interfaces.DHPublicKey; |
|
12 |
|
13 /** |
|
14 * |
|
15 * @author George Politis |
|
16 */ |
|
17 public class SignatureM { |
|
18 // Fields. |
|
19 public DHPublicKey localPubKey; |
|
20 public DHPublicKey remotePubKey; |
|
21 public PublicKey localLongTermPubKey; |
|
22 public int keyPairID; |
|
23 |
|
24 // Ctor. |
|
25 public SignatureM(DHPublicKey localPubKey, DHPublicKey remotePublicKey, |
|
26 PublicKey localLongTermPublicKey, int keyPairID) { |
|
27 |
|
28 this.localPubKey = localPubKey; |
|
29 this.remotePubKey = remotePublicKey; |
|
30 this.localLongTermPubKey = localLongTermPublicKey; |
|
31 this.keyPairID = keyPairID; |
|
32 } |
|
33 |
|
34 // Methods. |
|
35 @Override |
|
36 public int hashCode() { |
|
37 final int prime = 31; |
|
38 int result = 1; |
|
39 result = prime * result + keyPairID; |
|
40 // TODO: Needs work. |
|
41 result = prime |
|
42 * result |
|
43 + ((localLongTermPubKey == null) ? 0 : localLongTermPubKey |
|
44 .hashCode()); |
|
45 result = prime * result |
|
46 + ((localPubKey == null) ? 0 : localPubKey.hashCode()); |
|
47 result = prime * result |
|
48 + ((remotePubKey == null) ? 0 : remotePubKey.hashCode()); |
|
49 return result; |
|
50 } |
|
51 |
|
52 @Override |
|
53 public boolean equals(Object obj) { |
|
54 // TODO: Needs work. |
|
55 if (this == obj) |
|
56 return true; |
|
57 if (obj == null) |
|
58 return false; |
|
59 if (getClass() != obj.getClass()) |
|
60 return false; |
|
61 SignatureM other = (SignatureM) obj; |
|
62 if (keyPairID != other.keyPairID) |
|
63 return false; |
|
64 if (localLongTermPubKey == null) { |
|
65 if (other.localLongTermPubKey != null) |
|
66 return false; |
|
67 } else if (!localLongTermPubKey.equals(other.localLongTermPubKey)) |
|
68 return false; |
|
69 if (localPubKey == null) { |
|
70 if (other.localPubKey != null) |
|
71 return false; |
|
72 } else if (!localPubKey.equals(other.localPubKey)) |
|
73 return false; |
|
74 if (remotePubKey == null) { |
|
75 if (other.remotePubKey != null) |
|
76 return false; |
|
77 } else if (!remotePubKey.equals(other.remotePubKey)) |
|
78 return false; |
|
79 return true; |
|
80 } |
|
81 |
|
82 } |