-
1. Re: Extending JpaIdentityStore
kapitanpetko Oct 19, 2009 3:27 AM (in response to riboriori)Seems your class is not being instantiated at all. Since you are overriding the Seam component, you shouldn't need to specify the class in your components.xml. Remove it and see what happens. Also put some logging and/or breakpoints in your JpaIdentityStoreExt class to check if
it is used. Why do you need to override JpaIdentityStore in the first place? -
2. Re: Extending JpaIdentityStore
riboriori Oct 19, 2009 12:18 PM (in response to riboriori)I want store more information about user, such as company, age etc...
In order to do this, i belive (i dont know seam, i'm a newbe) i must override IdentiyManager also.
What do you think? -
3. Re: Extending JpaIdentityStore
kapitanpetko Oct 19, 2009 12:38 PM (in response to riboriori)You don't need to override JpaIdentityStore, just add properties as needed to your User class. You can observe the JpaIdentityStore.EVENT_USER_CREATED event to modify the newly created User. Look in the seamspace example for inspiration.
HTH
-
4. Re: Extending JpaIdentityStore
riboriori Oct 19, 2009 1:08 PM (in response to riboriori)Yes, good idea: must i use @Observer?
There is a problem: identityStore interface defines a method, createUser (and an overloading of it) which takes only the username and password params.
If i want a manager that creates a user with additional params? -
5. Re: Extending JpaIdentityStore
fuzzy333 Oct 19, 2009 3:12 PM (in response to riboriori)We have the same problem in our application and we work around this by observing the JpaIdentityStore.EVENT_USER_CREATED event.
What is retarted about this way of doing this however is that we have to (re)set every field on the user object since the JpaIdentityStore creates a new user instance instead of having a get/set user property or whatever way to hand it a user instance.
Here's an example observer:
public class UserEventObserverBean implements UserEventObserver { private User user; @Observer( value = JpaIdentityStore.EVENT_PRE_PERSIST_USER, create = false ) public void prePersistUser( Object pUser ) { User newUser = (User)pUser; newUser.setEmail( getUser().getEmail() ); newUser.setLocale( getUser().getLocale() ); newUser.setPortalId( getUser().getPortalId() ); } @Observer( value = JpaIdentityStore.EVENT_USER_CREATED, create = false ) public void userCreated( Object pUser ) { setUser( (User)pUser ); } public void setUser( User user ) { this.user = user; } public User getUser() { return user; } @Remove @Destroy public void destroy() { } }
.. and action bean
UserEventObserver observer = (UserEventObserver)Component.getInstance( "userCreationObserver" ); observer.setUser( getUser() ); identityStore.createUser( getUser().getUsername(), getUser().getPassword(), getUser().getFirstName(), getUser().getLastName() );
-
6. Re: Extending JpaIdentityStore
riboriori Oct 20, 2009 7:53 AM (in response to riboriori)The solution appear good, but i have some doubt: if i want an override of seam security that, for example, provide
List<User> listUsers()
method instead of
List<String> listUsers()
? -
7. Re: Extending JpaIdentityStore
kapitanpetko Oct 20, 2009 7:59 AM (in response to riboriori)JpaIdentityManager is not meant to be a full-blown user manager. If you want additional functionality, just create your own component,
UserManager or whatever. You can than search, update, etc. your User classes just as you do with your other entities.