}
}
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 );
}
}