public EncryptedContentInfo(ASN1Sequence seq) {
   contentType = (DERObjectIdentifier) seq.getObjectAt(0);
   contentEncryptionAlgorithm = AlgorithmIdentifier.getInstance(seq.getObjectAt(1));
   if (seq.size() > 2) {
     encryptedContent = ASN1OctetString.getInstance((ASN1TaggedObject) seq.getObjectAt(2), false);
   }
 }
  public ASN1OctetString getContent() {
    if (data.size() == 3) {
      DERTaggedObject o = (DERTaggedObject) data.getObjectAt(2);

      return ASN1OctetString.getInstance(o, false);
    }

    return null;
  }
Beispiel #3
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());
      }
    }
  }
 public byte[] getSalt() {
   return salt.getOctets();
 }