Michael Z
Michael Z

Reputation: 3993

List all JNDI ports

Is that possible to find all open ports on my machine that were registered with JNDI ?

It would be good to find out some util from Ubuntu but Java code also will be OK.

UPDATE: After JSP's clarification I have revised my question.

Upvotes: 0

Views: 776

Answers (1)

Yair Zaslavsky
Yair Zaslavsky

Reputation: 4137

I would do the following:
A. Parse your application server configuration
- for example, for standalone configuration of Jboss AS 7.x ,
you should parse the standalone/configuration/standalone.xml B. Read the JNDI configuration from the XML, and understand what ports should be used.
C. Use

System.getRuntime().exec

In order to invoke netstat -na ,
filter out those ports who exist in the list obtained from A, and that are in ESTABLISHED state.

Some issues wiht my solution: A. As far as I know, According to Java EE spec, you should not execute process from a Java enterprise application.
To overcome this, you can have some j2se application running as service,
communication with the application server. B. I assumed that the server and the code that needs to know about the JNDI ports exist on the same machine.
If the code that needs to know the ports should be run on a different machine, you should expose this information to the client (i.e - via web UI, REST, etc...)

Upvotes: 1

Related Questions