Bug 49450

Summary: KeyStoreResolver always exhausted after first use
Product: Security - Now in JIRA Reporter: Clement Pellerin <Clement_Pellerin>
Component: EncryptionAssignee: XML Security Developers Mailing List <security-dev>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows NT   
Bug Depends on: 49447    
Bug Blocks:    
Attachments: proposed source code patch with junit

Description Clement Pellerin 2010-06-16 15:33:04 UTC
The KeyStoreResolver creates an iterator once and always returns the same iterator afterwards. After the iterator is traversed once, it will always appear empty. Even if the implementation would be changed to reset the alias enumeration to the beginning, the single iterator instance approach will never be thread-safe.

To reproduce, run the KeyStoreResolverTest in attachment.

The solution is to return a new iterator instance each time.
This patch is built on top of the patch found in Bug 49447.
This patch also fixes a bug with the NoSuchElementException that was introduced in the patch attached to 49447.
Comment 1 Clement Pellerin 2010-06-16 15:35:20 UTC
Created attachment 25600 [details]
proposed source code patch with junit
Comment 2 coheigea 2010-06-17 09:27:38 UTC
Patch applied, thanks. I modified it slightly so that the KeyStoreResolver checks the KeyStore in the constructor, and throws a StorageResolverException if there is a problem. This is for backwards compatiblity reasons.

Colm.