Skip to content

Commit

Permalink
Merge pull request wildfly#5592 from pferraro/WFCORE-6440
Browse files Browse the repository at this point in the history
WFCORE-6440 HttpManagementAddHandler references ServerEnvironment incorrectly
  • Loading branch information
yersan authored Aug 3, 2023
2 parents 0be7619 + da70684 commit 8ba2478
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
import org.jboss.msc.service.ServiceBuilder;
import org.jboss.msc.service.ServiceController;
import org.jboss.msc.service.ServiceName;
import org.wildfly.common.function.Functions;
import org.wildfly.security.auth.server.HttpAuthenticationFactory;
import org.wildfly.security.auth.server.SaslAuthenticationFactory;
import org.xnio.XnioWorker;
Expand Down Expand Up @@ -163,7 +164,7 @@ protected List<ServiceName> installServices(OperationContext context, HttpInterf
final Supplier<SSLContext> scSupplier = sslContext != null ? builder.requiresCapability(SSL_CONTEXT_CAPABILITY, SSLContext.class, sslContext) : null;
final UndertowHttpManagementService service = new UndertowHttpManagementService(hmConsumer, lrSupplier, mcSupplier, null, null, null, ibSupplier, sibSupplier,
rpSupplier, xwSupplier, eSupplier, hafSupplier, scSupplier, port, securePort, commonPolicy.getAllowedOrigins(), consoleMode,
environment.getProductConfig().getConsoleSlot(), commonPolicy.getConstantHeaders(), caSupplier);
Functions.constantSupplier(environment.getProductConfig().getConsoleSlot()), commonPolicy.getConstantHeaders(), caSupplier);
builder.setInstance(service);
builder.setInitialMode(onDemand ? ServiceController.Mode.ON_DEMAND : ServiceController.Mode.ACTIVE).install();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public class UndertowHttpManagementService implements Service<HttpManagement> {
private final Supplier<HttpAuthenticationFactory> httpAuthFactorySupplier;
private final Supplier<SSLContext> sslContextSupplier;
private final ConsoleMode consoleMode;
private final String consoleSlot;
private final Supplier<String> consoleSlot;
private final Map<String, List<Header>> constantHeaders;
private final Supplier<ConsoleAvailability> consoleAvailabilitySupplier;
private final Supplier<SecurityDomain> virtualSecurityDomainSupplier;
Expand Down Expand Up @@ -220,7 +220,7 @@ public UndertowHttpManagementService(final Consumer<HttpManagement> httpManageme
final Integer securePort,
final Collection<String> allowedOrigins,
final ConsoleMode consoleMode,
final String consoleSlot,
final Supplier<String> consoleSlot,
final Map<String, List<Header>> constantHeaders,
final Supplier<ConsoleAvailability> consoleAvailabilitySupplier) {
this(httpManagementConsumer, listenerRegistrySupplier, modelControllerSupplier, socketBindingSupplier,
Expand All @@ -246,7 +246,7 @@ public UndertowHttpManagementService(final Consumer<HttpManagement> httpManageme
final Integer securePort,
final Collection<String> allowedOrigins,
final ConsoleMode consoleMode,
final String consoleSlot,
final Supplier<String> consoleSlot,
final Map<String, List<Header>> constantHeaders,
final Supplier<ConsoleAvailability> consoleAvailabilitySupplier,
final Supplier<SecurityDomain> virtualSecurityDomainSupplier,
Expand Down Expand Up @@ -363,7 +363,7 @@ public synchronized void start(final StartContext context) throws StartException
.setModelController(modelController)
.setSSLContext(sslContext)
.setConsoleMode(consoleMode)
.setConsoleSlot(consoleSlot)
.setConsoleSlot(consoleSlot.get())
.setChannelUpgradeHandler(upgradeHandler)
.setManagementHttpRequestProcessor(requestProcessorSupplier.get())
.setAllowedOrigins(allowedOrigins)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ protected List<ServiceName> installServices(OperationContext context, HttpInterf
ServerLogger.ROOT_LOGGER.httpManagementInterfaceIsUnsecured();
}

ServerEnvironment environment = (ServerEnvironment) context.getServiceRegistry(false).getRequiredService(ServerEnvironmentService.SERVICE_NAME).getValue();
final CapabilityServiceBuilder<?> builder = serviceTarget.addCapability(EXTENSIBLE_HTTP_MANAGEMENT_CAPABILITY);
final Consumer<HttpManagement> hmConsumer = builder.provides(EXTENSIBLE_HTTP_MANAGEMENT_CAPABILITY);
final Supplier<ListenerRegistry> lrSupplier = builder.requires(RemotingServices.HTTP_LISTENER_REGISTRY);
Expand All @@ -158,6 +157,15 @@ protected List<ServiceName> installServices(OperationContext context, HttpInterf
final Supplier<XnioWorker> xwSupplier = builder.requires(ManagementWorkerService.SERVICE_NAME);
final Supplier<Executor> eSupplier = builder.requires(ExternalManagementRequestExecutor.SERVICE_NAME);
final Supplier<HttpAuthenticationFactory> hafSupplier = httpAuthenticationFactory != null ? builder.requiresCapability(HTTP_AUTHENTICATION_FACTORY_CAPABILITY, HttpAuthenticationFactory.class, httpAuthenticationFactory) : null;
// TODO WFCORE-6321 Expose ServerEnvironment via a capability
// Supplier<ServerEnvironment> environment = builder.requiresCapability("org.wildfly.server.environment", ServerEnvironment.class);
Supplier<ServerEnvironment> environment = builder.requires(ServerEnvironmentService.SERVICE_NAME);
Supplier<String> consoleSlot = new Supplier<>() {
@Override
public String get() {
return environment.get().getProductConfig().getConsoleSlot();
}
};
Supplier<SecurityDomain> virtualSecurityDomainSupplier = null;
Supplier<HttpServerAuthenticationMechanismFactory> virtualMechanismFactorySupplier = null;
if (VirtualDomainMarkerUtility.isVirtualDomainRequired(context)) {
Expand All @@ -170,7 +178,7 @@ protected List<ServiceName> installServices(OperationContext context, HttpInterf
final Supplier<SSLContext> scSupplier = sslContext != null ? builder.requiresCapability(SSL_CONTEXT_CAPABILITY, SSLContext.class, sslContext) : null;
final UndertowHttpManagementService undertowService = new UndertowHttpManagementService(hmConsumer, lrSupplier, mcSupplier, sbSupplier, ssbSupplier, sbmSupplier,
null, null, rpSupplier, xwSupplier, eSupplier, hafSupplier, scSupplier, null, null, commonPolicy.getAllowedOrigins(), consoleMode,
environment.getProductConfig().getConsoleSlot(), commonPolicy.getConstantHeaders(), caSupplier, virtualSecurityDomainSupplier, virtualMechanismFactorySupplier);
consoleSlot, commonPolicy.getConstantHeaders(), caSupplier, virtualSecurityDomainSupplier, virtualMechanismFactorySupplier);
builder.setInstance(undertowService);
builder.install();

Expand Down

0 comments on commit 8ba2478

Please sign in to comment.