encryptionDictionary.setPermissions(permissionInt);
int length = keyLength/8;
COSArray idArray = document.getDocument().getDocumentID();
//check if the document has an id yet. If it does not then
//generate one
if( idArray == null || idArray.size() < 2 )
{
idArray = new COSArray();
try
{
MessageDigest md = MessageDigest.getInstance( "MD5" );
BigInteger time = BigInteger.valueOf( System.currentTimeMillis() );
md.update( time.toByteArray() );
md.update( ownerPassword.getBytes() );
md.update( userPassword.getBytes() );
md.update( document.getDocument().toString().getBytes() );
byte[] id = md.digest( this.toString().getBytes() );
COSString idString = new COSString();
idString.append( id );
idArray.add( idString );
idArray.add( idString );
document.getDocument().setDocumentID( idArray );
}
catch( NoSuchAlgorithmException e )
{
throw new CryptographyException( e );
}
catch(IOException e )
{
throw new CryptographyException( e );
}
}
COSString id = (COSString)idArray.getObject( 0 );
byte[] o = computeOwnerPassword(
ownerPassword.getBytes("ISO-8859-1"),
userPassword.getBytes("ISO-8859-1"), revision, length);