Examples of AccessPermission


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

              }
                   
              securityHandler = SecurityHandlersManager.getInstance().getSecurityHandler( encParameters.getFilter() );
              securityHandler.prepareForDecryption( encParameters, document.getDocumentID(), decryptionMaterial );
                   
              AccessPermission permission = securityHandler.getCurrentAccessPermission();
              if ( ! permission.canExtractContent() )
              {
                  LOG.warn( "PDF file '" + pdfFile.getPath() + "' does not allow extracting content." );
              }
               
          }
View Full Code Here

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

        throws CryptographyException, IOException
    {
        try
        {
            StandardProtectionPolicy policy =
                new StandardProtectionPolicy(ownerPassword, userPassword, new AccessPermission());
            this.protect(policy);
        }
        catch(BadSecurityHandlerException e)
        {
            throw new CryptographyException(e);
View Full Code Here

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

                }

                securityHandler = SecurityHandlersManager.getInstance().getSecurityHandler(encParameters.getFilter());
                securityHandler.prepareForDecryption(encParameters, document.getDocumentID(), decryptionMaterial);

                AccessPermission permission = securityHandler.getCurrentAccessPermission();
                if (!permission.canExtractContent())
                {
                    LOG.warn("PDF file '" + pdfFile.getPath() + "' does not allow extracting content.");
                }

            }
View Full Code Here

Examples of org.pdfbox.pdmodel.encryption.AccessPermission

     * @param name The junit test class name.
     */
    public TestPublicKeyEncryption( String name )
    {
        super( name );
        accessPermission = new AccessPermission();
        accessPermission.setCanAssembleDocument(false);
        accessPermission.setCanExtractContent(false);               
        accessPermission.setCanExtractForAccessibility(true);
        accessPermission.setCanFillInForm(false);
        accessPermission.setCanModify(false);
        accessPermission.setCanModifyAnnotations(false);
        accessPermission.setCanPrint(false);
        accessPermission.setCanPrintDegraded(false);
       
        accessPermission2 = new AccessPermission();
        accessPermission2.setCanAssembleDocument(false);
        accessPermission2.setCanExtractContent(false);               
        accessPermission2.setCanExtractForAccessibility(true);
        accessPermission2.setCanFillInForm(false);
        accessPermission2.setCanModify(false);
View Full Code Here

Examples of org.pdfbox.pdmodel.encryption.AccessPermission

       
        open(doc2, privateCert1.getAbsolutePath(), password1);       
       
        Assert.assertTrue(doc2.isEncrypted());
       
        AccessPermission currentAp = doc2.getCurrentAccessPermission();
       
        Assert.assertFalse(currentAp.canAssembleDocument());
        Assert.assertFalse(currentAp.canExtractContent());
        Assert.assertTrue(currentAp.canExtractForAccessibility());
        Assert.assertFalse(currentAp.canFillInForm());
        Assert.assertFalse(currentAp.canModify());
        Assert.assertFalse(currentAp.canModifyAnnotations());
        Assert.assertFalse(currentAp.canPrint());
        Assert.assertFalse(currentAp.canPrintDegraded());
       
        doc2.close();
           
    }
View Full Code Here

Examples of org.pdfbox.pdmodel.encryption.AccessPermission

                    else
                    {
                        decryptionMaterial = new StandardDecryptionMaterial(password);
                    }
                    document.openProtection(decryptionMaterial);
                    AccessPermission ap = document.getCurrentAccessPermission();
                    if(ap.isOwnerPermission())
                    {
                        document.save( outfile );
                    }
                    else
                    {
View Full Code Here

Examples of org.pdfbox.pdmodel.encryption.AccessPermission

                    if( document.isEncrypted() )
                    {
                   
                        StandardDecryptionMaterial spm = new StandardDecryptionMaterial(password);
                        document.openProtection(spm);
                        AccessPermission ap = document.getCurrentAccessPermission();
                           
                       
                        if( ! ap.canExtractContent() )
                        {
                            throw new IOException(
                                "Error: You do not have permission to extract images." );
                        }
                    }
View Full Code Here

Examples of org.pdfbox.pdmodel.encryption.AccessPermission

        {
            usage();
        }
        else
        {
            AccessPermission ap = new AccessPermission();
           
            String infile = null;
            String outfile = null;
            String certFile = null;
            String userPassword = "";
            String ownerPassword = "";
           
            int keyLength = 48;

            PDDocument document = null;

            try
            {
                for( int i=0; i<args.length; i++ )
                {
                    String key = args[i];
                    if( key.equals( "-O" ) )
                    {
                        ownerPassword = args[++i];
                    }
                    else if( key.equals( "-U" ) )
                    {
                        userPassword = args[++i];
                    }
                    else if( key.equals( "-canAssemble" ) )
                    {
                        ap.setCanAssembleDocument(args[++i].equalsIgnoreCase( "true" ));
                    }
                    else if( key.equals( "-canExtractContent" ) )
                    {
                        ap.setCanExtractContent( args[++i].equalsIgnoreCase( "true" ) );
                    }
                    else if( key.equals( "-canExtractForAccessibility" ) )
                    {
                        ap.setCanExtractForAccessibility( args[++i].equalsIgnoreCase( "true" ) );
                    }
                    else if( key.equals( "-canFillInForm" ) )
                    {
                        ap.setCanFillInForm( args[++i].equalsIgnoreCase( "true" ) );
                    }
                    else if( key.equals( "-canModify" ) )
                    {
                        ap.setCanModify( args[++i].equalsIgnoreCase( "true" ) );
                    }
                    else if( key.equals( "-canModifyAnnotations" ) )
                    {
                        ap.setCanModifyAnnotations( args[++i].equalsIgnoreCase( "true" ) );
                    }
                    else if( key.equals( "-canPrint" ) )
                    {
                        ap.setCanPrint( args[++i].equalsIgnoreCase( "true" ) );
                    }
                    else if( key.equals( "-canPrintDegraded" ) )
                    {
                        ap.setCanPrintDegraded( args[++i].equalsIgnoreCase( "true" ) );
                    }
                    else if( key.equals( "-certFile" ) )
                    {
                        certFile = args[++i];
                    }
View Full Code Here

Examples of org.pdfbox.pdmodel.encryption.AccessPermission

                //document.print();
                if( document.isEncrypted() )
                {
                    StandardDecryptionMaterial sdm = new StandardDecryptionMaterial( password );                   
                    document.openProtection( sdm );
                    AccessPermission ap = document.getCurrentAccessPermission();
                   
                    if( ! ap.canExtractContent() )
                    {
                        throw new IOException( "You do not have permission to extract text" );
                    }
                }
                if( toConsole )
View Full Code Here

Examples of org.pdfbox.pdmodel.encryption.AccessPermission

        throws CryptographyException, IOException
    {
        try
        {
            StandardProtectionPolicy policy =
                new StandardProtectionPolicy(ownerPassword, userPassword, new AccessPermission());
            this.protect(policy);
        }
        catch(BadSecurityHandlerException e)
        {
            throw new CryptographyException(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.