Bug 49450 - KeyStoreResolver always exhausted after first use
KeyStoreResolver always exhausted after first use
Status: RESOLVED FIXED
Product: Security - Now in JIRA
Classification: Unclassified
Component: Encryption
unspecified
PC Windows NT
: P2 normal
: ---
Assigned To: XML Security Developers Mailing List
:
Depends on: 49447
Blocks:
  Show dependency tree
 
Reported: 2010-06-16 15:33 UTC by Clement Pellerin
Modified: 2010-06-17 09:27 UTC (History)
0 users



Attachments
proposed source code patch with junit (5.45 KB, patch)
2010-06-16 15:35 UTC, Clement Pellerin
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.