Search code examples
jakarta-eeglassfishjdbcrealmpayara

Select JDBCRealm dynamically


I have created multiple realm in Payara server with different JNDI. Means i have multiple databases with same structure(users and groups) and would like to get authentication/authorization by getting/setting realm name on runtime. I am not sure how i will get the JDBCRealm name on runtime, any help needed.

i was trying to get by:

        Context iniCtx = new InitialContext();
        DataSource ddsa = (DataSource) iniCtx.lookup("java:app/multi2jndi");
        DatabaseMetaData mdd;

I doesn't work because it is used to lookup a resources.


Solution

  • After struggling of two days i found that we can't hack the container managed security/realms directly. some how we have to write our own custom security module or to go differently by using JASPIC (JSR196). I am going further with JASPIC.