throw new IOException(e);
}
}
else
{
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 )
{
MessageDigest md = MessageDigests.getMD5();
BigInteger time = BigInteger.valueOf( System.currentTimeMillis() );
md.update( time.toByteArray() );
md.update( ownerPassword.getBytes("ISO-8859-1") );
md.update( userPassword.getBytes("ISO-8859-1") );
md.update( document.getDocument().toString().getBytes() );
byte[] id = md.digest( this.toString().getBytes("ISO-8859-1") );
COSString idString = new COSString();
idString.append( id );
idArray = new COSArray();
idArray.add( idString );
idArray.add( idString );
document.getDocument().setDocumentID( idArray );
}
COSString id = (COSString)idArray.getObject( 0 );
byte[] ownerBytes = computeOwnerPassword(
ownerPassword.getBytes("ISO-8859-1"),
userPassword.getBytes("ISO-8859-1"), revision, length);