Wrapplet

Wrapplet (the Wrapper Applet) is a Java 1.1 compatible applet that acts as a 'host' for other 'guest' applets.

Features

Wrapplet features include:
  1. Providing a number of improvements over standard applet methods.
  2. Allows guest applet(s) to be configured by URL. Note that the URL parameters then apply to any applets on the page that are embedded in a Wrapplet. Properties that were private to an applet instance, now become shared across all guest applets that allow for query based parameters.
  3. Provides version checking for guest applets, with fall-back. The fall-back options include:
    • Inbuilt Label message.
    • Adding another applet. This applet might..
      • Put a customized 'version too low' message.
      • Put a customized 'version too low' message, with help (redirect) button.
      • Pop a warning dialog (for an applet that has very small WxH).
      • Put a lesser version of the original applet (e.g. AWT rather than Swing).
      • Redirect to another page.
  4. Allows the guest applet to be 'floated' by user choice.

Version History

  • 2008-08-03. 0.1. First official form of Wrapplet released. Test & demo pages tidied and expanded. Two downloadable Zip files were added. The first contains the entire file set of deployment jars, test/demo jars, and the pages that tie them all together and describe them (the pages you see on the pscode.org site, without the menus or stylesheets). The second archive contains only the deployment related binaries (jar files).
  • 2008-08-01. 0.1-beta. The working files were released to answer a question on the Sun forums.

Changes to applet methods

Change applet methods..

  • showDocument(URL) falls back to JS redirect. A number of problems have been observed in using the standard applet method to redirect (i.e. it fails without warning), so we add this secondary method to back it up.
  • The standard getDocumentBase() method sometimes returns the full URL with query parameters, but usually trims the query parameters. We have yet to figure the exact circumstances that determine which it will be, so we revert to using a JS based method to retrieve the entire URL reliably.
  • getParameter(String) usually returns only parameters defined within the applet element that invoked the applet, but by choice at deployment time, we can specify to allow parameters in the applet element to be changed by the equivalent parameter in the URL's query fragment.

These improvements rely on hooking into the JSObject (by adding the MAYSCRIPT flag to the applet element), which provides:

  • Redirects (fall-back)
  • Full URL (including query).

Download

  • wrapplet-demo.zip contains the deployment files, along with the web pages that demonstrate them, and the 'test' and 'demo' jars used specifically for those demos.
  • wrapplet-deploy.zip contains only the jars required for deployment.

Note that both downloads are for the sandboxed version only. The trusted version of Wrapplet will not work on other sites in its current form (Wrapplet will only remove the SecurityManager if the host is either a local server, or pscode.org).

To get a version that is built for a different site, contact the author.

Security

If trusted applet code loads other code using Class.forName() in the way Wrapplet does, the other code does not normally gain the extended priviliges, even if it is signed.

We might implement a custom security manager and set it to handle the security for the guest code, but since this was intended as a light applet, it was decided to take the simpler route of calling System.setSecurityManager(null) - which wipes out all security checks.

Using this approach, even unsigned code might be loaded by Wrapplet and given full permissions. While we are OK with doing this on the PSCode home site, since we control all the applets subsequently loaded, we are not prepared to extend that trust to other sites - not using code digitally signed by us.

As a result of that decision, Wrapplet will only attempt to disable the security manager if it is loaded from the local host, or pscode.org. Applets hosted by Wrapplet on other sites, will remain sandboxed even if they are properly digitally signed.

The author of Wrapplet can supply a binary* (and sample build file to digitally sign the code), suitable for use on other sites. * Compiled using the -bootclasspath compilation option, to guarantee the binary is Java 1.1 compatible.

See Also

  • The Wrapplet demo shows the applet deployed with a variety of options. The demos use TestApplet as the guest applet.
  • The Swing based TestApplet demo (plain, with no - Wrapplet wrapper)
  • URLTransformer demo shows the transformations that are currently supported. Note that while the URLTransformer class itself is designed for Java 1.1, we use a Swing based JTable to represent the transforms.
  • MessageDialog demo. An AWT based, Java 1.1 compatible JOptionPane style dialog.
  • JumpButton demo. The recommended way to handle 'version too low'. It does not 'break the back button' in the way that the VersionCheck does, but instead leaves any redirection to user action (clicking the button).
  • VersionCheck applet. VersionCheck could be used as a complete alternative to wrapping the applet in Wrapplet, or as the 'fallbackApplet' to load in case of a Java version too low to run the main applet.
© 2003-2011 by Andrew Thompson. All rights reserved.
Web hosting compliments of Java Web Hosting.
Java Web Hosting