Пример #1
0
  public boolean equals(Object o) {
    if (o == null || !(o instanceof ASN1Sequence)) {
      return false;
    }

    ASN1Sequence other = (ASN1Sequence) o;

    if (this.size() != other.size()) {
      return false;
    }

    Enumeration s1 = this.getObjects();
    Enumeration s2 = other.getObjects();

    while (s1.hasMoreElements()) {
      Object o1 = s1.nextElement();
      Object o2 = s2.nextElement();

      if (o1 != null && o2 != null) {
        if (!o1.equals(o2)) {
          return false;
        }
      } else if (o1 == null && o2 == null) {
        continue;
      } else {
        return false;
      }
    }

    return true;
  }
Пример #2
0
  /**
   * Constructor from ASN1Sequence.
   *
   * <p>the extensions are a list of constructed sequences, either with (OID, OctetString) or (OID,
   * Boolean, OctetString)
   */
  public X509Extensions(ASN1Sequence seq) {
    Enumeration e = seq.getObjects();

    while (e.hasMoreElements()) {
      ASN1Sequence s = (ASN1Sequence) e.nextElement();

      if (s.size() == 3) {
        extensions.put(
            s.getObjectAt(0),
            new X509Extension((DERBoolean) s.getObjectAt(1), (ASN1OctetString) s.getObjectAt(2)));
      } else {
        extensions.put(
            s.getObjectAt(0), new X509Extension(false, (ASN1OctetString) s.getObjectAt(1)));
      }

      ordering.addElement(s.getObjectAt(0));
    }
  }