Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 5038176
Votes 0
Synopsis security policy runtime settings not working for applets
Category java_plugin:misc
Reported Against 1.4.2_04
Release Fixed
State 11-Closed, Not a Defect, bug
Priority: 1-Very High
Related Bugs 4745222
Submit Date 27-APR-2004
Description
The customer upgraded to 1.4.2_04 since a z-order panel switching problem has been fixed here.
But their application does not seem to be working any more.The runtime settings are not taking effect.
The Runtime permissions set using the .java.policy are not found to be taking effect. The error
received in java console is
[java.security.AccessControlException: access denied
(javax.security.auth.AuthPermission createLoginContext)]

The policy file for the application has
  permission javax.security.auth.AuthPermission "createLoginContext";

Attached is a sample applet which needs a run time permission and
property permission. Steps to be followed are

1. Extract the zip file
2. Put the html and jar files in any web server 
3. Edit the machine name and port number in .java.policy file
4. Add/Modify the policy file in your user_home/java_home directory
5. Access TestApplet.html in IE where j2re1.4.0_04 plugin is installed
6. Click on Test button.

You can see that the property permissions are granted whereas the
runtime permission is not.
  xxxxx@xxxxx   2004-04-27
  xxxxx@xxxxx   2004-04-27
  xxxxx@xxxxx   2004-04-29
Work Around
N/A
Evaluation
This is because of introducing security restrcitions for JavaScript->Java calls. Since we cannot verify the origin of JavaScript, the Java code called from the JavaScript is not considered to be from the same codebase. Hence the permissions granted for the applet codebase in java.policy file is not honored in JS->Java call

It should work fine if you change the java.policy file to grant the required permissions to all the codebases, for example
grant {
};

  xxxxx@xxxxx   2004-04-27

I discussed this with security team and found that the customer could resolve this issue by having doPrivliged blocks in the Java code called by JavaScript. In this case the Java code could be given the appropriate permissions either by signing the applet or adding permissions in java.policy file

Sample code:
void m() {
	AccessController.doPrivileged( new PrivilegedExceptionAction() {
		public Object run() {
			//Do actions that require permissions
		}
	});
}

  xxxxx@xxxxx   2004-05-06
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang