All Packages This Package Class Hierarchy Class Search Index
java.lang.Object | +----app.authkit.test.AuthTest | +----app.authkit.test.TestAuth
Summary |
public class TestAuth extends app.authkit.test.AuthTest { // Constructors 1 public TestAuth(); // Methods 2 public static void main(String[]); public void testAuth(Authorization, String, String[]); }
TestAuth is the Swiss Army Knife test for Authorization methods. It can call every method of Authorization in one way or another. It does this by acting as a simple command interpreter over its command-line args. Some of its commands are "builtins" that call the Authorization methods. Everything else is an external command, which is run with elevated privileges using the execPrivileged() method.
The command-line args form an interpretable sequence of strings consisting of:
The command parser is very simple, and works with the individual Strings of the String[] received by main(). Those Strings are not subdivided or otherwise parsed or manipulated. The interpreter simply breaks the sequence into groups, examines the first String of the group, and acts accordingly. For example, the grouping separator is ":", but it's only recognized in isolation. The interpreter will not recognize embedded :'s, nor will it subdivide commands or args at :'s.
A command grouping is separated from a subsequent grouping by a single isolated ":". Within a grouping, the first String is the command, and all other Strings are args for that command. A grouping may be empty, which is quietly ignored.
Builtins were named to minimize collisions with external commands on Mac OS X. The builtin commands and their args are:
Any command not recognized as a builtin is interpreted as an external command, and will be executed using execPrivileged(). Some pre-processing may occur first:
The reason for doing this is that "java.home" will reflect the JVM currently running, which may be 1.3.1 or 1.4.1 on Mac OS X, and execute that same JVM in another process. If you just entered the command "/usr/bin/java", it won't necessarily be the current JVM.
You can customize which command in "java.home" is executed by defining it as a relative pathname in the "auth.bin.java" property. Be sure to use a file-separator appropriate to your platform. The value should always be a partial pathname relative to the location given by "java.home".
All external commands are executed using execPrivileged(), so they all run with elevated privileges. This is unwise as a general approach, but is acceptable for a test.
If authorization is needed before running an external command, it is obtained interactively if necessary. Failure to authorize or authenticate will fail to run the external command.
On Mac OS X, all commands executed by execPrivileged() must be absolute pathnames. If you don't know the absolute pathname of a command, use the 'which' command in your shell to tell you the pathname of a particular command. For example, 'which java' or 'which id'.
The external command's stdout is piped to the System.out stream, and the bytes are counted and CRC'ed for comparison purposes. On Mac OS X, the stderr is simply shared with the privileged process.
If the Authorization's privileged Process implements waitFor(), the external command is waited for. Otherwise a 3-second delay occurs, then the interpreter resumes parsing and executing commands. Since MacOSXAuthorization's privileged Process doesn't provide waitFor(), long-running external commands may need a subsequent 'zzz' builtin command.
Before each command is executed, whether builtin or external, the Authorization's current public identifier is displayed on stdout. This is done to help track when sessions are created, attached, and detached. It's also useful to compare to public identifiers displayed by other processes that attach to the same session. The identifiers should be identical, even though from different processes.
Several system properties affect the TestAuth command interpreter:
Constructors |
· TestAuth | Summary | Top |
public TestAuth()
Create with default separator defined by "between" property, or ":".
Methods |
· main | Summary | Top |
public static void main(String[] args)
Static entry point, when used as an application.
· testAuth | Summary | Top |
public void testAuth(Authorization auth, String dontCare, String[] args)
Do the test over all the args. In this test, the args represent a series of command+parameters groupings. As a result, we DO NOT want to iterate using AuthTest.testAuth(), hence this override.
The groupings contain both external commands, which must have absolute pathnames, and builtin commands, which are performed by methods of this class. All external commands are executed using Authorization.execPrivileged().
- Overrides:
- testAuth in class AuthTest
All Packages This Package Class Hierarchy Class Search IndexFreshly brewed Java API Documentation automatically generated with polardoc Version 1.0.7