The JAAS OSGi config login modules leverages the OSGi Config Admin Service to store user data. This login module is fairly similar to the JAAS properties login module (for example, the syntax of the user entries is the same), but the mechanism for retrieving user data is based on the OSGi Config Admin Service.
The user data can be edited directly by creating a corresponding OSGi configuration
file, etc/ or using any method of
configuration that is supported by the OSGi Config Admin Service. The PersistentID.cfgjaas:*
console commands are not supported, however.
The JAAS OSGi config login module authenticates username/password credentials, returning the list of roles associated with the authenticated user.
The following classes implement the JAAS OSGi config login module:
org.apache.karaf.jaas.modules.osgi.OsgiConfigLoginModuleImplements the JAAS login module.
![]() | Note |
|---|---|
There is no backing engine factory for the OSGi config login module, which means that
this module cannot be managed using the |
The JAAS OSGi config login module supports the following options:
pidThe persistent ID of the OSGi configuration containing the user data. In the OSGi Config Admin standard, a persistent ID references a set of related configuration properties.
The location of the configuration file follows the usual convention where the
configuration for the persistent ID, ,
is stored in the following file:PersistentID
InstallDir/etc/PersistentID.cfg
The configuration file is used
to store username, password, and role data for the OSGi config login module. Each user is
represented by a single line in the configuration file, where a line has the following
form:PersistentID.cfg
Username=Password[,Role][,Role]...
This is the same format that is used in a users property file.
The following Blueprint configuration shows how to define a new karaf realm
using the OSGi config login module, where the default karaf realm is overridden
by setting the rank attribute to 2:
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:jaas="http://karaf.apache.org/xmlns/jaas/v1.0.0"
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0">
<jaas:config name="karaf" rank="2">
<jaas:module className="org.apache.karaf.jaas.modules.osgi.OsgiConfigLoginModule"
flags="required">
pid = org.fusesource.example.osgiconfigloginmodule
</jaas:module>
</jaas:config>
</blueprint>In this example, the user data will be stored in the file,
,
and it is not possible to edit the configuration using the InstallDir/etc/org.fusesource.example.osgiconfigloginmodule.cfgjaas:* console
commands.






![[Note]](imagesdb/note.gif)


