Skip to content

Commit

Permalink
[WFCORE-5279] Update capabilities, dependencies/dep processor
Browse files Browse the repository at this point in the history
[WFCORE-5279] commented out keystore/manager objects, added missing capability references
[WFCORE-5279] Add missing deps, correct capability names
[WFCORE-5279] Correct subsystem name for test cases
[WFCORE-5279] Correct feature-pack ssl dep, test error codes
[WFCORE-5279] Add processor for default SSL context
  • Loading branch information
jessicarod7 committed Oct 19, 2022
1 parent e06afe6 commit 988b171
Show file tree
Hide file tree
Showing 24 changed files with 306 additions and 132 deletions.
4 changes: 4 additions & 0 deletions feature-pack/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -139,5 +139,9 @@
<artifactId>elytron-tls-subsystem</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.wildfly.security</groupId>
<artifactId>wildfly-elytron-ssl-common</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

<resources>
<artifact name="${org.wildfly.extras.elytron-tls:elytron-tls-dependency}"/>
<artifact name="${org.wildfly.security:wildfly-elytron-ssl-common"></artifact>
<artifact name="${org.wildfly.security:wildfly-elytron-ssl-common}"/>
</resources>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

<dependencies>
<!-- Typical module dependencies for a subsystem -->
<module name="java.security.sasl"/>
<module name="org.jboss.as.controller"/>
<module name="org.jboss.as.server"/>
<module name="org.jboss.logging"/>
Expand All @@ -32,9 +33,10 @@
<module name="org.jboss.weld.api"/>
<module name="org.jboss.weld.core"/>
<module name="org.jboss.weld.spi"/>
<module name="org.wildfly.security.base"/>
<module name="org.wildfly.common"/>
<module name="org.wildfly.security.elytron-base"/>
<!-- TODO: Remove this module once key store and manager objects are implemented -->
<module name="org.wildly.extension.elytron"/>
<module name="org.wildfly.extension.elytron"/>
<module name="org.wildfly.security.elytron-web.undertow-server"/>
<module name="org.wildfly.elytron-tls-dependency"/>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/
package org.wildfly.extension.elytron.tls.subsystem;

import static org.wildfly.extension.elytron.tls.subsystem.Capabilities.ELYTRON_CAPABILITY;
import static org.wildfly.extension.elytron.tls.subsystem.Capabilities.ELYTRON_TLS_SUBSYSTEM_CAPABILITY_NAME;

import java.util.Collections;
import java.util.Set;
Expand All @@ -36,7 +36,7 @@
*
* @author <a href="mailto:[email protected]">Darran Lofthouse</a>
*/
class BaseAddHandler extends AbstractAddStepHandler implements org.wildfly.extension.elytron.tls.subsystem.ElytronOperationStepHandler {
class BaseAddHandler extends AbstractAddStepHandler implements ElytronOperationStepHandler {

private final Set<RuntimeCapability> runtimeCapabilities;

Expand Down Expand Up @@ -81,7 +81,7 @@ protected void recordCapabilitiesAndRequirements(OperationContext context, Model
super.recordCapabilitiesAndRequirements(context, operation, resource);
final String pathValue = context.getCurrentAddressValue();
for (RuntimeCapability r : runtimeCapabilities) {
context.registerAdditionalCapabilityRequirement(ELYTRON_CAPABILITY, r.isDynamicallyNamed() ? r.getDynamicName(pathValue) : r.getName(), null);
context.registerAdditionalCapabilityRequirement(ELYTRON_TLS_SUBSYSTEM_CAPABILITY_NAME, r.isDynamicallyNamed() ? r.getDynamicName(pathValue) : r.getName(), null);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ class Capabilities {

private static final String WILDFLY_SECURITY_CAPABILITY_BASE = "org.wildfly.security.";

private static final String ELYTRON_TLS_SUBSYSTEM_CAPABILITY_NAME = "org.wildfly.extras.elytron-tls";

static final String ELYTRON_TLS_SUBSYSTEM_CAPABILITY_NAME = "org.wildfly.extras.elytron-tls";
static final RuntimeCapability<Void> ELYTRON_TLS_RUNTIME_CAPABILITY = RuntimeCapability.Builder
.of(ELYTRON_TLS_SUBSYSTEM_CAPABILITY_NAME)
.addRequirements(ElytronTlsExtension.WELD_CAPABILITY_NAME)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class CertificateAuthorityAccountDefinition extends SimpleResourceDefinition {
static final SimpleAttributeDefinition KEY_STORE = new SimpleAttributeDefinitionBuilder(Constants.KEY_STORE, ModelType.STRING, false)
.setAttributeGroup(Constants.ACCOUNT_KEY)
.setMinSize(1)
.setAlternatives(Constants.KEY_STORE_OBJECT)
// .setAlternatives(Constants.KEY_STORE_OBJECT)
.setRestartAllServices()
.setCapabilityReference(KEY_STORE_CAPABILITY, CERTIFICATE_AUTHORITY_ACCOUNT_CAPABILITY)
.build();
Expand All @@ -113,6 +113,7 @@ class CertificateAuthorityAccountDefinition extends SimpleResourceDefinition {
.setMinSize(1)
.setAlternatives(Constants.KEY_STORE)
.setRestartAllServices()
.setCapabilityReference(KEY_STORE_CAPABILITY, CERTIFICATE_AUTHORITY_ACCOUNT_CAPABILITY)
.build();

static final SimpleAttributeDefinition ALIAS = new SimpleAttributeDefinitionBuilder(Constants.ALIAS, ModelType.STRING, false)
Expand All @@ -126,7 +127,7 @@ class CertificateAuthorityAccountDefinition extends SimpleResourceDefinition {
.setAttributeGroup(Constants.ACCOUNT_KEY)
.build();

private static final AttributeDefinition[] ATTRIBUTES = new AttributeDefinition[] { CERTIFICATE_AUTHORITY, CONTACT_URLS, KEY_STORE, KEY_STORE_OBJECT, ALIAS, CREDENTIAL_REFERENCE };
private static final AttributeDefinition[] ATTRIBUTES = new AttributeDefinition[] { CERTIFICATE_AUTHORITY, CONTACT_URLS, KEY_STORE, /* KEY_STORE_OBJECT, */ ALIAS, CREDENTIAL_REFERENCE };

static final SimpleAttributeDefinition AGREE_TO_TERMS_OF_SERVICE = new SimpleAttributeDefinitionBuilder(Constants.AGREE_TO_TERMS_OF_SERVICE, ModelType.BOOLEAN, false)
.setAllowExpression(true)
Expand Down Expand Up @@ -197,7 +198,7 @@ protected void performRuntime(OperationContext context, ModelNode operation, Res
final String alias = ALIAS.resolveModelAttribute(context, model).asString();

String keyStoreName = KEY_STORE.resolveModelAttribute(context, model).asString();
final ModelNode keyStoreObject = KEY_STORE_OBJECT.resolveModelAttribute(context, model);
/* final ModelNode keyStoreObject = KEY_STORE_OBJECT.resolveModelAttribute(context, model);
if (keyStoreName == null) {
if (keyStoreObject == null) {
LOGGER.missingKeyStoreDefinition();
Expand All @@ -207,6 +208,9 @@ protected void performRuntime(OperationContext context, ModelNode operation, Res
if (keyStoreObject != null) {
LOGGER.multipleKeystoreDefinitions();
}
} */
if (keyStoreName == null) {
LOGGER.missingKeyStoreDefinition();
}
final String finalKeyStoreName = keyStoreName;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

import java.util.concurrent.atomic.AtomicReference;

import javax.net.ssl.SSLContext;

import org.jboss.as.controller.Extension;
import org.jboss.as.controller.ExtensionContext;
import org.jboss.as.controller.ModelVersion;
Expand All @@ -32,6 +34,7 @@
import org.jboss.as.controller.parsing.ExtensionParsingContext;
import org.jboss.as.controller.registry.ImmutableManagementResourceRegistration;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.jboss.as.server.deployment.AttachmentKey;
import org.jboss.msc.service.ServiceController;
import org.jboss.msc.service.ServiceName;
import org.jboss.msc.service.ServiceRegistry;
Expand Down Expand Up @@ -63,6 +66,8 @@ public class ElytronTlsExtension implements Extension {

public static final String WELD_CAPABILITY_NAME = "org.wildfly.weld";

public static final AttachmentKey<SSLContext> SSL_CONTEXT_KEY = AttachmentKey.create(SSLContext.class);

private static final String RESOURCE_NAME = ElytronTlsExtension.class.getPackage().getName() + ".LocalDescriptions";

protected static final ModelVersion VERSION_1_0_0 = ModelVersion.create(1, 0, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@

import static org.jboss.as.controller.OperationContext.Stage.RUNTIME;
import static org.jboss.as.server.deployment.Phase.DEPENDENCIES;
import static org.jboss.as.server.deployment.Phase.STRUCTURE;
import static org.jboss.as.server.deployment.Phase.STRUCTURE_ELYTRON_EXPRESSION_RESOLVER;
import static org.jboss.as.server.deployment.Phase.CONFIGURE_DEFAULT_SSL_CONTEXT;
import static org.jboss.as.server.deployment.Phase.CONFIGURE_MODULE;
import static org.wildfly.extension.elytron.tls.subsystem.Capabilities.ELYTRON_TLS_RUNTIME_CAPABILITY;
import static org.wildfly.extension.elytron.tls.subsystem.Capabilities.PROVIDERS_CAPABILITY;
import static org.wildfly.extension.elytron.tls.subsystem.Capabilities.SSL_CONTEXT_CAPABILITY;
Expand Down Expand Up @@ -66,9 +70,11 @@
import org.jboss.msc.service.ServiceTarget;
import org.wildfly.extension.elytron.tls.subsystem._private.ElytronTLSLogger;
import org.wildfly.extension.elytron.tls.subsystem.deployment.DependencyProcessor;
import org.wildfly.extension.elytron.tls.subsystem.expression.DeploymentExpressionResolverProcessor;

/**
* @author <a href="mailto:[email protected]">Kabir Khan</a>
* @author <a href="mailto:[email protected]">Cameron Rodriguez</a>
*/
public class ElytronTlsSubsystemDefinition extends PersistentResourceDefinition {

Expand Down Expand Up @@ -254,12 +260,21 @@ protected void performBoottime(OperationContext context, ModelNode operation, Mo
serviceBuilder.setInstance(defaultSSLContextService).install();
}

context.addStep(new AbstractDeploymentChainStep() {
public void execute(DeploymentProcessorTarget processorTarget) {
final int DEPENDENCIES_TEMPLATE = 6304;
processorTarget.addDeploymentProcessor(ElytronTlsExtension.SUBSYSTEM_NAME, DEPENDENCIES, DEPENDENCIES_TEMPLATE, new DependencyProcessor());
}
}, RUNTIME);
if(context.isNormalServer()){
context.addStep(new AbstractDeploymentChainStep() {
@Override
public void execute(DeploymentProcessorTarget processorTarget) {
final int DEPENDENCIES_ELYTRON_TLS = 0x0C60;
final int STRUCTURE_ELYTRON_TLS_EXPRESSION_RESOLVER = 0x0490;

processorTarget.addDeploymentProcessor(ElytronTlsExtension.SUBSYSTEM_NAME, STRUCTURE, STRUCTURE_ELYTRON_TLS_EXPRESSION_RESOLVER, new DeploymentExpressionResolverProcessor());
processorTarget.addDeploymentProcessor(ElytronTlsExtension.SUBSYSTEM_NAME, DEPENDENCIES, DEPENDENCIES_ELYTRON_TLS, new DependencyProcessor());
if (defaultSSLContext != null) {
processorTarget.addDeploymentProcessor(ElytronTlsExtension.SUBSYSTEM_NAME, CONFIGURE_MODULE, CONFIGURE_DEFAULT_SSL_CONTEXT, new SSLContextDependencyProcessor());
}
}
}, RUNTIME);
}

ElytronTLSLogger.LOGGER.activatingSubsystem();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@
import org.jboss.as.controller.PersistentResourceXMLParser;

/**
* A parser for the Elytron TLS subsystem.
*
* @author <a href="mailto:[email protected]">Kabir Khan</a>
* @author <a href="mailto:[email protected]">Cameron Rodriguez</a>
*/
public class ElytronTlsSubsystemParser_1_0 extends PersistentResourceXMLParser {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
import java.text.SimpleDateFormat;
import java.util.Date;

import org.jboss.as.controller.AbstractWriteAttributeHandler;
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.ObjectTypeAttributeDefinition;
import org.jboss.as.controller.OperationContext;
Expand Down Expand Up @@ -80,7 +79,7 @@
*/
final class KeyStoreDefinition extends SimpleResourceDefinition {

static final ServiceUtil<KeyStore> KEY_STORE_UTIL = ServiceUtil.newInstance(KEY_STORE_RUNTIME_CAPABILITY, Constants.KEY_STORE_OBJECT, KeyStore.class);
static final ServiceUtil<KeyStore> KEY_STORE_UTIL = ServiceUtil.newInstance(KEY_STORE_RUNTIME_CAPABILITY, Constants.KEY_STORE, KeyStore.class);

static final SimpleAttributeDefinition TYPE = new SimpleAttributeDefinitionBuilder(Constants.TYPE, ModelType.STRING, true)
.setAttributeGroup(Constants.IMPLEMENTATION)
Expand Down Expand Up @@ -121,7 +120,7 @@ final class KeyStoreDefinition extends SimpleResourceDefinition {

// Resource Resolver

private static final StandardResourceDescriptionResolver RESOURCE_RESOLVER = ElytronTlsExtension.getResourceDescriptionResolver(Constants.KEY_STORE_OBJECT);
private static final StandardResourceDescriptionResolver RESOURCE_RESOLVER = ElytronTlsExtension.getResourceDescriptionResolver(Constants.KEY_STORE);

// Runtime Attributes

Expand Down Expand Up @@ -151,10 +150,10 @@ final class KeyStoreDefinition extends SimpleResourceDefinition {

private static final KeyStoreAddHandler ADD = new KeyStoreAddHandler();
private static final OperationStepHandler REMOVE = new TrivialCapabilityServiceRemoveHandler(ADD, KEY_STORE_RUNTIME_CAPABILITY);
private static final AbstractWriteAttributeHandler WRITE = new ElytronReloadRequiredWriteAttributeHandler(CONFIG_ATTRIBUTES);
private static final ElytronReloadRequiredWriteAttributeHandler WRITE = new ElytronReloadRequiredWriteAttributeHandler(CONFIG_ATTRIBUTES);

KeyStoreDefinition() {
super(new Parameters(PathElement.pathElement(Constants.KEY_STORE_OBJECT), RESOURCE_RESOLVER)
super(new Parameters(PathElement.pathElement(Constants.KEY_STORE), RESOURCE_RESOLVER)
.setAddHandler(ADD)
.setRemoveHandler(REMOVE)
.setAddRestartLevel(OperationEntry.Flag.RESTART_RESOURCE_SERVICES)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package org.wildfly.extension.elytron.tls.subsystem;

import static org.wildfly.extension.elytron.tls.subsystem.Constants.KEY_STORE_OBJECT;
import static org.wildfly.extension.elytron.tls.subsystem.Constants.KEY_STORE;
import static org.wildfly.extension.elytron.tls.subsystem.Constants.KEY_STORES;

import org.jboss.as.controller.PathElement;
Expand All @@ -25,7 +25,7 @@

class KeyStoreParser {

final PersistentResourceXMLDescription keyStoreParser_1_0 = PersistentResourceXMLDescription.builder(PathElement.pathElement(KEY_STORE_OBJECT))
final PersistentResourceXMLDescription keyStoreParser_1_0 = PersistentResourceXMLDescription.builder(PathElement.pathElement(KEY_STORE))
.setXmlWrapperElement(KEY_STORES)
.addAttribute(KeyStoreDefinition.CREDENTIAL_REFERENCE)
.addAttribute(KeyStoreDefinition.TYPE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

package org.wildfly.extension.elytron.tls.subsystem;

import static org.wildfly.extension.elytron.tls.subsystem.Constants.KEY_MANAGER_OBJECT;
import static org.wildfly.extension.elytron.tls.subsystem.Constants.KEY_MANAGER;
import static org.wildfly.extension.elytron.tls.subsystem.Constants.KEY_MANAGERS;
import static org.wildfly.extension.elytron.tls.subsystem.Constants.TRUST_MANAGER_OBJECT;
import static org.wildfly.extension.elytron.tls.subsystem.Constants.TRUST_MANAGER;
import static org.wildfly.extension.elytron.tls.subsystem.Constants.TRUST_MANAGERS;

import org.jboss.as.controller.PathElement;
Expand All @@ -27,7 +27,7 @@

class ManagerParsers {

final PersistentResourceXMLDescription keyManagerParser_1_0 = PersistentResourceXMLDescription.builder(PathElement.pathElement(KEY_MANAGER_OBJECT))
final PersistentResourceXMLDescription keyManagerParser_1_0 = PersistentResourceXMLDescription.builder(PathElement.pathElement(KEY_MANAGER))
.setXmlWrapperElement(KEY_MANAGERS)
.addAttribute(SSLContextDefinitions.ALGORITHM)
.addAttribute(SSLContextDefinitions.KEY_STORE)
Expand All @@ -39,7 +39,7 @@ class ManagerParsers {
.addAttribute(CredentialReference.getAttributeDefinition())
.build();

final PersistentResourceXMLDescription trustManagerParser_1_0 = PersistentResourceXMLDescription.builder(PathElement.pathElement(TRUST_MANAGER_OBJECT))
final PersistentResourceXMLDescription trustManagerParser_1_0 = PersistentResourceXMLDescription.builder(PathElement.pathElement(TRUST_MANAGER))
.setXmlWrapperElement(TRUST_MANAGERS)
.addAttribute(SSLContextDefinitions.ALGORITHM)
.addAttribute(SSLContextDefinitions.KEY_STORE)
Expand Down
Loading

0 comments on commit 988b171

Please sign in to comment.