code: public byte[] getAuthenticatedAttributeBytes(byte secondDigest[], Calendar signingTime, byte[] ocsp) {
          try {
              return getAuthenticatedAttributeSet(secondDigest, signingTime, ocsp).getEncoded(ASN1Encoding.DER);
          }
          catch (Exception e) {
              throw new ExceptionConverter(e);
          }
      }
docs: When using authenticatedAttributes the authentication process is different.
  The document digest is generated and put inside the attribute. The signing is done over the DER encoded
  authenticatedAttributes. This method provides that encoding and the parameters must be
  exactly the same as in {@link #getEncodedPKCS7(byte[],Calendar)}.
  <p>
  A simple example:
  <p>
  <pre>
  Calendar cal = Calendar.getInstance();
  PdfPKCS7 pk7 = new PdfPKCS7(key, chain, null, "SHA1", null, false);
  MessageDigest messageDigest = MessageDigest.getInstance("SHA1");
  byte buf[] = new byte[8192];
  int n;
  InputStream inp = sap.getRangeStream();
  while ((n = inp.read(buf)) &gt; 0) {
  messageDigest.update(buf, 0, n);
  }
  byte hash[] = messageDigest.digest();
  byte sh[] = pk7.getAuthenticatedAttributeBytes(hash, cal);
  pk7.update(sh, 0, sh.length);
  byte sg[] = pk7.getEncodedPKCS7(hash, cal);
  </pre>
  @param secondDigest the content digest
  @param signingTime the signing time
  @return the byte array representation of the authenticatedAttributes ready to be signed