code: public static void encrypt(PdfReader reader, OutputStream os, byte userPassword[], byte ownerPassword[], int permissions, boolean strength128Bits) throws DocumentException, IOException {
          PdfStamper stamper = new PdfStamper(reader, os);
          stamper.setEncryption(userPassword, ownerPassword, permissions, strength128Bits);
          stamper.close();
      }
docs: Entry point to encrypt a PDF document. The encryption parameters are the same as in
  <code>PdfWriter</code>. The userPassword and the
  ownerPassword can be null or have zero length. In this case the ownerPassword
  is replaced by a random string. The open permissions for the document can be
  AllowPrinting, AllowModifyContents, AllowCopy, AllowModifyAnnotations,
  AllowFillIn, AllowScreenReaders, AllowAssembly and AllowDegradedPrinting.
  The permissions can be combined by ORing them.
  @param reader the read PDF
  @param os the output destination
  @param userPassword the user password. Can be null or empty
  @param ownerPassword the owner password. Can be null or empty
  @param permissions the user permissions
  @param strength128Bits <code>true</code> for 128 bit key length, <code>false</code> for 40 bit key length
  @throws DocumentException on error
  @throws IOException on error