Creating and Using Digitally Signed CAB Files
This article has four sections:
To see:
See the
To see the sample as a standalone
Overview of the sample
The CabAndSign sample demonstrates how the Cabinet
Development Kit and the Code Sign Kit are used to create
signed cabinet (CAB) files. Signed CAB files are required if
a Java applet is to use COM components.
About the server
BEEPER.DLL is a simple Automation server. It is one of the
samples from the ActiveX™ Template Library (ATL). You can
download ATL from the Web (www.microsoft.com/visualc/v42/atl/).
Beeper has two methods and one property of interest.
- In response to calling the Beep method, Beeper plays the
default system sound five out of six times. Every sixth call fails.
- The getItem method returns a String.
- The read-only Count property gives the number of different
strings getItem will return.
About the sample
javabeep creates a Beeper object (COM component). It calls the
Beep method of Beeper in response to mouseDown events. If the
call succeeds, Beeper plays the default system sound. javabeep
then calls getItem to get a series of strings from Beeper. It displays
the set of strings at the location of the mouseDown. If the
call fails (as it will every sixth time), no system sound occurs.
In response, javabeep places an error message at the location
of the mouseDown event.
See javabeep.start for creating the beeper COM component. See
javabeep.mouseDown for the calls to the beeper COM component
and handling the failure of the call to Beep. Use ClassView to
help you find these methods.
About security
COM components can access any system resources. As such, they
are both very powerful and potentially very dangerous. In the
Java virtual machine (VM) in Microsoft® Internet Explorer 3.0
only trusted class files can use COM components. Class files
from digitally signed CAB files are trusted.
If the HTML file is run from Microsoft Developer Studio, the
class files are also trusted. This can be very helpful during
applet development. However, to deliver your applet to
other users, you must put it in a signed CAB file.
The code for the applet itself is taken from the JavaBeep
sample. For more information on the Java code and the server,
see the JavaBeep sample.
Return to the top of this article.
How to use this sample
To run the CabAndSign sample:
- Register BEEPER.DLL, the COM component for this sample.
See Registering a COM Component.
- Create a Java interface for the COM component.
See Creating a Java Interface for a
COM component.
- In Explorer, double-click the WVTSTON.REG file to enable
test certificates on this machine.
- In Explorer, double-click the JAVABEEP.HTML file to open it.
To create your own CAB file and sign it:
- Create a CAB file with your CLASS files.
See Making Cabinets.
- Create a test certificate (this needs to be done only once).
See Creating a Test Certificate.
- Sign the CAB file with your certificate.
See Signing a Program File.
To use the .CLASS files from a CAB file:
- Add a parameter to the <APPLET> tag naming the CAB file.
For example:
<param name="cabbase" value="firstcab.cab">
Return to the top of this article.
Troubleshooting this sample
If you did not see the certificate:
- In Explorer, double-click the WVTSTON.REG file to enable
test certificates on this machine.
If you get the error message ClassNotFoundException:
If you get the error message UnsatisfiedLinkError:
Return to the top of this article.
Files in this sample
This sample includes the following files.
Primary files:
- javabeep.html - the HTML for the sample applet
- beeper.dll - the COM component
- firstcab.cab - the signed CAB file with the .CLASS file
- wvtston.reg - the registry file to enable test certificates
Project files:
- javabeep.java - the Java source code for the sample
- javabeepframe.java - the Java source code for the sample as
a standalone application
- cabandsign.mak - the project settings file
- cabandsign.mdp - the project file
- images\img00xx - the .GIF files for the spinning globe
Support files:
- javabeepframe.html - description of how to run the applet as
a standalone application
- cabandsign.html - an alternate project HTML file
- firstcab.ddf - the DDF file describing the CAB file
- readme.html - this read me file
- register.html - instructions for registering a COM component
- javatlb.html - instructions for creating a Java interface
for COM components
- cab.html - instructions for creating CAB files
- cert.html - instructions for creating a test certificate
- sign.html - instructions for signing a program file
Return to the top of this article.