| ★ wanayoo — archive 1999 http://java.sun.com/security/signExample/ | Nouvelle recherche | Portail wanayoo |
Unfortunately the Java Development Kit (JDK TM) 1.1 signing and verification is not supported by the web browsers (NetscapeTM's and Microsoft's.) It is supported in HotJavaTM, http://java.sun.com/products/hotjava and appletviewer.
You can use the JavaTM Plug-in in the browsers to get access to more recent JDK technology, http://java.sun.com/products/plugin. You can run 1.1.x signed applets with the Plug-in plugged into the browsers.
We are working with the Java technology licensees to get the standard Java technology signing working for people in an interoperable way.
Full instructions for installing the Java Plug-in are on its download page. Briefly, on SolarisTM,
% chmod +x plugin-11-solaris2-sparc.bin
% /bin/sh plugin-11-solaris2-sparc.bin*
% mkdir -p ~/.netscape/java/lib
% touch ~/.netscape/java/lib/rt.jar
The mkdir and touch commands are needed to
workaround a known bug that will be fixed in the next release of the
Java Plug-in.
On Microsoft Windows, double-click on the file named plugin-11-win32.exe, and InstallShield will go through the installation.
Here's the source code for an applet that wants to do just that. It tries to write a file named /tmp/foo (or a file named "tmpfoo" if you're on a Microsoft Windows system.) This is not a malicious applet, but it is trying to do something that the Java Applet Security Manager prevents it from doing.
After you've installed the Plug-In, start the Plug-in Control Panel:
~/.netscape/java/ControlPanel
http://java.sun.com/security/signExample/pluginEx.html
from your browser.
On the pluginEx.html page, the applet display should read "writeFile: caught security exception." This is a good thing, and the expected behavior. A security exception doesn't mean that a security violation occurred - it means exactly the opposite. It means that the system caught the applet trying to escape the restrictions of the applet sandbox. To alert you to that fact, the system throws an exception. This is programmer terminology for "the system set off a warning bell." When you see a security exception on a Java technology-enabled system, you know that the system prevented the code from violating security.
Note that the Java Console should have displayed some output, including the location of the User home directory. This is important information that you should remember for the next step.
Here's the steps you need to take to accomplish that.
Duke.x509
% javakey -c Duke true
% javakey -ic Duke Duke.x509
http://java.sun.com/security/signExample/signedPluginEx.html
You might wonder, what does the HTML tag look like, for a signed archive loaded by a plugin? The HTML is complicated, but, you don't need to write this HTML by hand. When you downloaded the Java Plug-In, you also could download a tool called the Java Plug-In HTML Converter. It's very easy to run. Once you've installed it, go to the directory named HTML_Converter and invoke the simple GUI tool:
% HTMLConverter &Type in the name of the HTML file you need to convert so that it can be loaded by the Plug-In, and click on the "Convert" button.
That's all there is to it. For more details on the object HTML tag, see the Java Plug-in HTML Specification.
Once you've downloaded JDK 1.1.x and installed the software on your client, we're ready to go. Make sure that the JDK tools are accessible from your search path. We'll need to use these tools:
javakey, the tool for generating keys and signing archives
jar, the tool for creating an archive
appletviewer, a stripped-down browser for viewing the applet
Here's the source code for an applet that wants to do just that. It tries to write a file named /tmp/foo (or a file named "tmpfoo" if you're on a Microsoft Windows system.) This is not a malicious applet, but it is trying to do something that the Java Applet Security Manager prevents it from doing.
You can see what happens
when you try to run this applet by typing this command in a shell window (or in an
MS-DOS prompt window:)
% appletviewer http://java.sun.com/security/signExample/writeFile.html
You should see that the system throws a security exception. This is a
good thing, and the expected behavior. A security exception doesn't
mean that a security violation occurred - it means exactly the
opposite. It means that the system caught the applet trying to escape
the restrictions of the applet sandbox. To alert you to that fact,
the system threw an exception. This is programmer terminology for
"the system set off a warning bell." When you see a security
exception on a Java system, you know that the system prevented the
code from violating security.
Here's the steps you need to take to accomplish that.
Duke.x509
% javakey -c Duke true
% javakey -ic Duke Duke.x509
% appletviewer http://java.sun.com/security/signExample/signedWriteFile.html
You might wonder, what does the HTML tag look like, for a signed archive?
<applet code=writeFile.class archive="signedWriteFile.jar" width=500 height=50> </applet>That's all there is to it. You simply tell the browser the name of the archive, using the
archive= attribute. For more
details on the applet HTML tag, see the JAR
Guide.
doit: a script that creates a Duke identity, keys, certificate, then creates an archive and signs it. It prints out some diagnostic information, such as the contents of the signed archive, and the contents of the identity database.
Here's links to all the files used in this example.