Skip to content

Commit

Permalink
WFLY-8099 Define modcluster/ssl vs ssl-context priority
Browse files Browse the repository at this point in the history
  • Loading branch information
rhusar committed Feb 14, 2017
1 parent d3a0ad8 commit 393c5cb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Expand Up @@ -69,6 +69,7 @@
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.stream.Stream;
Expand Down Expand Up @@ -212,13 +213,17 @@ public Builder<ModClusterConfiguration> configure(OperationContext context, Mode

// Elytron-based security support

optionalString(SSL_CONTEXT.resolveModelAttribute(context, model)).ifPresent(
Optional<String> sslContextRef = optionalString(SSL_CONTEXT.resolveModelAttribute(context, model));
sslContextRef.ifPresent(
sslContext -> this.sslContextDependency = new InjectedValueDependency<>(context.getCapabilityServiceName(SSL_CONTEXT_CAPABILITY_NAME, sslContext, SSLContext.class), SSLContext.class)
);

// Legacy security support

if (model.get(ModClusterSSLResourceDefinition.PATH.getKeyValuePair()).isDefined()) {
if (sslContextRef.isPresent()) {
throw ROOT_LOGGER.bothElytronAndLegacySslContextDefined();
}
ModelNode sslModel = model.get(ModClusterSSLResourceDefinition.PATH.getKeyValuePair());

ModClusterConfig sslConfiguration = new ModClusterConfig();
Expand Down
Expand Up @@ -187,4 +187,10 @@ interface ModClusterLogger extends BasicLogger {
*/
@Message(id = 19, value = "'%s' is not a valid value for 'excludedContexts'.")
IllegalArgumentException excludedContextsWrongFormat(String trimmedContexts);

/**
* Exception thrown when user configures both 'ssl-context' attribute reference and the mod-cluster-config=configuration/ssl=configuration.
*/
@Message(id = 20, value = "Only one of 'ssl-context' attribute or 'ssl' resource can be defined!")
IllegalStateException bothElytronAndLegacySslContextDefined();
}

0 comments on commit 393c5cb

Please sign in to comment.