This content has been marked as final.
Show 2 replies
-
1. Re: IdentityStore and EntityManager with JTA transactions
shane.bryzak Oct 24, 2008 12:06 AM (in response to bistro1410)You can set it in components.xml:
<security:jpa-identity-store entity-manager="#{myEntityManager}"/>
-
2. Re: IdentityStore and EntityManager with JTA transactions
fivesails Mar 19, 2009 8:23 AM (in response to bistro1410)I still cannot get IdentityManagement to persist anything in the database. Read access works fine.
My components.xml:
<persistence:managed-persistence-context name="entityManager" auto-create="true" persistence-unit-jndi-name="java:/MartensRDFEntityManagerFactory"/> <security:rule-based-permission-resolver security-rules="#{securityRules}"/> <security:jpa-identity-store user-class="xx.martens.rdf.model.User" role-class="xx.martens.rdf.model.Role" entity-manager="#{entityManager}"/>
The following simple test shows, that users present in the database can be accessed, but a new user is not persisted:
public class IdentityManagementTest extends SeamTest { private static LogProvider log = Logging.getLogProvider(IdentityManagementTest.class); public EntityManager getEntityManager() { return (EntityManager) getInstance( "entityManager" ); } @Test public void createUser() throws Exception { new ComponentTest() { String newUsername = "user_created_by_createUser"; @Override protected void testComponents() throws Exception { IdentityManager identityManager = IdentityManager.instance(); assertNotNull(identityManager); Credentials credentials = (Credentials) Component.getInstance(Credentials.class); credentials.setUsername("admin"); credentials.setPassword("admin"); Identity identity = Identity.instance(); assertNotNull(identity.login()); // this is for being able to perform the operations below. assertTrue(identity.hasRole("admin")); // the test itself: log.debug("createUser returned: " + createUser(newUsername, newUsername)); assertTrue(identityManager.userExists(newUsername)); } @Transactional private boolean createUser(String name, String password) { IdentityManager identityManager = IdentityManager.instance(); assertNotNull(identityManager); return identityManager.createUser(name, password); } }.run(); }
Running the test above, I get the following:
- No Exceptions are thrown.
- The log output shows, that createUser() returns true.
- The assertion assertTrue(identityManager.userExists(newUsername)) fails.
Thanks, Phil