Package org.apache.pdfbox.pdmodel.encryption

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


                    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


            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

                doc = PDDocument.load( in );
                if( doc.isEncrypted() )
                {
                    try
                    {
                        StandardDecryptionMaterial sdm = new StandardDecryptionMaterial(password);
                        doc.openProtection(sdm);
                        doc.setAllSecurityToBeRemoved(true);
                    }
                    catch( InvalidPasswordException e )
                    {
View Full Code Here

        }
        else
        {
            doc = PDDocument.load(new ByteArrayInputStream(inputFileAsByteArray));
            Assert.assertTrue(doc.isEncrypted());
            DecryptionMaterial decryptionMaterial = new StandardDecryptionMaterial(password);
            doc.openProtection(decryptionMaterial);
        }
        AccessPermission currentAccessPermission = doc.getCurrentAccessPermission();

        // check permissions
View Full Code Here

        }
        else
        {
            encryptedDoc = PDDocument.load(pdfFile);
            Assert.assertTrue(encryptedDoc.isEncrypted());
            DecryptionMaterial decryptionMaterial = new StandardDecryptionMaterial(ownerpassword);
            encryptedDoc.openProtection(decryptionMaterial);
        }
        Assert.assertTrue(encryptedDoc.getCurrentAccessPermission().isOwnerPermission());
        encryptedDoc.close();

        // test with owner password => restricted permissions
        if (nonSeq)
        {
            encryptedDoc = PDDocument.loadNonSeq(pdfFile, userpassword);
        }
        else
        {
            encryptedDoc = PDDocument.load(pdfFile);
            Assert.assertTrue(encryptedDoc.isEncrypted());
            DecryptionMaterial decryptionMaterial = new StandardDecryptionMaterial(userpassword);
            encryptedDoc.openProtection(decryptionMaterial);
        }
        Assert.assertFalse(encryptedDoc.getCurrentAccessPermission().isOwnerPermission());

        assertEquals(permission.getPermissionBytes(), encryptedDoc.getCurrentAccessPermission().getPermissionBytes());
View Full Code Here

                document = PDDocument.load( args[0]);
                if( document.isEncrypted() )
                {
                    try
                    {
                        StandardDecryptionMaterial sdm = new StandardDecryptionMaterial("");
                        document.openProtection(sdm);
                    }
                    catch( InvalidPasswordException e )
                    {
                        System.err.println( "Error: Document is encrypted with a password." );
View Full Code Here

                {
                    document = PDDocument.load(pdfFile);

                    if (document.isEncrypted())
                    {
                        StandardDecryptionMaterial sdm = new StandardDecryptionMaterial(password);
                        document.openProtection(sdm);
                    }
                    for (PDPage page : document.getPages())
                    {
                        PDResources resources = page.getResources();
View Full Code Here

            {
                document = PDDocument.load( infile );

                if( document.isEncrypted() )
                {
                    StandardDecryptionMaterial sdm = new StandardDecryptionMaterial(password);
                    document.openProtection(sdm);
                }
                else
                {
                    System.err.println( "Warning: Document is not encrypted." );
View Full Code Here

                document = PDDocument.load( args[0] );
                if( document.isEncrypted() )
                {
                    try
                    {
                        StandardDecryptionMaterial sdm = new StandardDecryptionMaterial("");
                        document.openProtection(sdm);
                    }
                    catch( InvalidPasswordException e )
                    {
                        System.err.println( "Error: Document is encrypted with a password." );
View Full Code Here

                document = PDDocument.load( args[0] );
                if( document.isEncrypted() )
                {
                    try
                    {
                        StandardDecryptionMaterial sdm = new StandardDecryptionMaterial("");
                        document.openProtection(sdm);
                    }
                    catch( InvalidPasswordException e )
                    {
                        System.err.println( "Error: Document is encrypted with a password." );
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.