Skip to content

Commit

Permalink
WFLY-7874 Configuring SSLContext in mod_cluster filter fails with "Ca…
Browse files Browse the repository at this point in the history
…pability 'org.wildfly.undertow.mod_cluster_filter.modcluster' is unknown in context 'global'."
  • Loading branch information
rhusar committed Jan 10, 2017
1 parent cdca7b8 commit 3b40dc6
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 23 deletions.
Expand Up @@ -49,9 +49,6 @@ public abstract class AbstractHandlerDefinition extends PersistentResourceDefini
new SensitivityClassification(UndertowExtension.SUBSYSTEM_NAME, "undertow-filter", false, false, false)
).wrapAsList();


protected final String name;

protected AbstractHandlerDefinition(final String name, AbstractAddStepHandler addHandler, AbstractRemoveStepHandler removeHandler) {
this(name, Constants.HANDLER, addHandler, removeHandler);
}
Expand All @@ -60,17 +57,17 @@ protected AbstractHandlerDefinition(final String name) {
this(name, Constants.HANDLER);
}


protected AbstractHandlerDefinition(final String name, String prefix, AbstractAddStepHandler addHandler, AbstractRemoveStepHandler removeHandler) {
super(PathElement.pathElement(name), UndertowExtension.getResolver(prefix, name), addHandler, removeHandler);
this.name = name;
}

protected AbstractHandlerDefinition(final String name, String prefix) {
super(PathElement.pathElement(name), UndertowExtension.getResolver(prefix, name));
this.name = name;
}

protected AbstractHandlerDefinition(final Parameters parameters) {
super(parameters);
}

@Override
public void registerOperations(ManagementResourceRegistration resourceRegistration) {
Expand Down Expand Up @@ -98,11 +95,6 @@ public Collection<AttributeDefinition> getAttributes() {
return Collections.emptyList();
}

@Override
public String getXmlElementName() {
return this.name;
}

protected static class DefaultHandlerRemove extends AbstractRemoveStepHandler {
private DefaultHandlerRemove() {

Expand Down
Expand Up @@ -35,8 +35,6 @@
public interface Handler {
Collection<AttributeDefinition> getAttributes();

String getXmlElementName();

Class<? extends HttpHandler> getHandlerClass();

HttpHandler createHttpHandler(final Predicate predicate, final ModelNode model, final HttpHandler next);
Expand Down
Expand Up @@ -58,11 +58,6 @@ public void registerOperations(ManagementResourceRegistration resourceRegistrati

}

@Override
public String getXmlElementName() {
return name;
}

public HttpHandler createHttpHandler(final Predicate predicate, final ModelNode model, HttpHandler next) {
List<AttributeDefinition> attributes = new ArrayList<>(getAttributes());
HttpHandler handler = createHandler(getHandlerClass(), model, attributes, next);
Expand Down
Expand Up @@ -36,6 +36,7 @@
import org.jboss.as.controller.SimpleAttributeDefinition;
import org.jboss.as.controller.SimpleAttributeDefinitionBuilder;
import org.jboss.as.controller.access.management.SensitiveTargetAccessConstraintDefinition;
import org.jboss.as.controller.capability.RuntimeCapability;
import org.jboss.as.controller.client.helpers.MeasurementUnit;
import org.jboss.as.controller.operations.validation.EnumValidator;
import org.jboss.as.controller.operations.validation.StringLengthValidator;
Expand All @@ -47,12 +48,14 @@
import org.wildfly.extension.undertow.AbstractHandlerDefinition;
import org.wildfly.extension.undertow.Constants;
import org.wildfly.extension.undertow.PredicateValidator;
import org.wildfly.extension.undertow.UndertowExtension;
import org.wildfly.extension.undertow.UndertowService;

import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;

import static org.jboss.as.controller.PathElement.pathElement;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;

/**
Expand All @@ -64,7 +67,9 @@
public class ModClusterDefinition extends AbstractHandlerDefinition {

private static final String MOD_CLUSTER_FILTER_CAPABILITY_NAME = "org.wildfly.undertow.mod_cluster_filter";
static final String SSL_CONTEXT_CAPABILITY = "org.wildfly.security.ssl-context";
public static final RuntimeCapability<Void> MOD_CLUSTER_FILTER_CAPABILITY = RuntimeCapability.Builder.of(MOD_CLUSTER_FILTER_CAPABILITY_NAME, true, Void.class).build();

static final String SSL_CONTEXT_CAPABILITY_NAME = "org.wildfly.security.ssl-context";

public static final AttributeDefinition MANAGEMENT_SOCKET_BINDING = new SimpleAttributeDefinitionBuilder(Constants.MANAGEMENT_SOCKET_BINDING, ModelType.STRING)
.setAllowExpression(true)
Expand Down Expand Up @@ -186,7 +191,7 @@ public class ModClusterDefinition extends AbstractHandlerDefinition {

public static final SimpleAttributeDefinition SSL_CONTEXT = new SimpleAttributeDefinitionBuilder(Constants.SSL_CONTEXT, ModelType.STRING, true)
.setAlternatives(Constants.SECURITY_REALM)
.setCapabilityReference(SSL_CONTEXT_CAPABILITY, MOD_CLUSTER_FILTER_CAPABILITY_NAME, true)
.setCapabilityReference(SSL_CONTEXT_CAPABILITY_NAME, MOD_CLUSTER_FILTER_CAPABILITY_NAME, true)
.setRestartAllServices()
.setValidator(new StringLengthValidator(1))
.build();
Expand Down Expand Up @@ -274,7 +279,11 @@ public class ModClusterDefinition extends AbstractHandlerDefinition {
public static final ModClusterDefinition INSTANCE = new ModClusterDefinition();

private ModClusterDefinition() {
super(Constants.MOD_CLUSTER, new ModClusterAdd(), new ServiceRemoveStepHandler(UndertowService.FILTER, new ModClusterAdd()));
super(new Parameters(pathElement(Constants.MOD_CLUSTER), UndertowExtension.getResolver(Constants.HANDLER, Constants.MOD_CLUSTER))
.setAddHandler(new ModClusterAdd())
.setRemoveHandler(new ServiceRemoveStepHandler(UndertowService.FILTER, new ModClusterAdd()))
.setCapabilities(MOD_CLUSTER_FILTER_CAPABILITY)
);
}

@Override
Expand Down
@@ -1,6 +1,6 @@
package org.wildfly.extension.undertow.filters;

import static org.wildfly.extension.undertow.filters.ModClusterDefinition.SSL_CONTEXT_CAPABILITY;
import static org.wildfly.extension.undertow.filters.ModClusterDefinition.SSL_CONTEXT_CAPABILITY_NAME;
import io.undertow.Handlers;
import io.undertow.UndertowOptions;
import io.undertow.client.UndertowClient;
Expand Down Expand Up @@ -278,7 +278,7 @@ static ServiceController<FilterService> install(String name, ServiceTarget servi
serviceBuilder.addDependency(IOServices.WORKER.append(ModClusterDefinition.WORKER.resolveModelAttribute(operationContext, model).asString()), XnioWorker.class, service.workerInjectedValue);

if (sslContext.isDefined()) {
serviceBuilder.addDependency(operationContext.getCapabilityServiceName(SSL_CONTEXT_CAPABILITY, sslContext.asString(), SSLContext.class), SSLContext.class, service.sslContext);
serviceBuilder.addDependency(operationContext.getCapabilityServiceName(SSL_CONTEXT_CAPABILITY_NAME, sslContext.asString(), SSLContext.class), SSLContext.class, service.sslContext);
}
if(securityRealm.isDefined()) {
SecurityRealm.ServiceUtil.addDependency(serviceBuilder, service.securityRealm, securityRealm.asString(), false);
Expand Down

0 comments on commit 3b40dc6

Please sign in to comment.