Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Overriding the Security Sandbox in Java Applets

Status
Not open for further replies.

BZJavaInst

Programmer
Jan 17, 2001
67
US
Has anyone created an Applet that would allow Java code to execute around the Sand Box security? Here is an example I found, but it only works with the Microsoft SDK for Java 4.0. That is where I find the Microsoft com.ms.Security package. My users are running on a Intranet and we would like to get the system properties of the machine they are running the applet on. For ex. the computer user name. They are using MS. IE. and I am looking for a way to write a Java program using Suns Java 2 and override the Security as this example shows with Microsoft's SDK. Has anyone done something like this with Pure Sun Java?

MS Java CODE:

/* 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.*; //* microsoft package
import java.awt.*;
import java.applet.*;
import java.io.* ;
import java.util.*;
import netscape.security.PrivilegeManager; //* netscape pk

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") ;
}

}

Can anyone help? I would really appreciate it.
Thanks, Brian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top