That can be done but the implementation looks like a workaround. One possible implementation is at [1]. It switches to OSGi mode if it finds configuration through SPI otherwise it follows a logic similar to one in LocalAuthContext. It has an extra benefit of handling OSGI dynamism in a better way i.e. if the configuration through OSGi goes away it switches back to local one. So better suitable for cases like OSGi
But using LoginContext from within a LoginModule does not look good :). Having first class support for such cases in JR core would help in other places also. Chetan Mehrotra [1] https://github.com/chetanmeh/sling/blob/jaas-osgi-adv/bundles/jcr/jackrabbit-server/src/main/java/org/apache/sling/jcr/jackrabbit/server/impl/security/DelegatingLoginModule.java
