IdentitySession identitySession = identitySessionFactory.createIdentitySession(realmName);
EnvironmentImpl environment = EnvironmentImpl.getCurrent();
StandardTransaction transaction = environment.get(StandardTransaction.class);
if (transaction != null) {
IdentitySessionResource identitySessionResource = new IdentitySessionResource(identitySession);
transaction.enlistResource(identitySessionResource);
}
return new JBossIdmIdentitySessionImpl(identitySession);
} catch (IdentityException e) {