Examples of ExceptionConverter


Examples of com.lowagie.text.ExceptionConverter

          fact.setNamespaceAware(true);
      DocumentBuilder db = fact.newDocumentBuilder();
          ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
          domDocument = db.parse(bais);
    } catch (ParserConfigurationException e) {
      throw new ExceptionConverter(e);
    }
  }
View Full Code Here

Examples of com.lowagie.text.ExceptionConverter

  public PdfEncryption() {
    try {
      md5 = MessageDigest.getInstance("MD5");
    } catch (Exception e) {
      throw new ExceptionConverter(e);
    }
    publicKeyHandler = new PdfPublicKeySecurityHandler();
  }
View Full Code Here

Examples of com.lowagie.text.ExceptionConverter

  public static byte[] createDocumentId() {
    MessageDigest md5;
    try {
      md5 = MessageDigest.getInstance("MD5");
    } catch (Exception e) {
      throw new ExceptionConverter(e);
    }
    long time = System.currentTimeMillis();
    long mem = Runtime.getRuntime().freeMemory();
    String s = time + "+" + mem + "+" + (seq++);
    return md5.digest(s.getBytes());
View Full Code Here

Examples of com.lowagie.text.ExceptionConverter

      dic.put(PdfName.R, new PdfNumber(revision));

      try {
        recipients = publicKeyHandler.getEncodedRecipients();
      } catch (Exception f) {
        throw new ExceptionConverter(f);
      }

      if (revision == STANDARD_ENCRYPTION_40) {
        dic.put(PdfName.V, new PdfNumber(1));
        dic.put(PdfName.SUBFILTER, PdfName.ADBE_PKCS7_S4);
        dic.put(PdfName.RECIPIENTS, recipients);
      } else if (revision == STANDARD_ENCRYPTION_128 && encryptMetadata) {
        dic.put(PdfName.V, new PdfNumber(2));
        dic.put(PdfName.LENGTH, new PdfNumber(128));
        dic.put(PdfName.SUBFILTER, PdfName.ADBE_PKCS7_S4);
        dic.put(PdfName.RECIPIENTS, recipients);
      } else {
        dic.put(PdfName.R, new PdfNumber(AES_128));
        dic.put(PdfName.V, new PdfNumber(4));
        dic.put(PdfName.SUBFILTER, PdfName.ADBE_PKCS7_S5);

        PdfDictionary stdcf = new PdfDictionary();
        stdcf.put(PdfName.RECIPIENTS, recipients);
        if (!encryptMetadata)
          stdcf.put(PdfName.ENCRYPTMETADATA, PdfBoolean.PDFFALSE);

        if (revision == AES_128)
          stdcf.put(PdfName.CFM, PdfName.AESV2);
        else
          stdcf.put(PdfName.CFM, PdfName.V2);
        PdfDictionary cf = new PdfDictionary();
        cf.put(PdfName.DEFAULTCRYPTFILER, stdcf);
        dic.put(PdfName.CF, cf);if (embeddedFilesOnly) {
          dic.put(PdfName.EFF, PdfName.DEFAULTCRYPTFILER);
          dic.put(PdfName.STRF, PdfName.IDENTITY);
          dic.put(PdfName.STMF, PdfName.IDENTITY);
        }
        else {
          dic.put(PdfName.STRF, PdfName.DEFAULTCRYPTFILER);
          dic.put(PdfName.STMF, PdfName.DEFAULTCRYPTFILER);
        }
      }

      MessageDigest md = null;
      byte[] encodedRecipient = null;

      try {
        md = MessageDigest.getInstance("SHA-1");
        md.update(publicKeyHandler.getSeed());
        for (int i = 0; i < publicKeyHandler.getRecipientsSize(); i++) {
          encodedRecipient = publicKeyHandler.getEncodedRecipient(i);
          md.update(encodedRecipient);
        }
        if (!encryptMetadata)
          md.update(new byte[] { (byte) 255, (byte) 255, (byte) 255,
              (byte) 255 });
      } catch (Exception f) {
        throw new ExceptionConverter(f);
      }

      byte[] mdResult = md.digest();

      setupByEncryptionKey(mdResult, keyLength);
View Full Code Here

Examples of com.lowagie.text.ExceptionConverter

      OutputStreamEncryption os2 = getEncryptionStream(ba);
      os2.write(b);
      os2.finish();
      return ba.toByteArray();
    } catch (IOException ex) {
      throw new ExceptionConverter(ex);
    }
  }
View Full Code Here

Examples of com.lowagie.text.ExceptionConverter

      b2 = dec.finish();
      if (b2 != null)
        ba.write(b2);
      return ba.toByteArray();
    } catch (IOException ex) {
      throw new ExceptionConverter(ex);
    }
  }
View Full Code Here

Examples of com.lowagie.text.ExceptionConverter

                zip.write(conts);
                zip.close();
                bytes = stream.toByteArray();
            }
            catch (IOException ioe) {
                throw new ExceptionConverter(ioe);
            }
            put(PdfName.FILTER, PdfName.FLATEDECODE);
        }
        else
            bytes = conts;
View Full Code Here

Examples of com.lowagie.text.ExceptionConverter

                zip.close();
                bytes = stream.toByteArray();
                this.compressionLevel = compressionLevel;
            }
            catch (IOException ioe) {
                throw new ExceptionConverter(ioe);
            }
            put(PdfName.FILTER, PdfName.FLATEDECODE);
        }
        else
            bytes = data;
View Full Code Here

Examples of com.lowagie.text.ExceptionConverter

            else
                sig = Signature.getInstance("SHA1withRSA", provider);
            sig.initVerify(signCert.getPublicKey());
        }
        catch (Exception e) {
            throw new ExceptionConverter(e);
        }
    }
View Full Code Here

Examples of com.lowagie.text.ExceptionConverter

            else
                sig = Signature.getInstance(getDigestAlgorithm(), provider);
            sig.initVerify(signCert.getPublicKey());
        }
        catch (Exception e) {
            throw new ExceptionConverter(e);
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.