Skip to content

Commit

Permalink
Merge pull request #6090 from pferraro/WFCORE-6911
Browse files Browse the repository at this point in the history
WFCORE-6911 Remove usage of deprecated AbstractAddStepHandler constructors in elytron subsystem
  • Loading branch information
darranl authored Jul 30, 2024
2 parents 1734306 + 85974ab commit 72a41d1
Show file tree
Hide file tree
Showing 47 changed files with 103 additions and 132 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import java.util.function.Supplier;

import org.jboss.as.controller.AbstractAddStepHandler;
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.CapabilityServiceBuilder;
import org.jboss.as.controller.ListAttributeDefinition;
import org.jboss.as.controller.OperationContext;
Expand Down Expand Up @@ -120,7 +119,7 @@ private static class AggregateComponentAddHandler<T> extends BaseAddHandler {
private AggregateComponentAddHandler(Class<T> aggregationType, Function<T[], T> aggregator,
StringListAttributeDefinition aggregateReferences, RuntimeCapability<?> runtimeCapability,
boolean dependOnProviderRegistration) {
super(runtimeCapability, aggregateReferences);
super(runtimeCapability);
this.aggregationType = aggregationType;
this.aggregator = aggregator;
this.aggregateReferences = aggregateReferences;
Expand Down Expand Up @@ -168,7 +167,7 @@ private static class AggregateApiComponentAddHandler<T> extends DoohickeyAddHand
private AggregateApiComponentAddHandler(Class<T> aggregationType, Function<T[], T> aggregator,
StringListAttributeDefinition aggregateReferences, RuntimeCapability<?> runtimeCapability, String apiCapabilityName,
boolean dependOnProviderRegistration) {
super(runtimeCapability, new AttributeDefinition[] { aggregateReferences }, apiCapabilityName);
super(runtimeCapability, apiCapabilityName);

this.aggregationType = aggregationType;
this.aggregator = aggregator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public void registerAttributes(ManagementResourceRegistration resourceRegistrati
private static class RealmAddHandler extends BaseAddHandler {

private RealmAddHandler() {
super(SECURITY_REALM_RUNTIME_CAPABILITY, ATTRIBUTES_8_0);
super(SECURITY_REALM_RUNTIME_CAPABILITY);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public void dispose() {

static ResourceDefinition getFileAuditLogResourceDefinition() {
AttributeDefinition[] attributes = new AttributeDefinition[] { PATH, RELATIVE_TO, AUTOFLUSH, SYNCHRONIZED, FORMAT, ENCODING };
AbstractAddStepHandler add = new TrivialAddHandler<SecurityEventListener>(SecurityEventListener.class, attributes, SECURITY_EVENT_LISTENER_RUNTIME_CAPABILITY) {
AbstractAddStepHandler add = new TrivialAddHandler<SecurityEventListener>(SecurityEventListener.class, SECURITY_EVENT_LISTENER_RUNTIME_CAPABILITY) {

@Override
protected ValueSupplier<SecurityEventListener> getValueSupplier(
Expand Down Expand Up @@ -260,7 +260,7 @@ public SecurityEventListener get() throws StartException {

static ResourceDefinition getPeriodicRotatingFileAuditLogResourceDefinition() {
AttributeDefinition[] attributes = new AttributeDefinition[] {PATH, RELATIVE_TO, AUTOFLUSH, SYNCHRONIZED, FORMAT, ENCODING, PERIODIC_SUFFIX };
AbstractAddStepHandler add = new TrivialAddHandler<SecurityEventListener>(SecurityEventListener.class, attributes, SECURITY_EVENT_LISTENER_RUNTIME_CAPABILITY) {
AbstractAddStepHandler add = new TrivialAddHandler<SecurityEventListener>(SecurityEventListener.class, SECURITY_EVENT_LISTENER_RUNTIME_CAPABILITY) {

@Override
protected ValueSupplier<SecurityEventListener> getValueSupplier(
Expand Down Expand Up @@ -324,7 +324,7 @@ public SecurityEventListener get() throws StartException {

static ResourceDefinition getSizeRotatingFileAuditLogResourceDefinition() {
AttributeDefinition[] attributes = new AttributeDefinition[] { PATH, RELATIVE_TO, AUTOFLUSH, SYNCHRONIZED, FORMAT, ENCODING, MAX_BACKUP_INDEX, ROTATE_ON_BOOT, ROTATE_SIZE, SIZE_SUFFIX };
AbstractAddStepHandler add = new TrivialAddHandler<SecurityEventListener>(SecurityEventListener.class, attributes, SECURITY_EVENT_LISTENER_RUNTIME_CAPABILITY) {
AbstractAddStepHandler add = new TrivialAddHandler<SecurityEventListener>(SecurityEventListener.class, SECURITY_EVENT_LISTENER_RUNTIME_CAPABILITY) {

@Override
protected ValueSupplier<SecurityEventListener> getValueSupplier(
Expand Down Expand Up @@ -396,7 +396,7 @@ public SecurityEventListener get() throws StartException {

static ResourceDefinition getSyslogAuditLogResourceDefinition() {
AttributeDefinition[] attributes = new AttributeDefinition[] { SERVER_ADDRESS, PORT, TRANSPORT, HOST_NAME, FORMAT, SSL_CONTEXT, SYSLOG_FORMAT, RECONNECT_ATTEMPTS };
AbstractAddStepHandler add = new TrivialAddHandler<SecurityEventListener>(SecurityEventListener.class, attributes, SECURITY_EVENT_LISTENER_RUNTIME_CAPABILITY) {
AbstractAddStepHandler add = new TrivialAddHandler<SecurityEventListener>(SecurityEventListener.class, SECURITY_EVENT_LISTENER_RUNTIME_CAPABILITY) {

@Override
protected ValueSupplier<SecurityEventListener> getValueSupplier(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,7 @@ class AuthenticationClientDefinitions {

static ResourceDefinition getAuthenticationClientDefinition() {

TrivialAddHandler<AuthenticationConfiguration> add = new TrivialAddHandler<AuthenticationConfiguration>(AuthenticationConfiguration.class, AUTHENTICATION_CONFIGURATION_ALL_ATTRIBUTES,
AUTHENTICATION_CONFIGURATION_RUNTIME_CAPABILITY) {
TrivialAddHandler<AuthenticationConfiguration> add = new TrivialAddHandler<>(AuthenticationConfiguration.class, AUTHENTICATION_CONFIGURATION_RUNTIME_CAPABILITY) {

@Override
protected void populateModel(final OperationContext context, final ModelNode operation, final Resource resource) throws OperationFailedException {
Expand Down Expand Up @@ -404,7 +403,7 @@ private InjectedValue<SecurityDomain> getSecurityDomain(ServiceBuilder<Authentic
static ResourceDefinition getAuthenticationContextDefinition() {
AttributeDefinition[] attributes = new AttributeDefinition[] { CONTEXT_EXTENDS, MATCH_RULES };

TrivialAddHandler<AuthenticationContext> add = new TrivialAddHandler<AuthenticationContext>(AuthenticationContext.class, attributes, AUTHENTICATION_CONTEXT_RUNTIME_CAPABILITY) {
TrivialAddHandler<AuthenticationContext> add = new TrivialAddHandler<AuthenticationContext>(AuthenticationContext.class, AUTHENTICATION_CONTEXT_RUNTIME_CAPABILITY) {

@Override
protected ValueSupplier<AuthenticationContext> getValueSupplier(ServiceBuilder<AuthenticationContext> serviceBuilder, OperationContext context, ModelNode model)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ static ResourceDefinition getHttpAuthenticationFactory() {
AttributeDefinition mechanismConfigurationAttribute = getMechanismConfiguration(HTTP_AUTHENTICATION_FACTORY_CAPABILITY);

AttributeDefinition[] attributes = new AttributeDefinition[] { securityDomainAttribute, HTTP_SERVER_MECHANISM_FACTORY, mechanismConfigurationAttribute };
AbstractAddStepHandler add = new BaseAddHandler(HTTP_AUTHENTICATION_FACTORY_RUNTIME_CAPABILITY, attributes) {
AbstractAddStepHandler add = new BaseAddHandler(HTTP_AUTHENTICATION_FACTORY_RUNTIME_CAPABILITY) {

@SuppressWarnings("unchecked")
@Override
Expand Down Expand Up @@ -458,7 +458,7 @@ static ResourceDefinition getSaslAuthenticationFactory() {

AttributeDefinition[] attributes = new AttributeDefinition[] { securityDomainAttribute, SASL_SERVER_FACTORY, mechanismConfigurationAttribute };

AbstractAddStepHandler add = new TrivialAddHandler<SaslAuthenticationFactory>(SaslAuthenticationFactory.class, ServiceController.Mode.ACTIVE, ServiceController.Mode.PASSIVE, attributes, SASL_AUTHENTICATION_FACTORY_RUNTIME_CAPABILITY) {
AbstractAddStepHandler add = new TrivialAddHandler<SaslAuthenticationFactory>(SaslAuthenticationFactory.class, ServiceController.Mode.ACTIVE, ServiceController.Mode.PASSIVE, SASL_AUTHENTICATION_FACTORY_RUNTIME_CAPABILITY) {

@Override
protected ValueSupplier<SaslAuthenticationFactory> getValueSupplier(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,14 @@
*/
class BaseAddHandler extends AbstractAddStepHandler implements ElytronOperationStepHandler {

private final Set<RuntimeCapability> runtimeCapabilities;
private final Set<RuntimeCapability<?>> runtimeCapabilities;

/**
* Constructor of the add handler that takes an array of {@link AttributeDefinition}.
*
* @param attributes the {@link AttributeDefinition} instances associated with this resource.
*/
BaseAddHandler(AttributeDefinition... attributes) {
super(attributes);
BaseAddHandler() {
this.runtimeCapabilities = Collections.emptySet();
}

Expand All @@ -43,8 +42,7 @@ class BaseAddHandler extends AbstractAddStepHandler implements ElytronOperationS
* @param runtimeCapability the {@link RuntimeCapability} that will be provided at runtime.
* @param attributes the {@link AttributeDefinition} instances associated with this resource.
*/
BaseAddHandler(RuntimeCapability<?> runtimeCapability, AttributeDefinition... attributes) {
super(attributes);
BaseAddHandler(RuntimeCapability<?> runtimeCapability) {
this.runtimeCapabilities = Collections.singleton(runtimeCapability);
}

Expand All @@ -56,8 +54,7 @@ class BaseAddHandler extends AbstractAddStepHandler implements ElytronOperationS
* @param capabilities a {@link Set} of capabilitiies that will be added.
* @param attributes the {@link AttributeDefinition} instances associated with this resource.
*/
BaseAddHandler(Set<RuntimeCapability> capabilities, AttributeDefinition... attributes) {
super(attributes);
BaseAddHandler(Set<RuntimeCapability<?>> capabilities) {
this.runtimeCapabilities = capabilities;
}

Expand All @@ -67,7 +64,7 @@ class BaseAddHandler extends AbstractAddStepHandler implements ElytronOperationS
protected void recordCapabilitiesAndRequirements(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException {
super.recordCapabilitiesAndRequirements(context, operation, resource);
final String pathValue = context.getCurrentAddressValue();
for (RuntimeCapability r : runtimeCapabilities) {
for (RuntimeCapability<?> r : runtimeCapabilities) {
context.registerAdditionalCapabilityRequirement(ELYTRON_CAPABILITY, r.isDynamicallyNamed() ? r.getDynamicName(pathValue) : r.getName(), null);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public void registerOperations(ManagementResourceRegistration resourceRegistrati
private static class RealmAddHandler extends BaseAddHandler {

private RealmAddHandler() {
super(SECURITY_REALM_RUNTIME_CAPABILITY, ATTRIBUTES);
super(SECURITY_REALM_RUNTIME_CAPABILITY);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public CertificateAuthorityAttributeDefinition build() {
private static class CertificateAuthorityAccountAddHandler extends BaseAddHandler {

private CertificateAuthorityAccountAddHandler() {
super(CERTIFICATE_AUTHORITY_ACCOUNT_RUNTIME_CAPABILITY, ATTRIBUTES);
super(CERTIFICATE_AUTHORITY_ACCOUNT_RUNTIME_CAPABILITY);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public void registerAttributes(ManagementResourceRegistration resourceRegistrati

private static class CertificateAuthorityAddHandler extends BaseAddHandler {
private CertificateAuthorityAddHandler() {
super(CERTIFICATE_AUTHORITY_RUNTIME_CAPABILITY, ATTRIBUTES);
super(CERTIFICATE_AUTHORITY_RUNTIME_CAPABILITY);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ private static Class<? extends Credential> fromEntryType(final String entryTyoe)
private static class CredentialStoreAddHandler extends DoohickeyAddHandler<CredentialStore> {

private CredentialStoreAddHandler() {
super(CREDENTIAL_STORE_RUNTIME_CAPABILITY, CONFIG_ATTRIBUTES, CREDENTIAL_STORE_API_CAPABILITY);
super(CREDENTIAL_STORE_RUNTIME_CAPABILITY, CREDENTIAL_STORE_API_CAPABILITY);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@
import java.lang.reflect.Method;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.function.Function;

import org.jboss.as.controller.AbstractAddStepHandler;
Expand Down Expand Up @@ -92,7 +91,7 @@ private static class ComponentAddHandler<C, T> extends BaseAddHandler {
private final Function<C, T> wrapper;

private ComponentAddHandler(Class<C> serviceType, Function<C, T> wrapper, RuntimeCapability<?> ... runtimeCapabilities) {
super(new HashSet<>(Arrays.asList(runtimeCapabilities)), ATTRIBUTES);
super(Set.of(runtimeCapabilities));
this.runtimeCapabilities = runtimeCapabilities;
this.serviceType = serviceType;
this.wrapper = wrapper;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ private static TrivialService.ValueSupplier<DirContextSupplier> obtainDirContext
};
}

private static final AbstractAddStepHandler ADD = new BaseAddHandler(DIR_CONTEXT_RUNTIME_CAPABILITY, ATTRIBUTES) {
private static final AbstractAddStepHandler ADD = new BaseAddHandler(DIR_CONTEXT_RUNTIME_CAPABILITY) {
protected void populateModel(final OperationContext context, final ModelNode operation, final Resource resource) throws OperationFailedException {
super.populateModel(context, operation, resource);
handleCredentialReferenceUpdate(context, resource.getModel());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public void registerAttributes(ManagementResourceRegistration resourceRegistrati
private static class RealmAddHandler extends BaseAddHandler {

private RealmAddHandler() {
super(SECURITY_REALM_RUNTIME_CAPABILITY, ATTRIBUTES);
super(SECURITY_REALM_RUNTIME_CAPABILITY);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ private static void injectRoleDecoder(String roleDecoder, OperationContext conte
private static class DomainAddHandler extends BaseAddHandler {

private DomainAddHandler() {
super(SECURITY_DOMAIN_RUNTIME_CAPABILITY, ATTRIBUTES);
super(SECURITY_DOMAIN_RUNTIME_CAPABILITY);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import java.util.function.Consumer;

import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.CapabilityServiceBuilder;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
Expand All @@ -31,8 +30,8 @@ abstract class DoohickeyAddHandler<T> extends BaseAddHandler {
private final RuntimeCapability<?> runtimeCapability;
private final String apiCapabilityName;

public DoohickeyAddHandler(RuntimeCapability<?> runtimeCapability, AttributeDefinition[] configAttributes, String apiCapabilityName) {
super(runtimeCapability, configAttributes);
public DoohickeyAddHandler(RuntimeCapability<?> runtimeCapability, String apiCapabilityName) {
super(runtimeCapability);
this.runtimeCapability = runtimeCapability;
this.apiCapabilityName = apiCapabilityName;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -431,14 +431,10 @@ private static SecurityPropertyService uninstallSecurityPropertyService(Operatio

private static class ElytronAdd extends AbstractBoottimeAddStepHandler implements ElytronOperationStepHandler {

private ElytronAdd() {
super(DEFAULT_AUTHENTICATION_CONTEXT, INITIAL_PROVIDERS, FINAL_PROVIDERS, DISALLOWED_PROVIDERS, SECURITY_PROPERTIES, REGISTER_JASPI_FACTORY, DEFAULT_SSL_CONTEXT);
}

@Override
protected void populateModel(ModelNode operation, ModelNode model) throws OperationFailedException {
protected void populateModel(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException {
Version.getVersion();
super.populateModel(operation, model);
super.populateModel(context, operation, resource);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public static SubjectAltNameType fromName(final String name) {

static ResourceDefinition getX500SubjectEvidenceDecoderDefinition() {
final AttributeDefinition[] attributes = new AttributeDefinition[] {};
AbstractAddStepHandler add = new TrivialAddHandler<EvidenceDecoder>(EvidenceDecoder.class, attributes, EVIDENCE_DECODER_RUNTIME_CAPABILITY) {
AbstractAddStepHandler add = new TrivialAddHandler<EvidenceDecoder>(EvidenceDecoder.class, EVIDENCE_DECODER_RUNTIME_CAPABILITY) {

@Override
protected ValueSupplier<EvidenceDecoder> getValueSupplier(ServiceBuilder<EvidenceDecoder> serviceBuilder,
Expand All @@ -116,7 +116,7 @@ protected ValueSupplier<EvidenceDecoder> getValueSupplier(ServiceBuilder<Evidenc

static ResourceDefinition getX509SubjectAltNameEvidenceDecoderDefinition() {
final AttributeDefinition[] attributes = new AttributeDefinition[] { ALT_NAME_TYPE, SEGMENT };
AbstractAddStepHandler add = new TrivialAddHandler<EvidenceDecoder>(EvidenceDecoder.class, attributes, EVIDENCE_DECODER_RUNTIME_CAPABILITY) {
AbstractAddStepHandler add = new TrivialAddHandler<EvidenceDecoder>(EvidenceDecoder.class, EVIDENCE_DECODER_RUNTIME_CAPABILITY) {

@Override
protected ValueSupplier<EvidenceDecoder> getValueSupplier(ServiceBuilder<EvidenceDecoder> serviceBuilder,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ private static class ExpressionResolverAddHandler extends BaseAddHandler {

ExpressionResolverAddHandler(RuntimeCapability<ExpressionResolverExtension> expressionResolverRuntimeCapability,
AtomicReference<ExpressionResolverExtension> resolverRef) {
super(expressionResolverRuntimeCapability, ATTRIBUTES);
super(expressionResolverRuntimeCapability);
this.expressionResolver = (ElytronExpressionResolver) expressionResolverRuntimeCapability.getRuntimeAPI();
this.resolverRef = resolverRef;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public void registerAttributes(ManagementResourceRegistration resourceRegistrati
private static class RealmAddHandler extends BaseAddHandler {

private RealmAddHandler() {
super(SECURITY_REALM_RUNTIME_CAPABILITY, ATTRIBUTES);
super(SECURITY_REALM_RUNTIME_CAPABILITY);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ protected void executeRuntimeStep(final OperationContext context, final ModelNod
private static class RealmAddHandler extends BaseAddHandler {

private RealmAddHandler() {
super(SECURITY_REALM_RUNTIME_CAPABILITY, ALL_ATTRIBUTES);
super(SECURITY_REALM_RUNTIME_CAPABILITY);
}

private static SecretKey getSecretKey(OperationContext context, String credentialStoreReference, String alias) throws OperationFailedException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ protected void executeRuntimeStep(OperationContext context, ModelNode operation)
private static class KeyStoreAddHandler extends BaseAddHandler {

private KeyStoreAddHandler() {
super(KEY_STORE_RUNTIME_CAPABILITY, CONFIG_ATTRIBUTES);
super(KEY_STORE_RUNTIME_CAPABILITY);
}

@Override
Expand Down
Loading

0 comments on commit 72a41d1

Please sign in to comment.