Package org.pdfbox.pdmodel.encryption

Examples of org.pdfbox.pdmodel.encryption.StandardSecurityHandler


    }
    }


  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 );
        }
        else
        {
          return secHandler.isOwnerPassword(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

TOP

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

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.