View Source

h3.Security Code Samples


Java technologies include APIs for signing and verifying signed data, encrypting and decrypting data, and writing a security manager. A security manager is a Java virtual machine (JVM ^1^) object that implements a security policy such as prompting an end user for password verification. However, for export reasons, code for encrypting and decrypting data cannot be shown on the Web.

* [#Java Cryptography Extension (JCE)]
* [#Java Web Start and Security]
* [#Signing and Verifying Signed Data]
* [#Writing a Security Manager]

h5.Java Cryptography Extension (JCE)

* [EncryptTest|http://java.sun.com/developer/technicalArticles/Security/securitychange/#code1] demonstrates the JCE API by encrypting and decrypting a series of objects. For supporting information see [Exploring the Security Changes of the J2SE Platform|http://java.sun.com/developer/technicalArticles/Security/securitychange/].

* [JSSE|http://java.sun.com/developer/technicalArticles/Security/securitychange/#code2]demonstrates the JSSE library by reading a Web page through port 443, which is the HTTPS port. For supporting information see [Exploring the Security Changes of the J2SE Platform|http://java.sun.com/developer/technicalArticles/Security/securitychange/].

h5.Java Web Start and Security

* [writeFile.java|http://java.sun.com/developer/technicalArticles/JavaLP/javawebstart/#code1] shows how to run an applet securely with Java Web Start. For supporting information see [Java Web Start to the Rescue|http://java.sun.com/developer/technicalArticles/JavaLP/javawebstart/].

* [writeFile.java|http://java.sun.com/developer/technicalArticles/JavaLP/javawebstart/#code2] is another version of an applet that uses Java Network Launch Protocol (JNLP) to write to a user-selected file. The applet is run securely with Java Web Start. For supporting information see [Java Web Start to the Rescue|http://java.sun.com/developer/technicalArticles/JavaLP/javawebstart/].

h5.Signing and Verifying Signed Data

* [GenSig.java|http://java.sun.com/docs/books/tutorial/security/apisign/examples/GenSig.java] shows how to generate a digital signature on data.

* [VerSig.java|http://java.sun.com/docs/books/tutorial/security/apisign/examples/VerSig.java] shows how to verify a digital signature on data.

h5.Writing a Security Manager

* [FileIO.java|http://java.sun.com/developer/onlineTraining/Programming/JDCBook/Code/FileIO.java] has a security manager that prompts the end user to enter a password before it allows a read or write operation.

* [PasswordSecurityManager.java|http://java.sun.com/developer/onlineTraining/Programming/JDCBook/Code/PasswordSecurityManager.java] is the custom security manager for the [FileIO.java|http://java.sun.com/developer/onlineTraining/Programming/JDCBook/Code/FileIO.java] program.

----
^1^ As used on this web site, the terms Java virtual machine or JVM mean a virtual machine for the Java platform.
----

The individuals who post here are part of the extended Sun Microsystems community and they might not be employed or in any way formally affiliated with Sun Microsystems. The opinions expressed here are their own, are not necessarily reviewed in advance by anyone but the individual authors, and neither Sun nor any other party necessarily agrees with them.

Copyright 1994-2009 Sun Microsystems, Inc.
Powered by Atlassian Confluence
Sun Guidelines on Public Discourse Privacy Policy Terms of Use Trademarks Site Map Employment Investor Relations Contact