Constant width font
is used for:
Code examples
Class, variable, and method names within the text
Italicized font is used for:
Filenames
Host and domain names
URLs
When a new method or class is introduced, its definition will appear beginning with italicized text like this:
- public void checkAccess(Thread t)
Check whether the current thread is allowed to modify the state of the parameter thread.
There are some examples of commands scattered through the book, especially in sections and appendices that deal with administration. By convention, most examples are shown as they would be executed on a Unix system, e.g.:
piccolo% keytool -export -alias sdo -file /tmp/sdo.cer
Enter keystore password: ******
Certificate stored in file </tmp/sdo.cer>
In these examples, the text typed by the user or administrator is always shown in bold font; the remaining text is output from the command (the string piccolo% indicates a command prompt). On other systems, the names of the files would have to be changed to conform to that system (e.g., C:\sdo.cer for a Microsoft Windows system). Keep in mind, however, that the command-line arguments often specify a URL rather than a filename, in which case you must use forward slashes. In that case, the argument is often the same, although on Microsoft Windows systems you must specify a drive: the Unix directory file:///files/sdo/ is rendered on Microsoft Windows as file:/C:/files/sdo/. When an argument requires a URL, we always specify the protocol to distinguish it from a filename, even though tools will often accept the string without a protocol.
However, note that while Microsoft Windows systems often use a forward-slash (/) for command-line options, Java tools (even on those systems) universally use a hyphen (-) to indicate command-line options. In these examples, then, only the file and URL names are different between platforms.
The code examples in this book (and in the online samples) are organized by chapter. Each class belongs to a package based on the chapter when it is introduced; e.g., the class Test from Chapter 3, is in the package javasec.samples.ch03. When you unpack the online code, you’ll end up with a single directory (javasec), from which the remaining directories and source files descend.
There are two simple ways of proceeding. The first is to remain in the directory where you unpacked the sources, not set your classpath, and reference everything by full package name. Hence, to compile and run the Test class from Chapter 3, you’d execute these commands:
piccolo% javac javasec/samples/ch03/Test.java piccolo% java javasec.samples.ch03.Test Your account number is 0001 0002 0003 0004
Alternately, you can work in the directory containing the source and set your classpath as follows:
piccolo% javac -classpath ../../.. Test.java piccolo% java -classpath ../../.. javasec.samples.ch03.Test Your account number is 0001 0002 0003 0004
When required for space, commands may be continued on multiple lines, in which case a backslash character is used:
piccolo% java -classpath ../../.. javasec.samples.ch09.PrintCert \ /files/sdo/foo/bar/very/long/command
Commands that appear like this should be typed on one line or typed on multiple lines using whatever escape character is appropriate for your system (e.g., the backslash for a Unix system).
Get Java Security, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.