Hi All,

  I am working on a project were we are trying to prototype the
exposure  of some of Jaas functionality in an OSGi way. For the
authentication part, the requirement was the following:
  - You should be able to authenticate users using the current Jaas mechanism
    e.g.
    LoginContext ls = new LoginContext(name,...);
    lc.login();
  - There has to be a mechasnism to define new LoginModule(s) and bind
a new AppConfigurationEntry[] to a login context name.
  - There should be a mechanism to bind a LoginModule to a realm.
  - There should be a mechanism to define new realms.

The approach was the following:
  - Bundle 1:
    . Defines an interface so new bundles can define a new
AppConfigurationEntry[] and bind it to a name (defining a new OSGi
service).
    . Defines the interface for a realm.
    . Overrides the default Configuration with a new implementation
that looks for the service that specifies an AppConfigurationEntry[]
for a given name.
  - Bundle 2:
    . Implements a new LoginModule, the binding of this LoginModule is
done using the configuration admin service.
    . Specifies a new AppConfigurationEntry[] (this may be done in
another bundle).
  - Bundle 3:
    . Defines the realm
  - Bundle 4
    . Performs the login.


Now LoginContext performs the following to load the LoginModule
(slightly simplified)
contextClassLoader = Thread.currentThread().getContextClassLoader()
c = Class.forName(loginModuleName, true, contextClassLoader);
constructor = c.getConstructor(...);
module = constructor.newInstance(...);

So, to make this work, we need to force Bundle 4 (and every bundle
that performs a login) to execute
Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader())
before performing the login and to have
Dynamic-Import: *


Is there a better way for this? Is this the "standard" pattern to work
around this specific issue? It looks like asking dynamic import * and
asking to setup the classloader is asking for too much.


Regards,
  Lucas


PS: I will post the questions we had on the authorization part of Jaas
into another email as the use cases are more complex.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to