File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Sockets and Internet Protocols and the fly likes Pass on HTTP request to external server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Pass on HTTP request to external server" Watch "Pass on HTTP request to external server" New topic
Author

Pass on HTTP request to external server

Laurence Prescott
Greenhorn

Joined: Mar 25, 2011
Posts: 2
We are trying to work out how to pass on a request to an external server and catch the response in code.
The situation is this:
Most users need authenticating against AD, but some we'll handle differently.
Our server doesn't have access into our corporate domain so can't authenticate users against Active Directory.
We have been supplied with an aspx page on another server that will do this authentication then redirect the client back to our server with their username in the query string.
Currently we check any new requests, and if we have not yet authenticated the user we use a response.sendRedirect() call to pass them on to the authenticating server.

The problem is this: if the authenticating server's authentication fails, it sends a message back to the client that makes no sense to the user and they can't access our web site. In this case we'd like to handle this (failed) user differently, but have no way of knowing of the authentication failure.
So basically we would like to pass on the original request to the authenticating server and catch the response.
If the response is an authentication challenge we need to pass this back to the client (to facilitate the authorization mechanism).
If the response is a redirection back to our server we know the user is okay and can serve them what they need.
If the response is the failure message we want to do something else.

Is this possible or is it not allowed due to security risks.

We are running Tomcat5 on Windows 2000 Server.

Thanks,
Howd
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61199
    
  66

You can use the classes in java.net (notably URL and URLConnection) or a library such as HttpClient.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19693
    
  20

And welcome to the Ranch!


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Laurence Prescott
Greenhorn

Joined: Mar 25, 2011
Posts: 2
Bear and Rob,
Greetings and thanks for the welcome.
Sorry about the slow response (how rude!).
I've was pulled of this task for the moment but will let you know any results I achieve.

Nice to be part of the ranch.
Howd
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Pass on HTTP request to external server