~aishimoto/+junk/pdfbox-identity-h

« back to all changes in this revision

Viewing changes to src/main/java/org/apache/pdfbox/pdmodel/encryption/SecurityHandler.java

  • Committer: jukka
  • Date: 2010-02-20 18:30:41 UTC
  • Revision ID: svn-v4:13f79535-47bb-0310-9956-ffa450edef68:pdfbox/trunk:912181
PDFBOX-626: Reduce the memory impact of the COS object model

Use LinkedHashMap in COSDictionary instead of the previous HashMap + ArrayList approach.

Fix remaining generics warnings in org.apache.pdfbox.cos (and in some related classes)

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
import java.util.HashSet;
28
28
import java.util.Iterator;
29
29
import java.util.List;
 
30
import java.util.Map;
30
31
import java.util.Set;
31
32
 
32
33
import org.apache.pdfbox.cos.COSArray;
306
307
    private void decryptDictionary( COSDictionary dictionary, long objNum, long genNum )
307
308
        throws CryptographyException, IOException
308
309
    {
309
 
        Iterator keys = dictionary.keyList().iterator();
310
 
        while( keys.hasNext() )
 
310
        for( Map.Entry<COSName, COSBase> entry : dictionary.entrySet() )
311
311
        {
312
 
            COSName key = (COSName)keys.next();
313
 
            Object value = dictionary.getItem( key );
314
312
            //if we are a signature dictionary and contain a Contents entry then
315
313
            //we don't decrypt it.
316
 
            if( !(key.getName().equals( "Contents" ) &&
317
 
                  value instanceof COSString &&
 
314
            if( !(entry.getKey().getName().equals( "Contents" ) &&
 
315
                  entry.getValue() instanceof COSString &&
318
316
                  potentialSignatures.contains( dictionary )))
319
317
            {
320
 
                decrypt( value, objNum, genNum );
 
318
                decrypt( entry.getValue(), objNum, genNum );
321
319
            }
322
320
        }
323
321
    }