Package org.apache.pdfbox.pdmodel.encryption

Examples of org.apache.pdfbox.pdmodel.encryption.StandardDecryptionMaterial


      pdfDocument = parser.getPDDocument();

      // Decrypt the PDF-Dokument
      if (pdfDocument.isEncrypted()) {
        mLog.debug("Document is encrypted: " + url);
        StandardDecryptionMaterial sdm = new StandardDecryptionMaterial("");
        pdfDocument.openProtection(sdm);
        AccessPermission ap = pdfDocument.getCurrentAccessPermission();

        if (!ap.canExtractContent()) {
          throw new RegainException("Document is encrypted and can't be opened: " + url);
View Full Code Here


            Thread.currentThread().setPriority(Thread.NORM_PRIORITY);
        }

        if (pdfDoc.isEncrypted()) {
            try {
                pdfDoc.openProtection(new StandardDecryptionMaterial(""));
            } catch (final BadSecurityHandlerException e) {
                try {pdfDoc.close();} catch (final IOException ee) {}
                throw new Parser.Failure("Document is encrypted (1): " + e.getMessage(), location);
            } catch (final IOException e) {
                try {pdfDoc.close();} catch (final IOException ee) {}
View Full Code Here

     */
    public void decrypt( String password ) throws CryptographyException, IOException, InvalidPasswordException
    {
        try
        {
            StandardDecryptionMaterial m = new StandardDecryptionMaterial(password);
            this.openProtection(m);
            document.dereferenceObjectStreams();
        }
        catch(BadSecurityHandlerException e)
        {
View Full Code Here

                    document = PDDocument.load(pdfFile);
                    if( document.isEncrypted() )
                    {
                        try
                        {
                            StandardDecryptionMaterial sdm = new StandardDecryptionMaterial(password);
                            document.openProtection(sdm);
                        }
                        catch( InvalidPasswordException e )
                        {
                            if( args.length == 4 )//they supplied the wrong password
View Full Code Here

            // password (such a document appears to not be encrypted by
            // someone viewing the document, thus the confusion).  We will
            // attempt to decrypt with the empty password to handle this case.
            try
            {
                StandardDecryptionMaterial sdm = new StandardDecryptionMaterial("");
                document.openProtection(sdm);
            }
            catch (InvalidPasswordException e)
            {
                throw new IOException("Invalid password for encrypted document", e);
View Full Code Here

                else
                {
                    document = PDDocument.load(pdfFile, force);
                    if( document.isEncrypted() )
                    {
                        StandardDecryptionMaterial sdm = new StandardDecryptionMaterial( password );
                        document.openProtection( sdm );
                    }
                }
               
                AccessPermission ap = document.getCurrentAccessPermission();
View Full Code Here

            {
                document = PDDocument.load(pdfFile);

                if (document.isEncrypted())
                {
                    StandardDecryptionMaterial spm = new StandardDecryptionMaterial(password);
                    document.openProtection(spm);
                }
            }
            AccessPermission ap = document.getCurrentAccessPermission();
            if (! ap.canExtractContent())
View Full Code Here

        {
            document = PDDocument.load(pdfFile);

            if (document.isEncrypted())
            {
                StandardDecryptionMaterial sdm = new StandardDecryptionMaterial(password);
                document.openProtection(sdm);
            }

            PrinterJob printJob = PrinterJob.getPrinterJob();
            printJob.setJobName(new File(pdfFile).getName());
View Full Code Here

            document = PDDocument.load( file );
            if( document.isEncrypted() )
            {
                try
                {
                    StandardDecryptionMaterial sdm = new StandardDecryptionMaterial(password);
                    document.openProtection(sdm);
                }
                catch( InvalidPasswordException e )
                {
                    System.err.println( "Error: The document is encrypted." );
View Full Code Here

                        decryptionMaterial = new PublicKeyDecryptionMaterial(ks, alias, password);
                    }
                    else
                    {
                        decryptionMaterial = new StandardDecryptionMaterial(password);
                    }
                    document.openProtection(decryptionMaterial);
                    AccessPermission ap = document.getCurrentAccessPermission();
                    if(ap.isOwnerPermission())
                    {
View Full Code Here

TOP

Related Classes of org.apache.pdfbox.pdmodel.encryption.StandardDecryptionMaterial

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.