diff options
Diffstat (limited to 'bcprov/src/main/java/org/bouncycastle/jce/provider/X509CRLObject.java')
-rw-r--r-- | bcprov/src/main/java/org/bouncycastle/jce/provider/X509CRLObject.java | 59 |
1 files changed, 54 insertions, 5 deletions
diff --git a/bcprov/src/main/java/org/bouncycastle/jce/provider/X509CRLObject.java b/bcprov/src/main/java/org/bouncycastle/jce/provider/X509CRLObject.java index cd83211..b5b4f13 100644 --- a/bcprov/src/main/java/org/bouncycastle/jce/provider/X509CRLObject.java +++ b/bcprov/src/main/java/org/bouncycastle/jce/provider/X509CRLObject.java @@ -59,6 +59,8 @@ public class X509CRLObject private String sigAlgName; private byte[] sigAlgParams; private boolean isIndirect; + private boolean isHashCodeSet = false; + private int hashCodeValue; static boolean isIndirectCRL(X509CRL crl) throws CRLException @@ -520,7 +522,7 @@ public class X509CRLObject throw new RuntimeException("X.509 CRL used with non X.509 Cert"); } - TBSCertList.CRLEntry[] certs = c.getRevokedCertificates(); + Enumeration certs = c.getRevokedCertificateEnumeration(); X500Name caName = c.getIssuer(); @@ -528,11 +530,13 @@ public class X509CRLObject { BigInteger serial = ((X509Certificate)cert).getSerialNumber(); - for (int i = 0; i < certs.length; i++) + while (certs.hasMoreElements()) { - if (isIndirect && certs[i].hasExtensions()) + TBSCertList.CRLEntry entry = TBSCertList.CRLEntry.getInstance(certs.nextElement()); + + if (isIndirect && entry.hasExtensions()) { - Extension currentCaName = certs[i].getExtensions().getExtension(Extension.certificateIssuer); + Extension currentCaName = entry.getExtensions().getExtension(Extension.certificateIssuer); if (currentCaName != null) { @@ -540,7 +544,7 @@ public class X509CRLObject } } - if (certs[i].getUserCertificate().getValue().equals(serial)) + if (entry.getUserCertificate().getValue().equals(serial)) { X500Name issuer; @@ -572,5 +576,50 @@ public class X509CRLObject return false; } + + public boolean equals(Object other) + { + if (this == other) + { + return true; + } + + if (!(other instanceof X509CRL)) + { + return false; + } + + if (other instanceof X509CRLObject) + { + X509CRLObject crlObject = (X509CRLObject)other; + + if (isHashCodeSet) + { + boolean otherIsHashCodeSet = crlObject.isHashCodeSet; + if (otherIsHashCodeSet) + { + if (crlObject.hashCodeValue != hashCodeValue) + { + return false; + } + } + } + + return this.c.equals(crlObject.c); + } + + return super.equals(other); + } + + public int hashCode() + { + if (!isHashCodeSet) + { + isHashCodeSet = true; + hashCodeValue = super.hashCode(); + } + + return hashCodeValue; + } } |