1

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.

stdunbar
  • 16,263
  • 11
  • 31
  • 53
umaair_653
  • 113
  • 10
  • Please check this question (http://stackoverflow.com/questions/5104185/how-to-inject-persistence-context-to-different-data-source-programmatically) and answer from Nayan. – D00de May 08 '17 at 14:24
  • @D00de this is about calling datasource, my question is about to get realm name at runtime. – umaair_653 May 08 '17 at 15:42
  • Where is your Realm configured, in web.xml file? – D00de May 08 '17 at 20:16
  • I have created 2 realms in payara. e.g: tenant1Realm and tenant2Realm. my approach is at the time of login i will detect tenantID and with the help of it i will invoke particular realm (realm name contains tenantID) just before login method. basically i am trying to use declarative realm but i will just invoke required realm within session scope. – umaair_653 May 09 '17 at 06:33
  • second approach would be to define realm within project instead of in Payara because all the required params will be same just datasource for the tenant will be different. but for this i need some classes to hookup my datasources with realm which i dont know now. **is it possible to have placeholder in web.xml and i can resolve it in backend for the particular session?? – umaair_653 May 09 '17 at 06:41

1 Answers1

1

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.

umaair_653
  • 113
  • 10