Refactor to prepar for splitting model
This commit is contained in:
1 parent
6291936ce9
commit
34a1923d18
140 files changed
+1033
-934
No files matched your search
@@ -31,10 +31,9 @@ import org.jboss.logging.Logger;
|
||||
import org.jboss.resteasy.plugins.server.undertow.UndertowJaxrsServer;
|
||||
import org.jboss.resteasy.spi.ResteasyDeployment;
|
||||
import org.keycloak.models.KeycloakSession;
|
||||
import org.keycloak.models.KeycloakSessionFactory;
|
||||
import org.keycloak.models.RealmModel;
|
||||
import org.keycloak.models.UserModel;
|
||||
import org.keycloak.provider.ProviderSession;
|
||||
import org.keycloak.provider.ProviderSessionFactory;
|
||||
import org.keycloak.representations.idm.RealmRepresentation;
|
||||
import org.keycloak.services.filters.ClientConnectionFilter;
|
||||
import org.keycloak.services.filters.KeycloakSessionServletFilter;
|
||||
@@ -163,7 +162,7 @@ public class KeycloakServer {
|
||||
|
||||
private KeycloakServerConfig config;
|
||||
|
||||
private ProviderSessionFactory providerSessionFactory;
|
||||
private KeycloakSessionFactory sessionFactory;
|
||||
|
||||
private UndertowJaxrsServer server;
|
||||
|
||||
@@ -175,8 +174,8 @@ public class KeycloakServer {
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
public ProviderSessionFactory getProviderSessionFactory() {
|
||||
return providerSessionFactory;
|
||||
public KeycloakSessionFactory getSessionFactory() {
|
||||
return sessionFactory;
|
||||
}
|
||||
|
||||
public UndertowJaxrsServer getServer() {
|
||||
@@ -189,8 +188,7 @@ public class KeycloakServer {
|
||||
}
|
||||
|
||||
public void importRealm(RealmRepresentation rep) {
|
||||
ProviderSession providerSession = providerSessionFactory.createSession();
|
||||
KeycloakSession session = providerSession.getProvider(KeycloakSession.class);
|
||||
KeycloakSession session = sessionFactory.create();;
|
||||
session.getTransaction().begin();
|
||||
|
||||
try {
|
||||
@@ -213,13 +211,12 @@ public class KeycloakServer {
|
||||
|
||||
session.getTransaction().commit();
|
||||
} finally {
|
||||
providerSession.close();
|
||||
session.close();
|
||||
}
|
||||
}
|
||||
|
||||
protected void setupDevConfig() {
|
||||
ProviderSession providerSession = providerSessionFactory.createSession();
|
||||
KeycloakSession session = providerSession.getProvider(KeycloakSession.class);
|
||||
KeycloakSession session = sessionFactory.create();
|
||||
session.getTransaction().begin();
|
||||
|
||||
try {
|
||||
@@ -231,7 +228,7 @@ public class KeycloakServer {
|
||||
|
||||
session.getTransaction().commit();
|
||||
} finally {
|
||||
providerSession.close();
|
||||
session.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -263,7 +260,7 @@ public class KeycloakServer {
|
||||
|
||||
server.deploy(di);
|
||||
|
||||
providerSessionFactory = ((KeycloakApplication) deployment.getApplication()).getProviderSessionFactory();
|
||||
sessionFactory = ((KeycloakApplication) deployment.getApplication()).getSessionFactory();
|
||||
|
||||
setupDevConfig();
|
||||
|
||||
@@ -284,7 +281,7 @@ public class KeycloakServer {
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
providerSessionFactory.close();
|
||||
sessionFactory.close();
|
||||
server.stop();
|
||||
|
||||
info("Stopped Keycloak");
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
}
|
||||
},
|
||||
|
||||
"login-forms": {
|
||||
"login": {
|
||||
"provider": "freemarker"
|
||||
},
|
||||
|
||||
|
||||
@@ -14,11 +14,11 @@ import org.keycloak.audit.Details;
|
||||
import org.keycloak.audit.Event;
|
||||
import org.keycloak.audit.EventType;
|
||||
import org.keycloak.models.ClientModel;
|
||||
import org.keycloak.models.KeycloakSession;
|
||||
import org.keycloak.models.RealmModel;
|
||||
import org.keycloak.models.UserModel;
|
||||
import org.keycloak.models.UserSessionModel;
|
||||
import org.keycloak.models.utils.KeycloakModelUtils;
|
||||
import org.keycloak.provider.ProviderSession;
|
||||
import org.keycloak.representations.idm.UserRepresentation;
|
||||
import org.keycloak.services.managers.RealmManager;
|
||||
import org.keycloak.testsuite.rule.KeycloakRule;
|
||||
@@ -173,7 +173,7 @@ public class AssertEvents implements TestRule, AuditListenerFactory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuditListener create(ProviderSession providerSession) {
|
||||
public AuditListener create(KeycloakSession session) {
|
||||
return new AuditListener() {
|
||||
@Override
|
||||
public void onEvent(Event event) {
|
||||
|
||||
@@ -54,7 +54,7 @@ public class ProfileTest {
|
||||
user.setAttribute("key1", "value1");
|
||||
user.setAttribute("key2", "value2");
|
||||
|
||||
ApplicationModel accountApp = appRealm.getApplicationNameMap().get(org.keycloak.models.Constants.ACCOUNT_MANAGEMENT_APP);
|
||||
ApplicationModel accountApp = appRealm.getApplicationByName(org.keycloak.models.Constants.ACCOUNT_MANAGEMENT_APP);
|
||||
|
||||
UserModel user2 = appRealm.addUser("test-user-no-access@localhost");
|
||||
user2.setEnabled(true);
|
||||
@@ -66,7 +66,7 @@ public class ProfileTest {
|
||||
creds.setValue("password");
|
||||
user2.updateCredential(creds);
|
||||
|
||||
ApplicationModel app = appRealm.getApplicationNameMap().get("test-app");
|
||||
ApplicationModel app = appRealm.getApplicationByName("test-app");
|
||||
app.addScopeMapping(accountApp.getRole(AccountRoles.VIEW_PROFILE));
|
||||
app.addRedirectUri("http://localhost:8081/app/*");
|
||||
app.addWebOrigin("http://localtest.me:8081");
|
||||
|
||||
+31
-34
@@ -34,8 +34,6 @@ import org.keycloak.models.KeycloakSession;
|
||||
import org.keycloak.models.RealmModel;
|
||||
import org.keycloak.models.UserModel;
|
||||
import org.keycloak.models.UserSessionModel;
|
||||
import org.keycloak.models.cache.CacheKeycloakSession;
|
||||
import org.keycloak.provider.ProviderSession;
|
||||
import org.keycloak.representations.AccessToken;
|
||||
import org.keycloak.representations.adapters.action.SessionStats;
|
||||
import org.keycloak.representations.idm.RealmRepresentation;
|
||||
@@ -94,9 +92,9 @@ public class AdapterTest {
|
||||
};
|
||||
|
||||
private static String createToken() {
|
||||
ProviderSession providerSession = keycloakRule.startSession();
|
||||
KeycloakSession session = keycloakRule.startSession();
|
||||
try {
|
||||
RealmManager manager = new RealmManager(providerSession.getProvider(KeycloakSession.class));
|
||||
RealmManager manager = new RealmManager(session);
|
||||
|
||||
RealmModel adminRealm = manager.getRealm(Config.getAdminRealm());
|
||||
ApplicationModel adminConsole = adminRealm.getApplicationByName(Constants.ADMIN_CONSOLE_APPLICATION);
|
||||
@@ -106,8 +104,7 @@ public class AdapterTest {
|
||||
AccessToken token = tm.createClientAccessToken(null, adminRealm, adminConsole, admin, userSession);
|
||||
return tm.encodeToken(adminRealm, token);
|
||||
} finally {
|
||||
keycloakRule.stopSession(providerSession, true);
|
||||
|
||||
keycloakRule.stopSession(session, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -192,12 +189,12 @@ public class AdapterTest {
|
||||
System.out.println(pageSource);
|
||||
Assert.assertTrue(pageSource.contains("Bill Burke") && pageSource.contains("Stian Thorgersen"));
|
||||
|
||||
KeycloakSession keycloakSession = keycloakRule.startCacheSession();
|
||||
RealmModel realm = keycloakSession.getRealmByName("demo");
|
||||
KeycloakSession session = keycloakRule.startSession();
|
||||
RealmModel realm = session.getRealmByName("demo");
|
||||
int originalIdle = realm.getSsoSessionIdleTimeout();
|
||||
realm.setSsoSessionIdleTimeout(1);
|
||||
keycloakSession.getTransaction().commit();
|
||||
keycloakSession.close();
|
||||
session.getTransaction().commit();
|
||||
session.close();
|
||||
|
||||
Thread.sleep(2000);
|
||||
|
||||
@@ -206,11 +203,11 @@ public class AdapterTest {
|
||||
driver.navigate().to("http://localhost:8081/product-portal");
|
||||
Assert.assertTrue(driver.getCurrentUrl().startsWith(LOGIN_URL));
|
||||
|
||||
keycloakSession = keycloakRule.startCacheSession();
|
||||
realm = keycloakSession.getRealmByName("demo");
|
||||
session = keycloakRule.startSession();
|
||||
realm = session.getRealmByName("demo");
|
||||
realm.setSsoSessionIdleTimeout(originalIdle);
|
||||
keycloakSession.getTransaction().commit();
|
||||
keycloakSession.close();
|
||||
session.getTransaction().commit();
|
||||
session.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -226,30 +223,30 @@ public class AdapterTest {
|
||||
System.out.println(pageSource);
|
||||
Assert.assertTrue(pageSource.contains("Bill Burke") && pageSource.contains("Stian Thorgersen"));
|
||||
|
||||
KeycloakSession keycloakSession = keycloakRule.startCacheSession();
|
||||
RealmModel realm = keycloakSession.getRealmByName("demo");
|
||||
KeycloakSession session = keycloakRule.startSession();
|
||||
RealmModel realm = session.getRealmByName("demo");
|
||||
int originalIdle = realm.getSsoSessionIdleTimeout();
|
||||
realm.setSsoSessionIdleTimeout(1);
|
||||
keycloakSession.getTransaction().commit();
|
||||
keycloakSession.close();
|
||||
session.getTransaction().commit();
|
||||
session.close();
|
||||
|
||||
Thread.sleep(2000);
|
||||
|
||||
keycloakSession = keycloakRule.startCacheSession();
|
||||
realm = keycloakSession.getRealmByName("demo");
|
||||
session = keycloakRule.startSession();
|
||||
realm = session.getRealmByName("demo");
|
||||
realm.removeExpiredUserSessions();
|
||||
keycloakSession.getTransaction().commit();
|
||||
keycloakSession.close();
|
||||
session.getTransaction().commit();
|
||||
session.close();
|
||||
|
||||
// test SSO
|
||||
driver.navigate().to("http://localhost:8081/product-portal");
|
||||
Assert.assertTrue(driver.getCurrentUrl().startsWith(LOGIN_URL));
|
||||
|
||||
keycloakSession = keycloakRule.startCacheSession();
|
||||
realm = keycloakSession.getRealmByName("demo");
|
||||
session = keycloakRule.startSession();
|
||||
realm = session.getRealmByName("demo");
|
||||
realm.setSsoSessionIdleTimeout(originalIdle);
|
||||
keycloakSession.getTransaction().commit();
|
||||
keycloakSession.close();
|
||||
session.getTransaction().commit();
|
||||
session.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -265,12 +262,12 @@ public class AdapterTest {
|
||||
System.out.println(pageSource);
|
||||
Assert.assertTrue(pageSource.contains("Bill Burke") && pageSource.contains("Stian Thorgersen"));
|
||||
|
||||
KeycloakSession keycloakSession = keycloakRule.startCacheSession();
|
||||
RealmModel realm = keycloakSession.getRealmByName("demo");
|
||||
KeycloakSession session = keycloakRule.startSession();
|
||||
RealmModel realm = session.getRealmByName("demo");
|
||||
int original = realm.getSsoSessionMaxLifespan();
|
||||
realm.setSsoSessionMaxLifespan(1);
|
||||
keycloakSession.getTransaction().commit();
|
||||
keycloakSession.close();
|
||||
session.getTransaction().commit();
|
||||
session.close();
|
||||
|
||||
Thread.sleep(2000);
|
||||
|
||||
@@ -279,11 +276,11 @@ public class AdapterTest {
|
||||
driver.navigate().to("http://localhost:8081/product-portal");
|
||||
Assert.assertTrue(driver.getCurrentUrl().startsWith(LOGIN_URL));
|
||||
|
||||
keycloakSession = keycloakRule.startCacheSession();
|
||||
realm = keycloakSession.getRealmByName("demo");
|
||||
session = keycloakRule.startSession();
|
||||
realm = session.getRealmByName("demo");
|
||||
realm.setSsoSessionMaxLifespan(original);
|
||||
keycloakSession.getTransaction().commit();
|
||||
keycloakSession.close();
|
||||
session.getTransaction().commit();
|
||||
session.close();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -62,7 +62,7 @@ public class AuthProvidersIntegrationTest {
|
||||
|
||||
// Configure LDAP
|
||||
ldapRule.getEmbeddedServer().setupLdapInRealm(appRealm);
|
||||
LDAPTestUtils.setLdapPassword(providerSession, appRealm, "johnkeycloak", "password");
|
||||
LDAPTestUtils.setLdapPassword(session, appRealm, "johnkeycloak", "password");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
+8
-9
@@ -32,7 +32,6 @@ import org.keycloak.audit.Event;
|
||||
import org.keycloak.models.KeycloakSession;
|
||||
import org.keycloak.models.RealmModel;
|
||||
import org.keycloak.models.UserSessionModel;
|
||||
import org.keycloak.provider.ProviderSession;
|
||||
import org.keycloak.representations.AccessToken;
|
||||
import org.keycloak.representations.RefreshToken;
|
||||
import org.keycloak.testsuite.AssertEvents;
|
||||
@@ -183,7 +182,7 @@ public class RefreshTokenTest {
|
||||
|
||||
String refreshId = oauth.verifyRefreshToken(tokenResponse.getRefreshToken()).getId();
|
||||
|
||||
KeycloakSession session = keycloakRule.startCacheSession();
|
||||
KeycloakSession session = keycloakRule.startSession();
|
||||
RealmModel realm = session.getRealmByName("test");
|
||||
UserSessionModel userSession = realm.getUserSession(sessionId);
|
||||
int last = userSession.getLastSessionRefresh();
|
||||
@@ -199,7 +198,7 @@ public class RefreshTokenTest {
|
||||
|
||||
Assert.assertEquals(200, tokenResponse.getStatusCode());
|
||||
|
||||
session = keycloakRule.startCacheSession();
|
||||
session = keycloakRule.startSession();
|
||||
realm = session.getRealmByName("test");
|
||||
userSession = realm.getUserSession(sessionId);
|
||||
int next = userSession.getLastSessionRefresh();
|
||||
@@ -211,7 +210,7 @@ public class RefreshTokenTest {
|
||||
|
||||
|
||||
|
||||
session = keycloakRule.startCacheSession();
|
||||
session = keycloakRule.startSession();
|
||||
realm = session.getRealmByName("test");
|
||||
int lastAccessTokenLifespan = realm.getAccessTokenLifespan();
|
||||
realm.setAccessTokenLifespan(100000);
|
||||
@@ -221,7 +220,7 @@ public class RefreshTokenTest {
|
||||
Thread.sleep(2000);
|
||||
tokenResponse = oauth.doRefreshTokenRequest(tokenResponse.getRefreshToken(), "password");
|
||||
|
||||
session = keycloakRule.startCacheSession();
|
||||
session = keycloakRule.startSession();
|
||||
realm = session.getRealmByName("test");
|
||||
userSession = realm.getUserSession(sessionId);
|
||||
next = userSession.getLastSessionRefresh();
|
||||
@@ -231,7 +230,7 @@ public class RefreshTokenTest {
|
||||
// lastSEssionRefresh should be updated because access code lifespan is higher than sso idle timeout
|
||||
Assert.assertThat(next, allOf(greaterThan(last), lessThan(last + 6)));
|
||||
|
||||
session = keycloakRule.startCacheSession();
|
||||
session = keycloakRule.startSession();
|
||||
realm = session.getRealmByName("test");
|
||||
int originalIdle = realm.getSsoSessionIdleTimeout();
|
||||
realm.setSsoSessionIdleTimeout(1);
|
||||
@@ -249,7 +248,7 @@ public class RefreshTokenTest {
|
||||
|
||||
events.expectRefresh(refreshId, sessionId).error(Errors.INVALID_TOKEN);
|
||||
|
||||
session = keycloakRule.startCacheSession();
|
||||
session = keycloakRule.startSession();
|
||||
realm = session.getRealmByName("test");
|
||||
realm.setSsoSessionIdleTimeout(originalIdle);
|
||||
realm.setAccessTokenLifespan(lastAccessTokenLifespan);
|
||||
@@ -274,7 +273,7 @@ public class RefreshTokenTest {
|
||||
|
||||
String refreshId = oauth.verifyRefreshToken(tokenResponse.getRefreshToken()).getId();
|
||||
|
||||
KeycloakSession session = keycloakRule.startCacheSession();
|
||||
KeycloakSession session = keycloakRule.startSession();
|
||||
RealmModel realm = session.getRealmByName("test");
|
||||
int maxLifespan = realm.getSsoSessionMaxLifespan();
|
||||
realm.setSsoSessionMaxLifespan(1);
|
||||
@@ -289,7 +288,7 @@ public class RefreshTokenTest {
|
||||
assertNull(tokenResponse.getAccessToken());
|
||||
assertNull(tokenResponse.getRefreshToken());
|
||||
|
||||
session = keycloakRule.startCacheSession();
|
||||
session = keycloakRule.startSession();
|
||||
realm = session.getRealmByName("test");
|
||||
realm.setSsoSessionMaxLifespan(maxLifespan);
|
||||
session.getTransaction().commit();
|
||||
|
||||
+12
-23
@@ -10,8 +10,6 @@ import org.keycloak.Config;
|
||||
import org.keycloak.models.KeycloakSession;
|
||||
import org.keycloak.models.RealmModel;
|
||||
import org.keycloak.models.UserModel;
|
||||
import org.keycloak.models.cache.CacheKeycloakSession;
|
||||
import org.keycloak.provider.ProviderSession;
|
||||
import org.keycloak.representations.idm.RealmRepresentation;
|
||||
import org.keycloak.representations.idm.UserRepresentation;
|
||||
import org.keycloak.services.managers.ModelToRepresentation;
|
||||
@@ -39,29 +37,28 @@ public abstract class AbstractKeycloakRule extends ExternalResource {
|
||||
}
|
||||
|
||||
public UserRepresentation getUser(String realm, String name) {
|
||||
ProviderSession providerSession = server.getProviderSessionFactory().createSession();
|
||||
KeycloakSession session = providerSession.getProvider(KeycloakSession.class);
|
||||
KeycloakSession session = server.getSessionFactory().create();
|
||||
session.getTransaction().begin();
|
||||
try {
|
||||
UserModel user = session.getRealmByName(realm).getUser(name);
|
||||
return user != null ? ModelToRepresentation.toRepresentation(user) : null;
|
||||
} finally {
|
||||
providerSession.close();
|
||||
session.close();
|
||||
}
|
||||
}
|
||||
|
||||
public UserRepresentation getUserById(String realm, String id) {
|
||||
ProviderSession providerSession = server.getProviderSessionFactory().createSession();
|
||||
KeycloakSession session = providerSession.getProvider(KeycloakSession.class);
|
||||
KeycloakSession session = server.getSessionFactory().create();
|
||||
session.getTransaction().begin();
|
||||
try {
|
||||
return ModelToRepresentation.toRepresentation(session.getRealmByName(realm).getUserById(id));
|
||||
} finally {
|
||||
providerSession.close();
|
||||
session.close();
|
||||
}
|
||||
}
|
||||
|
||||
protected void setupKeycloak() {
|
||||
ProviderSession providerSession = server.getProviderSessionFactory().createSession();
|
||||
KeycloakSession session = providerSession.getProvider(KeycloakSession.class);
|
||||
KeycloakSession session = server.getSessionFactory().create();
|
||||
session.getTransaction().begin();
|
||||
|
||||
try {
|
||||
@@ -73,7 +70,7 @@ public abstract class AbstractKeycloakRule extends ExternalResource {
|
||||
|
||||
session.getTransaction().commit();
|
||||
} finally {
|
||||
providerSession.close();
|
||||
session.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,23 +134,15 @@ public abstract class AbstractKeycloakRule extends ExternalResource {
|
||||
return JsonSerialization.readValue(bytes, RealmRepresentation.class);
|
||||
}
|
||||
|
||||
public ProviderSession startSession() {
|
||||
ProviderSession providerSession = server.getProviderSessionFactory().createSession();
|
||||
KeycloakSession session = providerSession.getProvider(KeycloakSession.class);
|
||||
session.getTransaction().begin();
|
||||
return providerSession;
|
||||
}
|
||||
|
||||
public KeycloakSession startCacheSession() {
|
||||
ProviderSession providerSession = server.getProviderSessionFactory().createSession();
|
||||
KeycloakSession session = providerSession.getProvider(CacheKeycloakSession.class);
|
||||
public KeycloakSession startSession() {
|
||||
KeycloakSession session = server.getSessionFactory().create();
|
||||
session.getTransaction().begin();
|
||||
return session;
|
||||
}
|
||||
|
||||
public void stopSession(ProviderSession session, boolean commit) {
|
||||
public void stopSession(KeycloakSession session, boolean commit) {
|
||||
if (commit) {
|
||||
session.getProvider(KeycloakSession.class).getTransaction().commit();
|
||||
session.getTransaction().commit();
|
||||
}
|
||||
session.close();
|
||||
}
|
||||
|
||||
@@ -25,8 +25,6 @@ import org.keycloak.Config;
|
||||
import org.keycloak.models.KeycloakSession;
|
||||
import org.keycloak.models.RealmModel;
|
||||
import org.keycloak.models.UserSessionModel;
|
||||
import org.keycloak.models.cache.CacheKeycloakSession;
|
||||
import org.keycloak.provider.ProviderSession;
|
||||
import org.keycloak.services.managers.RealmManager;
|
||||
import org.keycloak.testsuite.ApplicationServlet;
|
||||
|
||||
@@ -62,8 +60,7 @@ public class KeycloakRule extends AbstractKeycloakRule {
|
||||
}
|
||||
|
||||
public void configure(KeycloakSetup configurer) {
|
||||
ProviderSession providerSession = server.getProviderSessionFactory().createSession();
|
||||
KeycloakSession session = providerSession.getProvider(KeycloakSession.class);
|
||||
KeycloakSession session = server.getSessionFactory().create();
|
||||
session.getTransaction().begin();
|
||||
|
||||
try {
|
||||
@@ -72,18 +69,17 @@ public class KeycloakRule extends AbstractKeycloakRule {
|
||||
RealmModel adminstrationRealm = manager.getRealm(Config.getAdminRealm());
|
||||
RealmModel appRealm = manager.getRealm("test");
|
||||
|
||||
configurer.providerSession = providerSession;
|
||||
configurer.session = session;
|
||||
configurer.config(manager, adminstrationRealm, appRealm);
|
||||
|
||||
session.getTransaction().commit();
|
||||
} finally {
|
||||
providerSession.close();
|
||||
session.close();
|
||||
}
|
||||
}
|
||||
|
||||
public void update(KeycloakSetup configurer) {
|
||||
ProviderSession providerSession = server.getProviderSessionFactory().createSession();
|
||||
KeycloakSession session = providerSession.getProvider(CacheKeycloakSession.class);
|
||||
KeycloakSession session = server.getSessionFactory().create();
|
||||
session.getTransaction().begin();
|
||||
|
||||
try {
|
||||
@@ -92,28 +88,28 @@ public class KeycloakRule extends AbstractKeycloakRule {
|
||||
RealmModel adminstrationRealm = manager.getRealm(Config.getAdminRealm());
|
||||
RealmModel appRealm = manager.getRealm("test");
|
||||
|
||||
configurer.providerSession = providerSession;
|
||||
configurer.session = session;
|
||||
configurer.config(manager, adminstrationRealm, appRealm);
|
||||
|
||||
session.getTransaction().commit();
|
||||
} finally {
|
||||
providerSession.close();
|
||||
session.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void removeUserSession(String sessionId) {
|
||||
ProviderSession providerSession = startSession();
|
||||
RealmModel realm = providerSession.getProvider(KeycloakSession.class).getRealm("test");
|
||||
UserSessionModel session = realm.getUserSession(sessionId);
|
||||
assertNotNull(session);
|
||||
realm.removeUserSession(session);
|
||||
stopSession(providerSession, true);
|
||||
KeycloakSession session = startSession();
|
||||
RealmModel realm = session.getRealm("test");
|
||||
UserSessionModel userSession = realm.getUserSession(sessionId);
|
||||
assertNotNull(userSession);
|
||||
realm.removeUserSession(userSession);
|
||||
stopSession(session, true);
|
||||
}
|
||||
|
||||
public abstract static class KeycloakSetup {
|
||||
|
||||
protected ProviderSession providerSession;
|
||||
protected KeycloakSession session;
|
||||
|
||||
public abstract void config(RealmManager manager, RealmModel adminstrationRealm, RealmModel appRealm);
|
||||
|
||||
|
||||
Reference in new issue
Block a user