[Security & JAAS/JBoss] - Propagating custom principal
by dizzydewil
Hi,
After upgrade JBOSS from version 4.0.5 to 4.2.3 (requirements for EJB3 and JAX WS) I have problem with propagating custom principal.
I have web application (used as a presentation layer) and EJB component (used as a business layer) both on the same JBOSS version (4.2.3) but different machines.
JAAS based login mechanism (with login modules) is mixed (LDAP + database) which provide custom principal class with additional informations like language in UI (multilingual application). Before for propagating principal to EJB I had to use SecurityAssociation.setPrincipal() for pass my principal class (unless JbossGenericPrincipal was passed) in filter class (in WebApp) with currently used lang (java.util.Locale), now (after upgrade) principal is passed without any extra code but I can't set current lang (in passed principal).
Any idea ?
Regards Pawel
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4220676#4220676
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4220676
17 years, 1 month
[Persistence, JBoss/CMP, Hibernate, Database] - Re: Dynamic Datasource invocation at runtime in JSF-EJB3-MyS
by pragun@imcsystemsuk.com
I manage to solve it but need to fine-tune as per the Seam/Hibernate-JPA standards before using it in the application.
(1) Create multiple <xa-datasource> envelopes with different JNDI names, in the single mysql-ds.xml datasource file. e.g.
<xa-datasource>
<jndi-name>1TestDS</jndi-name>
..
</xa-datasource>
<xa-datasource>
<jndi-name>2TestDS</jndi-name>
..
</xa-datasource>
(2) Create multiple <persistence-unit> envelopes with different persistence unit name, in a single persistence.xml file of your application e.g.
<persistence-unit name="1TestPU" transaction-type="JTA">
<jta-data-source>java:/1TestDS</jta-data-source>
...
</persistence-unit>
<persistence-unit name="2TestPU" transaction-type="JTA">
<jta-data-source>java:/2TestDS</jta-data-source>
...
</persistence-unit>
(3) In my case, the persistence unit name is the same as User branch office name. So it will be available in User entity which has Seam SESSION scope after user logged in.
(4) Here is the Stalteless bean which uses different persistence unit as follows
@PersistenceContext
private EntityManager em;
@PersistenceUnit
private EntityManagerFactory emf;
{
// get the persistence unit name from User Entity and invoke below method
}
public List findOms(String puName){
emf = Persistence.createEntityManagerFactory(puName);
em = emf.createEntityManager();
List x = (List ) em.createQuery("select t from Om t").getResultList();
em.close();
return x;
}
I hope this helps you. LEt me also know if you have found some better approch.
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4220673#4220673
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4220673
17 years, 1 month