Home | History | Annotate | Download | only in style
      1 package org.bouncycastle.asn1.x500.style;
      2 
      3 import org.bouncycastle.asn1.x500.RDN;
      4 import org.bouncycastle.asn1.x500.X500Name;
      5 import org.bouncycastle.asn1.x500.X500NameStyle;
      6 
      7 /**
      8  * Variation of BCStyle that insists on strict ordering for equality
      9  * and hashCode comparisons
     10  */
     11 public class BCStrictStyle
     12     extends BCStyle
     13 {
     14     public static final X500NameStyle INSTANCE = new BCStrictStyle();
     15 
     16     public boolean areEqual(X500Name name1, X500Name name2)
     17     {
     18         RDN[] rdns1 = name1.getRDNs();
     19         RDN[] rdns2 = name2.getRDNs();
     20 
     21         if (rdns1.length != rdns2.length)
     22         {
     23             return false;
     24         }
     25 
     26         for (int i = 0; i != rdns1.length; i++)
     27         {
     28             if (!rdnAreEqual(rdns1[i], rdns2[i]))
     29             {
     30                 return false;
     31             }
     32         }
     33 
     34         return true;
     35     }
     36 }
     37