use of org.keycloak.adapters.spi.SessionIdMapperUpdater in project keycloak by keycloak.
the class KeycloakConfigurationServletListener method invokeAddTokenStoreUpdaterMethod.
private SessionIdMapperUpdater invokeAddTokenStoreUpdaterMethod(String idMapperSessionUpdaterClass, ServletContext servletContext, SessionIdMapperUpdater previousIdMapperUpdater) {
try {
Class<?> clazz = servletContext.getClassLoader().loadClass(idMapperSessionUpdaterClass);
Method addTokenStoreUpdatersMethod = clazz.getMethod("addTokenStoreUpdaters", ServletContext.class, SessionIdMapper.class, SessionIdMapperUpdater.class);
if (!Modifier.isStatic(addTokenStoreUpdatersMethod.getModifiers()) || !Modifier.isPublic(addTokenStoreUpdatersMethod.getModifiers()) || !SessionIdMapperUpdater.class.isAssignableFrom(addTokenStoreUpdatersMethod.getReturnType())) {
log.errorv("addTokenStoreUpdaters method in class {0} has to be public static. Ignoring class.", idMapperSessionUpdaterClass);
return previousIdMapperUpdater;
}
log.debugv("Initializing sessionIdMapperUpdater class {0}", idMapperSessionUpdaterClass);
return (SessionIdMapperUpdater) addTokenStoreUpdatersMethod.invoke(null, servletContext, idMapper, previousIdMapperUpdater);
} catch (ClassNotFoundException | NoSuchMethodException | SecurityException ex) {
log.warnv(ex, "Cannot use sessionIdMapperUpdater class {0}", idMapperSessionUpdaterClass);
return previousIdMapperUpdater;
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
log.warnv(ex, "Cannot use {0}.addTokenStoreUpdaters(DeploymentInfo, SessionIdMapper) method", idMapperSessionUpdaterClass);
return previousIdMapperUpdater;
}
}
use of org.keycloak.adapters.spi.SessionIdMapperUpdater in project keycloak by keycloak.
the class KeycloakConfigurationServletListener method addTokenStoreUpdaters.
public void addTokenStoreUpdaters(ServletContext servletContext) {
SessionIdMapperUpdater updater = this.idMapperUpdater;
try {
String idMapperSessionUpdaterClasses = servletContext.getInitParameter("keycloak.sessionIdMapperUpdater.classes");
if (idMapperSessionUpdaterClasses == null) {
return;
}
// This takes care of HTTP sessions manipulated locally
servletContext.addListener(new IdMapperUpdaterSessionListener(idMapper));
updater = SessionIdMapperUpdater.DIRECT;
for (String clazz : idMapperSessionUpdaterClasses.split("\\s*,\\s*")) {
if (!clazz.isEmpty()) {
if (Objects.equals("org.keycloak.adapters.saml.wildfly.infinispan.InfinispanSessionCacheIdMapperUpdater", clazz)) {
// exchange wildfly/undertow for elytron one
clazz = InfinispanSessionCacheIdMapperUpdater.class.getName();
}
updater = invokeAddTokenStoreUpdaterMethod(clazz, servletContext, updater);
if (updater instanceof AutoCloseable) {
toClose.add((AutoCloseable) updater);
}
}
}
} finally {
setIdMapperUpdater(updater);
}
}
use of org.keycloak.adapters.spi.SessionIdMapperUpdater in project keycloak by keycloak.
the class KeycloakHttpServerAuthenticationMechanism method getSessionIdMapperUpdater.
private SessionIdMapperUpdater getSessionIdMapperUpdater(HttpServerRequest request) {
HttpScope scope = request.getScope(Scope.APPLICATION);
SessionIdMapperUpdater res = scope == null ? null : (SessionIdMapperUpdater) scope.getAttachment(KeycloakConfigurationServletListener.ADAPTER_SESSION_ID_MAPPER_UPDATER_ATTRIBUTE_ELYTRON);
return res == null ? this.idMapperUpdater : res;
}
Aggregations