M. Gallant 01/08/2001
import java.util.Properties; class props { static public void main(String args[]){ Properties props; props = System.getProperties(); props.list(System.out); } }
/* class SignedParm2 displays in textarea the system parameters. designed to run as signed applet in both Communicator 4+ and IE4+ web browsers. Since the applet runs it's privileged method in the init() method, IE code must explicitly assert permissions here. M. Gallant 11/04/1999 */ import com.ms.security.*; import java.awt.*; import java.applet.*; import java.io.* ; import java.util.*; import netscape.security.PrivilegeManager; public class SignedParm2 extends Applet { FontMetrics fm; int xtab, ystep ; String nl ; // new line character String[] graphString = new String[20] ; int strings = 0; TextArea ta = new TextArea (25, 80); public void init() { try { if (Class.forName("com.ms.security.PolicyEngine") != null) { // required for IE PolicyEngine.assertPermission(PermissionID.PROPERTY); } } catch (Throwable cnfe) { } this.setBackground(new Color(192,192,192)) ; add(ta) ; try{ PrivilegeManager.enablePrivilege("UniversalPropertyWrite") ; // required for NN } catch(Exception cnfe) { System.out.println("netscape.security.PrivilegeManager class not found") ; } Properties sysprops = System.getProperties() ; Enumeration enprop = sysprops.propertyNames() ; String str = "" ; ta.setText("") ; while ( enprop.hasMoreElements() ) { String key = (String) enprop.nextElement() ; // System.out.println(key+"\t"+sysprops.getProperty(key)); str = key+"\t"+sysprops.getProperty(key) ; ta.append(str + "\n"); } // PrivilegeManager.disablePrivilege("UniversalPropertyWrite") ; } }An alternate approach for browsers using the JavaPlugin1.2 and the JRE1.2 makes use of a local policy file to specify file-grained privileges. This approach can grant the privileges even without code-signing. An example of this approach (requires policy file modification) is available at: http://204.191.136.6/~neutron/signedparmj2/
import java.io.*; import javax.servlet.*; import java.util.Properties; import java.util.Enumeration; public class javasysprops extends GenericServlet { public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException { res.setContentType("text/plain"); Properties props; props = System.getProperties(); //get server JVM properties PrintWriter out = res.getWriter(); out.println("-------- Server Java System properties ---------------") ; out.println(" M. Gallant 02/99\n") ; if(req.getParameter("long")!=null){ out.println(" (long form listing)") ; Enumeration enprop = props.propertyNames() ; String key = ""; while ( enprop.hasMoreElements() ){ key = (String) enprop.nextElement() ; out.println(key+"\t"+props.getProperty(key)) ; } out.close(); return; } props.list(out); // abbreviated listing is default. out.close(); } }