-
1. Re: IdentityManager.createUser(String name, String password, String firstname, String lastname)
nimo22 Jun 19, 2008 2:20 PM (in response to nimo22)I tried to extend the the createUser-Method in IdentityManager:
I extended the JpaIdentityStore with 'String age' in createUser:
.. @Name("org.jboss.seam.security.jpaIdentityStore") @Install(precedence = DEPLOYMENT) @Scope(APPLICATION) @BypassInterceptors @Startup public class MyJPAIdentityStore extends JpaIdentityStore { ... public boolean createUser(String username, String password, String firstname, String lastname, String age) {...}
I also extended the IdentityManager
public class MyIdentityManager extends IdentityManager { @Override public boolean createUser(String name, String password) { return createUser(name, password, null, null); } @Override public boolean createUser(String name, String password, String firstname, String lastname) { Identity.instance().checkPermission(USER_PERMISSION_NAME, PERMISSION_CREATE); return identityStore.createUser(name, password, firstname, lastname); } public boolean createUser(String name, String password, String firstname, String lastname, String age) { Identity.instance().checkPermission(USER_PERMISSION_NAME, PERMISSION_CREATE); return identityStore.createUser(name, password, firstname, lastname, idShift, idTeam, defaultlang); }
and at last, I extended the IdentityStore
public interface MyIdentityStore extends IdentityStore { ... boolean createUser(String username, String password); boolean createUser(String username, String password, String firstname, String lastname); boolean createUser(String username, String password, String firstname, String lastname, String age);
Now, I want to use the the method.
My Question: Is this all I have to do or do I more than I have to do? I want to keep it simple:-)
-
2. Re: IdentityManager.createUser(String name, String password, String firstname, String lastname)
shane.bryzak Jun 19, 2008 2:28 PM (in response to nimo22)It isn't anywhere near as complicated as this. Simply write an observer for JpaIdentityStore.EVENTUSERCREATED to get a reference to the persisted entity, then make whatever further changes to it that you want before merging.
-
3. Re: IdentityManager.createUser(String name, String password, String firstname, String lastname)
shane.bryzak Jun 19, 2008 2:30 PM (in response to nimo22)Oops, that event should have been JpaIdentityStore.EVENT_USER_CREATED.
-
4. Re: IdentityManager.createUser(String name, String password, String firstname, String lastname)
nimo22 Jun 19, 2008 3:32 PM (in response to nimo22)ohh wow...thats fine..I saw the example of 'JpaIdentityStore.EVENTUSERCREATED' in the seamspace example..very nice.
One little performance-drawback with this is, that I have to use the merge-method..so the EntityManager, at first, persist the new Person-Object. After persisting, the merge-method will UPDATE the referenced Person-Object.
I can avoid the merge-method extending and overriding JPAIdentityStore:
boolean createUser(String username, String password, String firstname, String lastname, String age);
Besides, when I override the 'JPAIdentityStore', I have also override all dependencies (?). That means, I have also override the two classes 'IdentityStore' and 'IdentityManager'. Am I right?
But I am eager to keep it simple, so I use the JpaIdentityStore.EVENTUSERCREATED.
Thank u very much:-)
-
5. Re: IdentityManager.createUser(String name, String password, String firstname, String lastname)
shane.bryzak Jun 19, 2008 10:42 PM (in response to nimo22)Alternatively you can write an observer for JpaIdentityStore.EVENT_PRE_PERSIST_USER, which will give you the instance of the entity before it is persisted.