en.help.task-createcustomrealm.html Maven / Gradle / Ivy
To Create a Custom Realm
In addition to the three built-in realms, you can also create custom realms
that store user data in some other way, such as in a
relational database. Development of a custom realm is outside the scope of this
document. For more information, see Chapter 5, Securing Applications, in Oracle GlassFish Server 3.0.1 Application Development Guide.
For administration purposes, custom realms are implemented by a class (called the LoginModule)
derived from the Java Authentication and Authorization Service (JAAS) package.
- Follow the procedure in To Create a Realm, typing the name of the custom realm
and the name of the LoginModule class.
Use any unique name for the custom realm, for example myCustomRealm.
- Click OK.
- Edit the domain's login configuration file, domain-dir/config/login.conf, and add the fully qualified
class name of the JAAS LoginModule at the end of the file,
as follows:
realmName {
fully-qualified-LoginModule-classname required;
};
For example,
myCustomRealm {
com.foo.bar.security.customrealm.simpleCustomLoginModule required;
};
- Copy the LoginModule class and all dependent classes into the directory domain-dir/lib/classes.
- Restart the server if Restart Required appears in the Administration Console.
- Ensure that the realm is properly loaded.
Check domain-dir/logs/server.log to ensure that the server loaded the realm. The server
should invoke the realm’s init method.
See Also