Пример #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;
  }
  public X509CertificateStructure(ASN1Sequence seq) {
    this.seq = seq;

    //
    // correct x509 certficate
    //
    if (seq.size() == 3) {
      tbsCert = TBSCertificateStructure.getInstance(seq.getObjectAt(0));
      sigAlgId = AlgorithmIdentifier.getInstance(seq.getObjectAt(1));

      sig = (DERBitString) seq.getObjectAt(2);
    }
  }
Пример #3
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));
    }
  }
Пример #4
0
  public TBSCertificateStructure(ASN1Sequence seq) {
    int seqStart = 0;

    this.seq = seq;

    //
    // some certficates don't include a version number - we assume v1
    //
    if (seq.getObjectAt(0) instanceof DERTaggedObject) {
      version = DERInteger.getInstance(seq.getObjectAt(0));
    } else {
      seqStart = -1; // field 0 is missing!
      version = new DERInteger(0);
    }

    serialNumber = DERInteger.getInstance(seq.getObjectAt(seqStart + 1));

    signature = AlgorithmIdentifier.getInstance(seq.getObjectAt(seqStart + 2));
    issuer = X509Name.getInstance(seq.getObjectAt(seqStart + 3));

    //
    // before and after dates
    //
    ASN1Sequence dates = (ASN1Sequence) seq.getObjectAt(seqStart + 4);

    startDate = Time.getInstance(dates.getObjectAt(0));
    endDate = Time.getInstance(dates.getObjectAt(1));

    subject = X509Name.getInstance(seq.getObjectAt(seqStart + 5));

    //
    // public key info.
    //
    subjectPublicKeyInfo = SubjectPublicKeyInfo.getInstance(seq.getObjectAt(seqStart + 6));

    for (int extras = seq.size() - (seqStart + 6) - 1; extras > 0; extras--) {
      DERTaggedObject extra = (DERTaggedObject) seq.getObjectAt(seqStart + 6 + extras);

      switch (extra.getTagNo()) {
        case 1:
          issuerUniqueId = DERBitString.getInstance(extra);
          break;
        case 2:
          subjectUniqueId = DERBitString.getInstance(extra);
          break;
        case 3:
          extensions = X509Extensions.getInstance(extra);
      }
    }
  }
Пример #5
0
 public static TBSCertificateStructure getInstance(ASN1TaggedObject obj, boolean explicit) {
   return getInstance(ASN1Sequence.getInstance(obj, explicit));
 }
Пример #6
0
 public static X509Extensions getInstance(ASN1TaggedObject obj, boolean explicit) {
   return getInstance(ASN1Sequence.getInstance(obj, explicit));
 }