01: package org.bouncycastle.cms;
02:
03: import org.bouncycastle.util.Arrays;
04:
05: import java.security.cert.X509CertSelector;
06:
07: /**
08: * a basic index for a signer.
09: */
10: public class SignerId extends X509CertSelector {
11: public int hashCode() {
12: int code = Arrays.hashCode(this .getSubjectKeyIdentifier());
13:
14: if (this .getSerialNumber() != null) {
15: code ^= this .getSerialNumber().hashCode();
16: }
17:
18: if (this .getIssuerAsString() != null) {
19: code ^= this .getIssuerAsString().hashCode();
20: }
21:
22: return code;
23: }
24:
25: public boolean equals(Object o) {
26: if (!(o instanceof SignerId)) {
27: return false;
28: }
29:
30: SignerId id = (SignerId) o;
31:
32: return Arrays.areEqual(this .getSubjectKeyIdentifier(), id
33: .getSubjectKeyIdentifier())
34: && equalsObj(this .getSerialNumber(), id
35: .getSerialNumber())
36: && equalsObj(this .getIssuerAsString(), id
37: .getIssuerAsString());
38: }
39:
40: private boolean equalsObj(Object a, Object b) {
41: return (a != null) ? a.equals(b) : b == null;
42: }
43: }
|