Step 7: Test Use of the LoginModule
Finally, test your application and its use of the LoginModule.
When you run the application, specify the login configuration file
to be used. For example, suppose your application is named MyApp,
it is located in MyApp.jar, and your configuration
file is test.conf. You could run the application
and specify the configuration file via the following:
java -classpath MyApp.jar
-Djava.security.auth.login.config=test.conf MyApp
Type all that on one line. Multiple lines are used here for legibility.
To specify a policy file named my.policy and run
the application with a security manager installed, do the following:
java -classpath MyApp.jar -Djava.security.manager
-Djava.security.policy=my.policy
-Djava.security.auth.login.config=test.conf MyApp
Again, type all that on one line.
You may want to configure the LoginModule with
a debug option to help ensure that it is working correctly.
Debug your code and continue testing as needed. If you have problems, review the previous steps and ensure they are all completed.
Be sure to vary user input and the LoginModule options
specified in the configuration file.
Be sure to also include testing using different installation options
(e.g., making the LoginModule an installed extension
or placing it on the class path) and execution environments (with
or without a security manager running). Installation options are discussed
in Step 6b.
In particular, to ensure your LoginModule works
when a security manager is installed and the LoginModule and
application are not installed extensions, you need to test such an
installation and execution environment, after granting required permissions,
as described in Step
6c.
If you find during testing that your LoginModule or
application needs modifications, make the modifications, recompile
(Step 5), place
the updated code in a JAR file (Step 6a), re-install
the JAR file (Step
6b), if needed fix or add to the permissions (Step 6c), if needed
modify the login configuration file (Step 6d), and then
re-run the application and repeat these steps as needed.