/**
   * 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());
      }
    }
  }
Exemplo n.º 2
0
 /** @return Returns the professionItems. */
 public DirectoryString[] getProfessionItems() {
   DirectoryString[] items = new DirectoryString[professionItems.size()];
   int count = 0;
   for (Enumeration e = professionItems.getObjects(); e.hasMoreElements(); ) {
     items[count++] = DirectoryString.getInstance(e.nextElement());
   }
   return items;
 }
Exemplo n.º 3
0
  public static Restriction getInstance(Object obj) {
    if (obj instanceof Restriction) {
      return (Restriction) obj;
    }

    if (obj instanceof ASN1String) {
      return new Restriction(DirectoryString.getInstance(obj));
    }

    throw new IllegalArgumentException(
        "illegal object in getInstance: " + obj.getClass().getName());
  }