O'Reilly logo

Java Servlet & JSP Cookbook by Bruce W. Perry

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

15.7. Creating the JAAS Configuration File

Problem

You want to create the JAAS configuration file.

Solution

Create the configuration file, then specify the configuration's location on your filesystem in the ${java.home}/jre/lib/security/java.security file.

Discussion

Using JAAS also involves writing a configuration file to identify the LoginModule(s) that a particular application will use. The configuration file in Example 15-11 specifies an application named "WebLogin."

Example 15-11. A JAAS configuration file

WebLogin {
   com.jspservletcookbook.DataSourceLoginModule requisite;
};

Although only one module is specified in this recipe, one of the powerful features of the JAAS security design is to use multiple LoginModules or layers in order to authenticate users. A user might have to be authenticated in several ways before she gains access to web components and data (e.g., first her irises are scanned, then she must specify a username and password).

The configuration file specifies:

  • The fully qualified class name of the LoginModule(s).

  • A "Flag" value, which is just a constant expression such as "required" or "requisite." The example uses "requisite." Table 15-1 describes the different Flag values.

  • One or more "options" (Example 15-11 does not identify any options). The options represent a space-separated list of name/value pairs, such as debug="true" (you can use any name/value pairing you want). The options allow the configuration file to pass properties and values to the underlying LoginModule ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required