OutOfMemoryError at elytron adapter

closes #20540
This commit is contained in:
mposolda 2023-05-25 10:55:55 +02:00 committed by Marek Posolda
parent c187c17945
commit 47a304bea2
2 changed files with 12 additions and 4 deletions

View file

@ -48,11 +48,13 @@ class KeycloakHttpServerAuthenticationMechanism implements HttpServerAuthenticat
private final Map<String, ?> properties;
private final CallbackHandler callbackHandler;
private final AdapterDeploymentContext deploymentContext;
private final NodesRegistrationManagement nodesRegistrationManagement;
public KeycloakHttpServerAuthenticationMechanism(Map<String, ?> properties, CallbackHandler callbackHandler, AdapterDeploymentContext deploymentContext) {
public KeycloakHttpServerAuthenticationMechanism(Map<String, ?> properties, CallbackHandler callbackHandler, AdapterDeploymentContext deploymentContext, NodesRegistrationManagement nodesRegistrationManagement) {
this.properties = properties;
this.callbackHandler = callbackHandler;
this.deploymentContext = deploymentContext;
this.nodesRegistrationManagement = nodesRegistrationManagement;
}
@Override
@ -129,8 +131,6 @@ class KeycloakHttpServerAuthenticationMechanism implements HttpServerAuthenticat
}
private boolean preActions(ElytronHttpFacade httpFacade, AdapterDeploymentContext deploymentContext) {
NodesRegistrationManagement nodesRegistrationManagement = new NodesRegistrationManagement();
nodesRegistrationManagement.tryRegister(httpFacade.getDeployment());
PreAuthActionsHandler preActions = new PreAuthActionsHandler(UserSessionManagement.class.cast(httpFacade.getTokenStore()), deploymentContext, httpFacade);

View file

@ -19,6 +19,7 @@
package org.keycloak.adapters.elytron;
import org.keycloak.adapters.AdapterDeploymentContext;
import org.keycloak.adapters.NodesRegistrationManagement;
import org.wildfly.security.http.HttpAuthenticationException;
import org.wildfly.security.http.HttpServerAuthenticationMechanism;
import org.wildfly.security.http.HttpServerAuthenticationMechanismFactory;
@ -33,6 +34,7 @@ import java.util.Map;
public class KeycloakHttpServerAuthenticationMechanismFactory implements HttpServerAuthenticationMechanismFactory {
private final AdapterDeploymentContext deploymentContext;
private final NodesRegistrationManagement nodesRegistrationManagement;
/**
* <p>Creates a new instance.
@ -45,6 +47,7 @@ public class KeycloakHttpServerAuthenticationMechanismFactory implements HttpSer
public KeycloakHttpServerAuthenticationMechanismFactory(AdapterDeploymentContext deploymentContext) {
this.deploymentContext = deploymentContext;
this.nodesRegistrationManagement = new NodesRegistrationManagement();
}
@Override
@ -59,9 +62,14 @@ public class KeycloakHttpServerAuthenticationMechanismFactory implements HttpSer
mechanismProperties.putAll(properties);
if (KeycloakHttpServerAuthenticationMechanism.NAME.equals(mechanismName)) {
return new KeycloakHttpServerAuthenticationMechanism(properties, callbackHandler, this.deploymentContext);
return new KeycloakHttpServerAuthenticationMechanism(properties, callbackHandler, this.deploymentContext, nodesRegistrationManagement);
}
return null;
}
@Override
public void shutdown() {
this.nodesRegistrationManagement.stop();
}
}