Identity.instance().login() not possible with custom IdentityStore
steffi.stephanie.stroka.salzburgresearch.at Feb 2, 2010 5:15 PMHey,
I wrote a custom identityStore (which implements org.jboss.seam.security.management.IdentityStore, of course) and configured it in components.xml in the following way:
<security:identity-manager identity-store="#{kiwiIdentityStore}"/>
<security:jpa-identity-store user-class="kiwi.model.user.User" role-class="kiwi.model.user.Role"/>
<!-- <security:jpa-permission-store user-permission-class="kiwi.model.security.Permission"/> -->
<component name="kiwiIdentityStore"
class="kiwi.service.user.KiWiIdentityStoreImpl" startup="true"
scope="APPLICATION">
</component>This works, I guess, since Seam does not complain about this configuration on JBoss AS startup.
The problem that I have is that Identity.instance().login();does not work, and Identity.instance().isLoggedIn() returns false afterwards.
The createUser(), which is implemented in the custom IdentityStore can be seen below:
@Override
public boolean createUser(String username, String password,
String firstname, String lastname) {
// create new user ...
Query q = entityManager.createNamedQuery("currentUserFactory.getUserByLogin");
q.setParameter("login", username);
User user = null;
try {
q.setMaxResults(1);
user = (User) q.getSingleResult();
} catch(NonUniqueResultException ex) {
log.error("User #0 exists already", username);
return false;
} catch(NoResultException ex) {
user = new User(username);
user.setResource(
tripleStore.createUriResource(
configurationService.getBaseUri()+"/user/"+username));
user.setType(tripleStore.createUriResource(Constants.NS_KIWI_CORE + "User"));
user.setFirstName(firstname);
user.setLastName(lastname);
user.setPasswordHash(hashPassword(password, username));
user.setEnabled(true);
q.setHint("org.hibernate.cacheable", true);
cacheProvider.put(username, user);
entityManager.persist(user);
if (Events.exists())
Events.instance().raiseEvent(EVENT_ACCOUNT_CREATED, user);
return true;
}
return false;
}Does anyone of you know why I cannot login with Seams Identity.instance().login() or what I have to change that it works?