package extjtech; import java.io.*; import java.util.*; import com.sssw.rt.util.*; import com.sssw.rts.adminclient.*; import com.sssw.rts.adminapi.*; // The ExtAdmin class shows how you can access a SilverStream // server from an external Java client. It includes an example // of performing administrative operations on the server from // the client. public class ExtAdmin { // Instance variable for the SilverStream server session // object used by the ExtAdmin class. AgrServerSession session; // Constructor for the ExtAdmin class. It does the following: // * Connects to a SilverStream server // * Gets a reference to that server for doing administration // work // * Generates a report about the server's users and groups // // It takes 1 argument: // * SilverStream server host // myserver public ExtAdmin(String s3serverhost) { try { // Initialize the SilverStream runtime environment. Do // this if you need to specify a login handler for the // SilverStream server to call back when it requires user // authentication. (The login handler is a class that you // code and instantiate.) AgRuntime.init(new LoginHandler()); // Connect to the appropriate SilverStream server. This // establishes a server session (represented by an instance // of AgrServerSession). // // The following example connects via HTTP. In this case, // you wouldn't use RMI-IIOP (the connectRMI method), // because it doesn't support the Server Administration // API. session = AgRuntime.connect(s3serverhost); // Get a reference to the server (represented by an instance // of AgiAdmServer) that enables you to perform administration // tasks. AgiAdmServer admserver = AgAdmin.getServer(session); // Generate a report about the server's Silver Security // realm that lists: // * Each user // * All of the groups each user is in // Local variables for user and group information. AgiAdmDirectory userdir; Enumeration users; AgiAdmUser user; Enumeration groups; AgiAdmGroup group; // Get a reference to the directory of users in the Silver // Security realm. userdir = (AgiAdmDirectory)admserver.getElement( AgiAdmDirectory.SILVERUSERS, AgiAdmDirectory.SILVERUSERS, null); // Get a sorted list of the users in that directory. users = userdir.getChildren(AgiAdmContainer.GET_CHILDREN_SORTED); // Print the report title. System.out.println(">>>Silver Security"); System.out.println(" >>>Users"); // Loop through the user list. while (users.hasMoreElements()) { // Get and print information about an individual user. user = (AgiAdmUser)users.nextElement(); System.out.println(" Name: " + user.getName()); System.out.println(" Groups:"); // Get a sorted list of the groups for the current user. groups = user.getGroups(true); // Loop through the group list. while (groups.hasMoreElements()) { // Get and print information about an individual group. group = (AgiAdmGroup)groups.nextElement(); System.out.println(" " + group.getName()); } System.out.println(); } System.out.println("<<