File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Sockets and Internet Protocols and the fly likes get Firewall configuration in JAVA Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "get Firewall configuration in JAVA" Watch "get Firewall configuration in JAVA" New topic

get Firewall configuration in JAVA

Mrutyunjay Hanchinal
Ranch Hand

Joined: Sep 26, 2001
Posts: 50
I am writing a java component that gets some files from a FTP server. If the FTP server is behind the firewall and FTP access is blocked in the forewall then the client needs to be intimated that the firewall is stopping files being downloaded.
So I think before connnecting to FTP server, if I get the info that accessing FTP server is not possible, then I can flash a message saying FTP server is behind the firewall and is not possible to connect.
So how do I go about it?
[ March 19, 2002: Message edited by: Mrutyunjay Hanchinal ]
Michael Ernest
High Plains Drifter

Joined: Oct 25, 2000
Posts: 7292

Moving this to Socket/Internet Protocols.

Make visible what, without you, might perhaps never have been seen.
- Robert Bresson
Guy Allard
Ranch Hand

Joined: Nov 24, 2000
Posts: 776
Hi - Two cases:
1) The wall permits no ftp whatsoever.
You should get the infamous 'connection refused' return when attempting to connect. However, you will get the same if the wall allows ftp but the ftp daemon is not started. I know of no way to tell the difference.
2) The wall allows passive ftp but not active (I hope I got those terms right and not backwards).
What will happen then, is the initial connect will work OK. But when a 'get' request is issued, the ftp daemon will switch modes and hence TCP/IP port numbers, via a negotiation with the client. It is possible to get 'connection refused' at this point! Again no real way to tell if passive/active is the real problem - maybe the daemon just crashed!

In the second case, I usually assume the wall is not configured correctly. However, it may be that a particular system would be configured to not allow 'get' requests, only 'dir' and such. Depends on the SA's objectives.
HTH (and I know it does not much), Good Luck, Guy
I agree. Here's the link:
subject: get Firewall configuration in JAVA
It's not a secret anymore!