Fix and improve redirect to original URL.

Updating logic for the final redirect to the original URL to work similarly to the logic found in the Tomcat Form Authenticator.  This update fixes IllegalStateException errors during the redirect, and also adds support for POST operations being the initial request to a protected resource.

See this thread for more information: https://community.jboss.org/thread/200615