The cause and effect of accesscontrolexception

Source: Internet
Author: User



in the applets in the project , always meet java.security.AccessControlException: this type of exception .

to summarize here applets situations and workarounds that are encountered with these anomalies .

A cause

This exception is caused by the security of Java .

applets code that belongs to the page load,so the security level is limited.,Which means,a lot of things,not granted by some specific permission,they can't do it..The following are prohibited operations:

       Cannot access local file Span style= "font-family: Arial" > cannot read or write to Shenzhen cannot get information about files ( is there a , Modified date )

Cannot access any memory address

Cannot print document

other programs that cannot start the client , Which means no execution . system.exec () or runtime.exec ()

cannot get system parameters , System.getproperty (), It's even more impossible to set the system properties.

cannot define or use classloader,securitymanager,content-handlerfactory,socketimplfactory or urlstreamhandlerfactory a new instance of , must be an already existing instance .

cannot build except to load this applets links outside the host , That is, you can only load this applets the host

While these restrictions are somewhat relaxing for digitally signed code, sometimes

Two Fruits

the solution is that you add all of these operations to a privileged class , indicating that these operations are privileged .

     Accesscontroller.doprivileged (New Privilegedaction () {public            Object run () {                  //Privileged code goes here, for ex Ample:                   system.getproperty (...) returnnull;//nothing to                   return           }      );

The cause and effect of accesscontrolexception

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.