fixed for endpoint cookie handling

* domain is correctly retrieved for endpoint urls having subpaths

i.e. developerworks connections
* added support to authentication redirects and token failure modes

a redirect can be defined now to handle issuing token to users,
the redirect should then redirect back to the app
if no redirect is defined it throws an exception, Java can handle it
* now retrieves raw cookie value to resolve problem with escaping

servlet container was stripping escaping and breaking auth for some.