|
Security is an important aspect of programming these days. As applications get distributed around the Net piecemeal, those application pieces need to protect the parts of their underlying framework that were once assumed to be built into the main application. Along with these changes, the underlying Java 2 platform release has evolved to incorporate more and more features into the J2SE release 1.4 to provide a secure environment to execute mobile code.
With this latest 1.4 release, you'll find many enhancements in the security architecture. Several features that were previously available separately are now part of the core API set. These include support for encryption and decryption with the Java Cryptography Extension (JCE), support for Secure Sockets Layer (SSL) and Transport Layer Security (TLS) protocols with the Java Secure Socket Extension (JSSE), and support for user-based authentication and access controls with the Java Authentication and Authorization Service (JAAS). In addition to the inclusion of these previously optional packages, you'll find new support for building and verifying certificate chains with the Java Certification Path API and support for the Kerberos V5 mechanism under Java GSS-API and JAAS. Additional enhancements were made in improving the security policy-managing tool, The following sections introduce all these features and examine them in more detail. Java Cryptography ExtensionWithin the libraries of the Java Cryptography Extension (JCE), you'll find support for encryption, decryption, key agreement, Message Authentication Code (MAC), and some other cryptographic services. Due to import control restrictions of some countries, the JCE jurisdiction policy files shipped with the Java 2 SDK, release 1.4 allow "strong" but limited cryptography to be used. An "unlimited strength" version of these files indicating no restrictions on cryptographic strengths is available for those living in eligible countries (most countries). You can download this version and replace the string cryptography versions supplied with the Java 2 SDK, release 1.4 with the unlimited ones.
Found in the To demonstrate the JCE API, the following program encrypts a series of objects and decrypts them back. The example uses the Data Encryption Standard (DES) as the encryption algorithm. For a complete list of supported algorithms, see the Java Cryptography Extension (JCE) Reference Guide. Code Sample 1: Demonstrating the JCE API by encrypting and decrypting a series of objects
Java Secure Socket ExtensionNext up comes the Java Secure Socket Extension (JSSE) library. Here, you'll find support for communicating using the Secure Sockets Layer (SSL) and Transport Layer Security (TLS) protocols. Where the JCE operates on specific local data structures, the JSSE uses a different abstraction, applying encryption/decryption to network socket traffic. It adds server authentication, message integrity, and optional client authentication. Most people think of SSL and TLS as the secure HTTP protocol, better known as HTTPS.
The JSSE library lives in the SSL (and thus HTTPS) permits encrypted traffic to be exchanged between the client and server. After an SSL client initiates a conversation with an SSL server, the server sends an X.509 certificate back to the client for authentication. The client then checks the validity of the certificate. Assuming the server is verified, the client generates a premaster secret key, encrypts it with the server's public key from the certificate, and sends the encrypted key back to the server. From this premaster key, the client and server generate a master key for the session. After some basic handshaking, the encrypted exchange can commence.
The JSSE library hides these inner workings of the SSL protocol from you. Just work with the
The following example demonstrates the use of the JSSE library. It reads a web page using SSL. Even though the Code Sample 2: Demonstrating the use of the JSSE library by reading a Web page through port 443, the HTTPS port
In the case of creating a server instead of a client, you would get a
Also note that the JSSE libraries found in the J2SE version 1.4 release are not the same as those still available as the JSSE 1.0.2 release. For instance, the Java Authentication and Authorization Service
Third up is Java Authentication and Authorization Service (JAAS). Starting in A complete example for the JAAS is a little more involved than the other APIs due to the need to modify security policies. You can find a detailed tutorial and sample program in the JAAS reference guide.
Essentially, here is how everything works. Authentication is done through a
JAAS also supports authorization. A systemwide access control policy, represented by the Java GSS-APIThe Java GSS-API (Generic Security Service) adds Kerberos V5 support to the Java platform. If you're not familiar with Kerberos, this is something that originated at the Massachusetts Institute of Technology (MIT) as project Athena back in 1987. Essentially, Kerberos is a network authentication protocol. Defined in RFC 1510 from 1993, the authentication service's biggest draw is not having to send passwords over the net. It offers single sign-on within one domain -- if everything within the domain has been Kerberos-enabled. Support is also provided for single sign-on across different security realms over a network. Used in conjunction with JAAS, once a user's identity is established, future authentication requests are no longer necessary.
Using Kerberos on your desktop requires a Kerberos Key distribution server to be available. If you don't have a Kerberos realm available, you cannot use this aspect of the Java 2 platform, version 1.4 security API. Found in the Java Certification Path APILast is the fifth of the now standard libraries, and the second completely new library. The Java Certification Path API provides classes for building and validating certificate chains, an important requirement of a Public Key Infrastructure (PKI). These certificates provide for the storage of security keys for users. By trusting the issuer of a certificate that holds the keys, and trusting the issuer of the certificate that trusts the original certificate, you establish chains of trust. By following this certificate path chain, you eventually either end up with a certificate issued by a Certification Authority (CA) that you trust or a certificate issued by a CA that you don't trust. Thus, the relying party can ensure a subject's public key is genuine and trusted based on the trustworthiness of the underlying certificate chain.
Found in the And the Rest
Not all security-related changes are as big as the five previously mentioned libraries. The biggest changes here have to do with the Conclusion
J2SE version 1.4 adds many security-related capabilities to the standard Java 2 platform release. With these newly incorporated features, the execution of mobile code is more secure as it becomes unnecessary to require users to install the previously optional services. You no longer have to worry about adding in additional libraries for users to communicate securely. In addition, with new features like the crypto-chain validation, verification of paths is no longer implementation specific. One can only wonder what's
in store for version 1.5.
For More Information
About the AuthorJohn Zukowski conducts strategic Java consulting with JZ Ventures, Inc. His latest books are Learn Java with JBuilder 6 from Apress and Mastering Java 2, J2SE v. 1.4 from Sybex. Contact John at jaz@zukowski.net. | ||||||||||
|
| ||||||||||||