Package org.pdfbox.pdmodel.encryption

Examples of org.pdfbox.pdmodel.encryption.PDEncryptionDictionary


    {   
        if( encParameters == null )
        {
            if( isEncrypted() )
            {
                encParameters = new PDEncryptionDictionary(document.getEncryptionDictionary());
            }
            else
            {
                encParameters = new PDEncryptionDictionary();
            }
        }
        return encParameters;              
    }
View Full Code Here


     * @throws CryptographyException If there is an error during decryption.
     */   
    public void openProtection(DecryptionMaterial pm)
        throws BadSecurityHandlerException, IOException, CryptographyException
    {
        PDEncryptionDictionary dict = this.getEncryptionDictionary();
        if(dict.getFilter() != null)
        {
            SecurityHandler handler = SecurityHandlersManager.getInstance().getSecurityHandler(dict.getFilter());
            securityHandler = handler;
            handler.decryptDocument(this, pm);
            document.dereferenceObjectStreams();
        }
        else
View Full Code Here

          bitValue = EXTRACT_FOR_ACCESSIBILITY_BIT;
        else
          throw new IllegalArgumentException("Unknown pdf permission: " + permission);

       
        final PDEncryptionDictionary info;
    try {
      info = (PDEncryptionDictionary) getPDFDocument().getEncryptionDictionary();
    }
    catch (final IOException e)
    {
      throw new RuntimeException("Can't read permissions", e);
    }
        return (info.getPermissions() & (1 << (bitValue-1))) != 0;
    }
View Full Code Here


  private boolean isPassword(String password, boolean userPassword) throws IOException, BadSecurityHandlerException, CryptographyException {
        final StandardSecurityHandler secHandler = getSecurityHandler();
     
        PDEncryptionDictionary dictionary = getPDFDocument().getEncryptionDictionary();

        int dicPermissions = dictionary.getPermissions();
        int dicRevision = dictionary.getRevision();
        int dicLength = dictionary.getLength()/8;

        COSString id = (COSString) getPDFDocument().getDocument().getDocumentID().getObject( 0 );
        byte[] u = dictionary.getUserKey();
        byte[] o = dictionary.getOwnerKey();

        if (userPassword)
        {
          return secHandler.isUserPassword(password.getBytes(), u,
              o, dicPermissions, id.getBytes(), dicRevision, dicLength );
View Full Code Here

        }
  }

  private StandardSecurityHandler getSecurityHandler() throws IOException,
      BadSecurityHandlerException {
    PDEncryptionDictionary dict = getPDFDocument().getEncryptionDictionary();
        StandardSecurityHandler secHandler = (StandardSecurityHandler) SecurityHandlersManager.getInstance().getSecurityHandler(dict.getFilter());
    return secHandler;
  }
View Full Code Here

   */
  public int getEncryptionLength() {
    int length = 0;
    try {
      if (pdDocument.isEncrypted()) {
        final PDEncryptionDictionary dicen = pdDocument
            .getEncryptionDictionary();
        length = dicen.getLength();
      }
    } catch (IOException ioe) {
      length = 0;
    }
    return length;
View Full Code Here

      fireSpecialNull(ctx, "version", Float.toString(cosDoc.getVersion()));
     
      ctx.fireStartParseEvent("security");
      ctx.fireParseEvent("encrypted", encrypted);
      if (encrypted) {
        PDEncryptionDictionary encDict = doc.getEncryptionDictionary();
 
        PDFPermissions perms = new PDFPermissions(
            encDict.getCOSDictionary().getInt("P"),
            encDict.getCOSDictionary().getInt("V"));
       
        fireSpecialNull(ctx, "scheme", encDict.getFilter());
        fireSpecialNull(ctx, "scheme-type", schemeVersionNames[encDict.getVersion()]);
        ctx.fireParseEvent("key-length", encDict.getLength());
        ctx.fireParseEvent("readonly", !perms.allowModify());
        ctx.fireParseEvent("allow-print", perms.allowPrint());
        ctx.fireParseEvent("allow-copy", perms.allowCopy());
        ctx.fireParseEvent("allow-notes", perms.allowTextNotes());
        ctx.fireParseEvent("user-password", encDict.getUserKey() != null);
        ctx.fireParseEvent("owner-password", encDict.getOwnerKey() != null);
      }
      ctx.fireEndParseEvent("security");   
     
      ctx.fireEndParseEvent("pdf-meta");
    }
View Full Code Here

TOP

Related Classes of org.pdfbox.pdmodel.encryption.PDEncryptionDictionary

Copyright © 2018 www.massapicom. 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.