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 import java.util.Arrays; |
|
11 |
|
12 /** |
|
13 * |
|
14 * @author George Politis |
|
15 */ |
|
16 public class SignatureX { |
|
17 // Fields. |
|
18 public PublicKey longTermPublicKey; |
|
19 public int dhKeyID; |
|
20 public byte[] signature; |
|
21 |
|
22 // Ctor. |
|
23 public SignatureX(PublicKey ourLongTermPublicKey, int ourKeyID, |
|
24 byte[] signature) { |
|
25 this.longTermPublicKey = ourLongTermPublicKey; |
|
26 this.dhKeyID = ourKeyID; |
|
27 this.signature = signature; |
|
28 } |
|
29 |
|
30 // Methods. |
|
31 @Override |
|
32 public int hashCode() { |
|
33 // TODO: Needs work. |
|
34 final int prime = 31; |
|
35 int result = 1; |
|
36 result = prime * result + dhKeyID; |
|
37 result = prime |
|
38 * result |
|
39 + ((longTermPublicKey == null) ? 0 : longTermPublicKey |
|
40 .hashCode()); |
|
41 result = prime * result + Arrays.hashCode(signature); |
|
42 return result; |
|
43 } |
|
44 |
|
45 @Override |
|
46 public boolean equals(Object obj) { |
|
47 // TODO: Needs work. |
|
48 if (this == obj) |
|
49 return true; |
|
50 if (obj == null) |
|
51 return false; |
|
52 if (getClass() != obj.getClass()) |
|
53 return false; |
|
54 SignatureX other = (SignatureX) obj; |
|
55 if (dhKeyID != other.dhKeyID) |
|
56 return false; |
|
57 if (longTermPublicKey == null) { |
|
58 if (other.longTermPublicKey != null) |
|
59 return false; |
|
60 } else if (!longTermPublicKey.equals(other.longTermPublicKey)) |
|
61 return false; |
|
62 if (!Arrays.equals(signature, other.signature)) |
|
63 return false; |
|
64 return true; |
|
65 } |
|
66 |
|
67 } |
|