Exemplo n.º 1
0
  /**
   * Constructor from ASN1Sequence.
   *
   * <p>
   *
   * <p>
   *
   * <pre>
   *               ProfessionInfo ::= SEQUENCE
   *               {
   *                 namingAuthority [0] EXPLICIT NamingAuthority OPTIONAL,
   *                 professionItems SEQUENCE OF DirectoryString (SIZE(1..128)),
   *                 professionOIDs SEQUENCE OF OBJECT IDENTIFIER OPTIONAL,
   *                 registrationNumber PrintableString(SIZE(1..128)) OPTIONAL,
   *                 addProfessionInfo OCTET STRING OPTIONAL
   *               }
   * </pre>
   *
   * @param seq The ASN.1 sequence.
   */
  private ProfessionInfo(ASN1Sequence seq) {
    if (seq.size() > 5) {
      throw new IllegalArgumentException("Bad sequence size: " + seq.size());
    }

    Enumeration e = seq.getObjects();

    DEREncodable o = (DEREncodable) e.nextElement();

    if (o instanceof ASN1TaggedObject) {
      if (((ASN1TaggedObject) o).getTagNo() != 0) {
        throw new IllegalArgumentException("Bad tag number: " + ((ASN1TaggedObject) o).getTagNo());
      }
      namingAuthority = NamingAuthority.getInstance((ASN1TaggedObject) o, true);
      o = (DEREncodable) e.nextElement();
    }

    professionItems = ASN1Sequence.getInstance(o);

    if (e.hasMoreElements()) {
      o = (DEREncodable) e.nextElement();
      if (o instanceof ASN1Sequence) {
        professionOIDs = ASN1Sequence.getInstance(o);
      } else if (o instanceof DERPrintableString) {
        registrationNumber = DERPrintableString.getInstance(o).getString();
      } else if (o instanceof ASN1OctetString) {
        addProfessionInfo = ASN1OctetString.getInstance(o);
      } else {
        throw new IllegalArgumentException("Bad object encountered: " + o.getClass());
      }
    }
    if (e.hasMoreElements()) {
      o = (DEREncodable) e.nextElement();
      if (o instanceof DERPrintableString) {
        registrationNumber = DERPrintableString.getInstance(o).getString();
      } else if (o instanceof DEROctetString) {
        addProfessionInfo = (DEROctetString) o;
      } else {
        throw new IllegalArgumentException("Bad object encountered: " + o.getClass());
      }
    }
    if (e.hasMoreElements()) {
      o = (DEREncodable) e.nextElement();
      if (o instanceof DEROctetString) {
        addProfessionInfo = (DEROctetString) o;
      } else {
        throw new IllegalArgumentException("Bad object encountered: " + o.getClass());
      }
    }
  }
Exemplo n.º 2
0
  /**
   * Gets the role authority as a <code>String[]</code> object.
   *
   * @return the role authority of this RoleSyntax represented as a <code>String[]</code> array.
   */
  public String[] getRoleAuthorityAsString() {
    if (roleAuthority == null) {
      return new String[0];
    }

    GeneralName[] names = roleAuthority.getNames();
    String[] namesString = new String[names.length];
    for (int i = 0; i < names.length; i++) {
      DEREncodable value = names[i].getName();
      if (value instanceof ASN1String) {
        namesString[i] = ((ASN1String) value).getString();
      } else {
        namesString[i] = value.toString();
      }
    }
    return namesString;
  }