Previous | Next | Trail Map | Security in JDK 1.2  | Contents

Security in JDK 1.2

by Mary Dageforde

In this trail, you'll learn how the built-in JDKTM 1.2 security features protect you from malevolent programs. You'll see how to use tools to control access to resources, generate and check digital signatures, and create and manage keys needed for signature generation and checking. You'll also see how to incorporate cryptography services (such as digital signature generation and checking) into your programs.

Note: Nearly all the security features documented in this trail were added to the Java Development Kit (JDK) for its 1.2 release. Thus, the code examples in the following lessons will work only on Java platforms that are compatible with JDK version 1.2. Individual browsers may have some different behavior, unless you use the Java Plugin to download the latest Java Runtime Environment (JRE) compatible with JDK 1.2.

See Security in JDK 1.1(in the Learning the Java Language trail) if you want information about the limited Security API available in JDK 1.1.


Who Will Find the Security Features Useful

JDKTM 1.2 provides a number of security features for a wide variety of audiences:
  • For systems administrators, developers, and users:
    Tools for

    • managing your keystore (database of keys and certificates),

    • generating digital signatures for JAR (JavaTM Archive Format) files, and verifying the authenticity of such signatures and the integrity of the signed contents, and

    • creating and modifying the policy files that define your installation's security policy.

  • Trail Lessons

    Security Features Overview provides an overview of the security features available in JDK 1.2.

    Quick Tour of Controlling Applets gives a quick tour of some of the new features. It shows how resource accesses (such as reading or writing a file) are not permitted for applets unless explicitly allowed by a permission in a policy file.

    Quick Tour of Controlling Applications has the previous Quick Tour lesson as a pre-requisite. This second quick tour lesson applies to applications. It shows how resource accesses may be controlled exactly the same for applications as for applets, when the applications are run under a security manager.

    API and Tools Use for Secure Code and File Exchanges describes digital signatures, certificates, and keystores, and discusses why they are needed. It also provides overview information applicable to the next three lessons regarding the steps commonly needed for using the tools or the API to generate signatures, export/import certificates, etc.

    Signing Code and Granting It Permissions illustrates the use of all the security-related tools (jar, keytool, jarsigner , and policytool). It shows the steps that would be taken by a developer who wants to sign and distribute code for others to run. It also shows how someone who will run the code (or a sysadmin) could add an entry in a policy file granting the code permission for the resource accesses it needs

    Exchanging Files shows use of the tools by one party to sign an important document, such as a contract, and export the public key certificate for the public key corresponding to the private key used to sign the contract. Then it shows how another party, who receives the contract, the signature, and the public key certificate, can use keytool to import the certificate and the jarsigner tool to verify the signature.

    Generating and Verifying Signatures walks you step by step through an example of writing a Java program using the JDK Security API to generate keys, generate a digital signature for data using the private key, and export the public key and the signature to files. Then it shows writing a second program (which may be expected to run on a different person's computer) that imports the public key and verifies the authenticity of the signature. Finally, it discusses potential weaknesses of the approach used by the basic programs and demonstrates possible alternative approaches and methods of supplying and importing keys, including in certificates.

    Implementing Your Own Permission demonstrates how to write a class that defines its own special permission.

    Summaries provides summaries of

    For More Information

    The JDK 1.2 security release documentation can be found at http://java.sun.com/products/jdk/1.2/docs/guide/security/index.html. Here you'll find more detailed information about the security features, including architecture specifications, usage guides, API documentation, and tool documentation.

    Also check the JDK 1.2 security release documentation for information regarding security managers in JDK 1.2. For information about implementing your own security manager in JDK 1.1, refer to Providing Your Own Security Manager(in the Essential Java Classes trail).

    This trail does not cover encryption and decryption. These are supplied as part of the JCE (Java Cryptography Extension) release. You can find more information about this release here: http://java.sun.com/products/jdk/1.2/jce/index.html.

    Information on use of the Java Plugin to download the latest Java Runtime Environment compatible with JDK 1.2 can be found here: http://java.sun.com/products/plugin/index.html.



    This is a draft! Please send comments and suggestions on this trail to tutorial@java.sun.com. In your message, place security1.2 in the subject header. Your feedback is important to us!


    Previous | Next | Trail Map | Security in JDK 1.2  | Contents