List running Virtual Servers using JavaThe following code uses ZXTM's Control API to list all the running virtual servers on a cluster. The code is written in Java. listVS.java
import com.zeus.soap.zxtm._1_0.*;
import java.security.Security;
import java.security.KeyStore;
import java.security.Provider;
import java.security.cert.X509Certificate;
import javax.net.ssl.ManagerFactoryParameters;
import javax.net.ssl.TrustManager;
import javax.net.ssl.TrustManagerFactorySpi;
import javax.net.ssl.X509TrustManager;
public class listVS {
public static void main( String[] args ) {
// Install the all-trusting trust manager
Security.addProvider( new MyProvider() );
Security.setProperty( "ssl.TrustManagerFactory.algorithm", "TrustAllCertificates");
try {
VirtualServerLocator vsl = new VirtualServerLocator();
vsl.setVirtualServerPortEndpointAddress(
"https://username:password@host:9090/soap" );
VirtualServerPort vsp = vsl.getVirtualServerPort();
String[] vsnames = vsp.getVirtualServerNames();
boolean[] vsenabled = vsp.getEnabled( vsnames );
for( int i = 0; i < vsnames.length; i++ ){
if( vsenabled[i] ){
System.out.println( vsnames[i] );
}
}
} catch (Exception e) {
System.out.println( e.toString() );
}
}
/* The following code disables certificate checking.
* Use the Security.addProvider and Security.setProperty
* calls to enable it */
public static class MyProvider extends Provider {
public MyProvider() {
super( "MyProvider", 1.0, "Trust certificates" );
put( "TrustManagerFactory.TrustAllCertificates", MyTrustManagerFactory.class.getName() );
}
protected static class MyTrustManagerFactory extends TrustManagerFactorySpi {
public MyTrustManagerFactory() {}
protected void engineInit( KeyStore keystore ) {}
protected void engineInit(
ManagerFactoryParameters mgrparams ) {}
protected TrustManager[] engineGetTrustManagers() {
return new TrustManager[] { new MyX509TrustManager() };
}
}
protected static class MyX509TrustManager implements X509TrustManager {
public void checkClientTrusted( X509Certificate[] chain, String authType) {}
public void checkServerTrusted( X509Certificate[] chain, String authType) {}
public X509Certificate[] getAcceptedIssuers() { return null; }
}
}
}
NotesThe bulk of this code disables client certificate checking. Details of the code and surrounding infrastructure are at Running the exampleThis code works with the Java 1.5 SDK/JRE. To build and run the code, you'll need to do the following:
Owen Garrett
[Zeus Dev Team] 20 October 2005
|
Recent Articles
Other Resources
|


