/**
   * Constructor from ASN1Sequence.
   *
   * <p>The sequence is of type ProcurationSyntax:
   *
   * <p>
   *
   * <pre>
   *               ProcurationSyntax ::= SEQUENCE {
   *                 country [1] EXPLICIT PrintableString(SIZE(2)) OPTIONAL,
   *                 typeOfSubstitution [2] EXPLICIT DirectoryString (SIZE(1..128)) OPTIONAL,
   *                 signingFor [3] EXPLICIT SigningFor
   *               }
   *
   *               SigningFor ::= CHOICE
   *               {
   *                 thirdPerson GeneralName,
   *                 certRef IssuerSerial
   *               }
   * </pre>
   *
   * @param seq The ASN.1 sequence.
   */
  private ProcurationSyntax(ASN1Sequence seq) {
    if (seq.size() < 1 || seq.size() > 3) {
      throw new IllegalArgumentException("Bad sequence size: " + seq.size());
    }
    Enumeration e = seq.getObjects();

    while (e.hasMoreElements()) {
      ASN1TaggedObject o = ASN1TaggedObject.getInstance(e.nextElement());
      switch (o.getTagNo()) {
        case 1:
          country = DERPrintableString.getInstance(o, true).getString();
          break;
        case 2:
          typeOfSubstitution = DirectoryString.getInstance(o, true);
          break;
        case 3:
          DEREncodable signingFor = o.getObject();
          if (signingFor instanceof ASN1TaggedObject) {
            thirdPerson = GeneralName.getInstance(signingFor);
          } else {
            certRef = IssuerSerial.getInstance(signingFor);
          }
          break;
        default:
          throw new IllegalArgumentException("Bad tag number: " + o.getTagNo());
      }
    }
  }
  /**
   * Constructor from ASN1Sequence.
   *
   * <p>The sequence is of type CertificatePair:
   *
   * <p>
   *
   * <pre>
   *       CertificatePair ::= SEQUENCE {
   *         forward        [0]    Certificate OPTIONAL,
   *         reverse        [1]    Certificate OPTIONAL,
   *         -- at least one of the pair shall be present -- }
   * </pre>
   *
   * @param seq The ASN.1 sequence.
   */
  private CertificatePair(ASN1Sequence seq) {
    if (seq.size() != 1 && seq.size() != 2) {
      throw new IllegalArgumentException("Bad sequence size: " + seq.size());
    }

    Enumeration e = seq.getObjects();

    while (e.hasMoreElements()) {
      ASN1TaggedObject o = ASN1TaggedObject.getInstance(e.nextElement());
      if (o.getTagNo() == 0) {
        forward = X509CertificateStructure.getInstance(o, true);
      } else if (o.getTagNo() == 1) {
        reverse = X509CertificateStructure.getInstance(o, true);
      } else {
        throw new IllegalArgumentException("Bad tag number: " + o.getTagNo());
      }
    }
  }
Exemple #3
0
  /**
   * Constructor that builds an instance of <code>RoleSyntax</code> by extracting the encoded
   * elements from the <code>ASN1Sequence</code> object supplied.
   *
   * @param seq an instance of <code>ASN1Sequence</code> that holds the encoded elements used to
   *     build this <code>RoleSyntax</code>.
   */
  private RoleSyntax(ASN1Sequence seq) {
    if (seq.size() < 1 || seq.size() > 2) {
      throw new IllegalArgumentException("Bad sequence size: " + seq.size());
    }

    for (int i = 0; i != seq.size(); i++) {
      ASN1TaggedObject taggedObject = ASN1TaggedObject.getInstance(seq.getObjectAt(i));
      switch (taggedObject.getTagNo()) {
        case 0:
          roleAuthority = GeneralNames.getInstance(taggedObject, false);
          break;
        case 1:
          roleName = GeneralName.getInstance(taggedObject, true);
          break;
        default:
          throw new IllegalArgumentException("Unknown tag in RoleSyntax");
      }
    }
  }