Fix for OPENAM-2519, review via IM with PM and JS.

git-svn-id: https://svn.forgerock.org/openam/trunk/openam@5643 0f4defcf-c51a-4c67-9f44-6fb5eba73c5d
OpenAM-2611 CR-1917

git-svn-id: https://svn.forgerock.org/openam/trunk/openam@5644 0f4defcf-c51a-4c67-9f44-6fb5eba73c5d