JAAS is not the best security framework it exists but it is often enough for simple needs. Once you passed the setup (I’ll not detail it here) it is generally nice to use. However when writing a CDI app you need to do the bridge yourself.
You can hook it up with DeltaSpike BeanProvider but it is not that obvious/fluent.
That’s why TomEE and OpenEJB now support a bridge.
First create your jaas config file:
CDI { org.apache.openejb.core.security.jaas.CDILoginModule required delegate="org.superbiz.MyLoginModule" loginModuleAsCdiBean=false; };
Note: if you want to use a cdi name you can set cdiName property otherwise by default it uses delegate as type. loginModuleAsCdiBean is optional and if set to true it will use a login module cdi bean instead of a login module with CDI injections (so it can have a scope). Note this last ability can be dangerous and is only recommanded if you really know what you do.
Then simply implement LoginModule and inject all you need inside :).
Very cool!
Excellent. I’ve been using LazyRealm which also works a treat. But this looks pretty cool too.