コード例 #1
0
  /** @deprecated use X500Name method. */
  public CertificationRequestInfo(
      X509Name subject, SubjectPublicKeyInfo pkInfo, ASN1Set attributes) {
    this.subject = X500Name.getInstance(subject.toASN1Primitive());
    this.subjectPKInfo = pkInfo;
    this.attributes = attributes;

    if ((subject == null) || (version == null) || (subjectPKInfo == null)) {
      throw new IllegalArgumentException(
          "Not all mandatory fields set in CertificationRequestInfo generator.");
    }
  }
コード例 #2
0
ファイル: X509Name.java プロジェクト: smsj1010/testproject3
  /**
   * @param inOrder if true the order of both X509 names must be the same, as well as the values
   *     associated with each element.
   */
  public boolean equals(Object obj, boolean inOrder) {
    if (!inOrder) {
      return this.equals(obj);
    }

    if (obj == this) {
      return true;
    }

    if (!(obj instanceof X509Name || obj instanceof ASN1Sequence)) {
      return false;
    }

    DERObject derO = ((DEREncodable) obj).getDERObject();

    if (this.getDERObject().equals(derO)) {
      return true;
    }

    X509Name other;

    try {
      other = X509Name.getInstance(obj);
    } catch (IllegalArgumentException e) {
      return false;
    }

    int orderingSize = ordering.size();

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

    for (int i = 0; i < orderingSize; i++) {
      DERObjectIdentifier oid = (DERObjectIdentifier) ordering.elementAt(i);
      DERObjectIdentifier oOid = (DERObjectIdentifier) other.ordering.elementAt(i);

      if (oid.equals(oOid)) {
        String value = (String) values.elementAt(i);
        String oValue = (String) other.values.elementAt(i);

        if (!equivalentStrings(value, oValue)) {
          return false;
        }
      } else {
        return false;
      }
    }

    return true;
  }
コード例 #3
0
  public CertificationRequestInfo(ASN1Sequence seq) {
    version = (DERInteger) seq.getObjectAt(0);

    subject = X509Name.getInstance(seq.getObjectAt(1));
    subjectPKInfo = SubjectPublicKeyInfo.getInstance(seq.getObjectAt(2));

    //
    // some CertificationRequestInfo objects seem to treat this field
    // as optional.
    //
    if (seq.size() > 3) {
      DERTaggedObject tagobj = (DERTaggedObject) seq.getObjectAt(3);
      attributes = ASN1Set.getInstance(tagobj, false);
    }

    if ((subject == null) || (version == null) || (subjectPKInfo == null)) {
      throw new IllegalArgumentException(
          "Not all mandatory fields set in CertificationRequestInfo generator.");
    }
  }
コード例 #4
0
ファイル: X509Name.java プロジェクト: smsj1010/testproject3
  /** test for equality - note: case is ignored. */
  public boolean equals(Object obj) {
    if (obj == this) {
      return true;
    }

    if (!(obj instanceof X509Name || obj instanceof ASN1Sequence)) {
      return false;
    }

    DERObject derO = ((DEREncodable) obj).getDERObject();

    if (this.getDERObject().equals(derO)) {
      return true;
    }

    X509Name other;

    try {
      other = X509Name.getInstance(obj);
    } catch (IllegalArgumentException e) {
      return false;
    }

    int orderingSize = ordering.size();

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

    boolean[] indexes = new boolean[orderingSize];
    int start, end, delta;

    if (ordering.elementAt(0).equals(other.ordering.elementAt(0))) // guess forward
    {
      start = 0;
      end = orderingSize;
      delta = 1;
    } else // guess reversed - most common problem
    {
      start = orderingSize - 1;
      end = -1;
      delta = -1;
    }

    for (int i = start; i != end; i += delta) {
      boolean found = false;
      DERObjectIdentifier oid = (DERObjectIdentifier) ordering.elementAt(i);
      String value = (String) values.elementAt(i);

      for (int j = 0; j < orderingSize; j++) {
        if (indexes[j]) {
          continue;
        }

        DERObjectIdentifier oOid = (DERObjectIdentifier) other.ordering.elementAt(j);

        if (oid.equals(oOid)) {
          String oValue = (String) other.values.elementAt(j);

          if (equivalentStrings(value, oValue)) {
            indexes[j] = true;
            found = true;
            break;
          }
        }
      }

      if (!found) {
        return false;
      }
    }

    return true;
  }