Hi,

On Thu, Feb 13, 2014 at 1:11 AM, Chetan Mehrotra
<[email protected]> wrote:
> On Thu, Feb 13, 2014 at 12:45 PM, Tobias Bocanegra <[email protected]> wrote:
>> I don't quite follow. can you give an example of what would be in the
>> jaas.conf and where you instantiate the ProxyLoginModule ?
>
> A rough sketch would be ...
>
> jaas.config
>
> ----
> oakAuth {
> org.apache.jackrabbit.oak.security.ProxyLoginModule REQUIRED
>     
> loginModuleFactoryClass="org.apache.jackrabbit.oak.security.LdapLoginModuleFactory"
>     authIdentity="{USERNAME}"
>     useSSL=false
>     debug=true;
> };
> ----
>
> public class ProxyLoginModule implements LoginModule{
>     private LoginModule delegate;
>
>     public void initialize(Subject subject, CallbackHandler callbackHandler,
>         Map<String, ?> sharedState, Map<String, ?> options){
>         LMFactoryProviderCallBack lmfcb = new LMFactoryProviderCallBack()
>         factory =  callbackHandler.handle([lmfcb]);
>         LoginModuleFactory factory = lmfcb.getLoginModuleFactoryProvider()
>
> .getFactory(options.get(loginModuleFactoryClass));
>         delegate = factory.createLoginModule();
>         delegate.initialize(subject, callbackHandler, sharedState, options);
>     }
>
>     ...
>     //Use delegate for other operations
> }
>
> The flow would involve following steps
>
> 1. User mentions the ProxyLoginModule in jaas entry and provide the
> factory class name in the config. JAAS logic would be instantiating
> the Proxy LM
> 2. Oak provides a callback using which Proxy LM can obtain the factory

this callback would rely on some sort of (non-osgi) list of
pre-configured factories, right?
eg some sort of LoginModuleFactoryRegistryImpl that is added to the
authentication configuration?

> 3. Upon init the proxy would initialize the delegate from factory
> 4. The delegate is used for later calls
> 5. LM if required can still use the config from jaas or ot is
> configured via factory itself

this has one caveat, that you could register 1 factory per class (if
you are using the factories class name as identifier). otherwise you
would need to introduce some kind of factory pid.

> Note here I preferred using the callback to get LM access the outer
> layer services instead of using a custom config.
>
> The custom config mode works fine in standalone case where the
> application is the sole user of JAAS system. Hence it works fine for
> Karaf/OSGi env But that might not work properly in App server env
> where app server itself uses jaas. So to avoid interfering in embedded
> mode callback should be preferred.

regards, toby

Reply via email to