Skip to content

Commit

Permalink
Merge pull request #6101 from pferraro/WFCORE-6922
Browse files Browse the repository at this point in the history
WFCORE-6922 Remove usage of deprecated AbstractWriteAttributeHandler constructors in elytron subsystem
  • Loading branch information
darranl authored Jul 30, 2024
2 parents fb6d955 + 6b0c3b6 commit 2c28d35
Show file tree
Hide file tree
Showing 31 changed files with 46 additions and 115 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

import javax.crypto.SecretKey;

import org.jboss.as.controller.AbstractWriteAttributeHandler;
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
Expand Down Expand Up @@ -110,9 +109,8 @@ protected AbstractCredentialStoreResourceDefinition(Parameters parameters) {
@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
AttributeDefinition[] configAttributes = getAttributeDefinitions();
AbstractWriteAttributeHandler write = new ElytronReloadRequiredWriteAttributeHandler(configAttributes);
for (AttributeDefinition current : configAttributes) {
resourceRegistration.registerReadWriteAttribute(current, null, write);
resourceRegistration.registerReadWriteAttribute(current, null, ElytronReloadRequiredWriteAttributeHandler.INSTANCE);
}
if (isServerOrHostController(resourceRegistration)) {
resourceRegistration.registerReadOnlyAttribute(STATE, new ElytronRuntimeOnlyHandler() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,8 @@ static <T> AggregateComponentDefinition<T> create(Class<T> aggregationType, Stri

AbstractAddStepHandler add = new AggregateComponentAddHandler<T>(aggregationType, aggregator, aggregateReferences, runtimeCapability, dependOnProviderRegistration);
OperationStepHandler remove = new TrivialCapabilityServiceRemoveHandler(add, runtimeCapability);
OperationStepHandler write = new ElytronReloadRequiredWriteAttributeHandler(aggregateReferences);

return new AggregateComponentDefinition<T>(aggregationType, componentName, add, remove, aggregateReferences, write, runtimeCapability);
return new AggregateComponentDefinition<T>(aggregationType, componentName, add, remove, aggregateReferences, ElytronReloadRequiredWriteAttributeHandler.INSTANCE, runtimeCapability);
}

static <T> AggregateComponentDefinition<T> create(Class<T> aggregationType, String componentName, String referencesName,
Expand All @@ -103,9 +102,8 @@ static <T> AggregateComponentDefinition<T> create(Class<T> aggregationType, Stri

AbstractAddStepHandler add = new AggregateApiComponentAddHandler<T>(aggregationType, aggregator, aggregateReferences, runtimeCapability, apiCapabilityName, dependOnProviderRegistration);
OperationStepHandler remove = new TrivialCapabilityServiceRemoveHandler(add, runtimeCapability);
OperationStepHandler write = new ElytronReloadRequiredWriteAttributeHandler(aggregateReferences);

return new AggregateComponentDefinition<T>(aggregationType, componentName, add, remove, aggregateReferences, write, runtimeCapability);
return new AggregateComponentDefinition<T>(aggregationType, componentName, add, remove, aggregateReferences, ElytronReloadRequiredWriteAttributeHandler.INSTANCE, runtimeCapability);
}

private static class AggregateComponentAddHandler<T> extends BaseAddHandler {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import java.util.List;

import org.jboss.as.controller.AbstractAddStepHandler;
import org.jboss.as.controller.AbstractWriteAttributeHandler;
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
Expand Down Expand Up @@ -94,9 +93,8 @@ class AggregateRealmDefinition extends SimpleResourceDefinition {

@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
AbstractWriteAttributeHandler write = new ElytronReloadRequiredWriteAttributeHandler(ATTRIBUTES_8_0);
for (AttributeDefinition current : ATTRIBUTES_8_0) {
resourceRegistration.registerReadWriteAttribute(current, null, write);
resourceRegistration.registerReadWriteAttribute(current, null, ElytronReloadRequiredWriteAttributeHandler.INSTANCE);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import static org.wildfly.extension.elytron.ElytronExtension.getRequiredService;

import org.jboss.as.controller.AbstractAddStepHandler;
import org.jboss.as.controller.AbstractWriteAttributeHandler;
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
Expand Down Expand Up @@ -88,9 +87,8 @@ class CachingRealmDefinition extends SimpleResourceDefinition {

@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
AbstractWriteAttributeHandler write = new ElytronReloadRequiredWriteAttributeHandler(ATTRIBUTES);
for (AttributeDefinition current : ATTRIBUTES) {
resourceRegistration.registerReadWriteAttribute(current, null, write);
resourceRegistration.registerReadWriteAttribute(current, null, ElytronReloadRequiredWriteAttributeHandler.INSTANCE);
}
}

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

import org.jboss.as.controller.AbstractAddStepHandler;
import org.jboss.as.controller.AbstractAttributeDefinitionBuilder;
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 @@ -205,8 +204,6 @@ protected void rollbackRuntime(OperationContext context, final ModelNode operati

private static final OperationStepHandler REMOVE = new TrivialCapabilityServiceRemoveHandler(ADD, CERTIFICATE_AUTHORITY_ACCOUNT_RUNTIME_CAPABILITY);

private static final AbstractWriteAttributeHandler WRITE = new ElytronReloadRequiredWriteAttributeHandler(ATTRIBUTES);

CertificateAuthorityAccountDefinition() {
super(new Parameters(PathElement.pathElement(ElytronDescriptionConstants.CERTIFICATE_AUTHORITY_ACCOUNT), ElytronExtension.getResourceDescriptionResolver(ElytronDescriptionConstants.CERTIFICATE_AUTHORITY_ACCOUNT))
.setAddHandler(ADD)
Expand All @@ -219,7 +216,7 @@ protected void rollbackRuntime(OperationContext context, final ModelNode operati
@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
for (AttributeDefinition current : ATTRIBUTES) {
resourceRegistration.registerReadWriteAttribute(current, null, WRITE);
resourceRegistration.registerReadWriteAttribute(current, null, ElytronReloadRequiredWriteAttributeHandler.INSTANCE);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
package org.wildfly.extension.elytron;

import org.jboss.as.controller.AbstractAddStepHandler;
import org.jboss.as.controller.AbstractWriteAttributeHandler;
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
Expand Down Expand Up @@ -82,7 +81,6 @@ public void validateParameter(String parameterName, ModelNode value) throws Oper
private static final AbstractAddStepHandler ADD = new CertificateAuthorityAddHandler();

private static final OperationStepHandler REMOVE = new TrivialCapabilityServiceRemoveHandler(ADD, CERTIFICATE_AUTHORITY_RUNTIME_CAPABILITY);
private static final AbstractWriteAttributeHandler WRITE = new ElytronReloadRequiredWriteAttributeHandler(ATTRIBUTES);

CertificateAuthorityDefinition() {
super(new Parameters(PathElement.pathElement(ElytronDescriptionConstants.CERTIFICATE_AUTHORITY), ElytronExtension.getResourceDescriptionResolver(ElytronDescriptionConstants.CERTIFICATE_AUTHORITY))
Expand All @@ -96,7 +94,7 @@ public void validateParameter(String parameterName, ModelNode value) throws Oper
@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
for (AttributeDefinition current : ATTRIBUTES) {
resourceRegistration.registerReadWriteAttribute(current, null, WRITE);
resourceRegistration.registerReadWriteAttribute(current, null, ElytronReloadRequiredWriteAttributeHandler.INSTANCE);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import java.util.function.Function;

import org.jboss.as.controller.AbstractAddStepHandler;
import org.jboss.as.controller.AbstractWriteAttributeHandler;
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
Expand Down Expand Up @@ -78,9 +77,8 @@ private static <C, T> Parameters addAddRemoveHandlers(Parameters parameters, Cla

@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
AbstractWriteAttributeHandler writeHandler = new ElytronReloadRequiredWriteAttributeHandler(ATTRIBUTES);
for (AttributeDefinition current : ATTRIBUTES) {
resourceRegistration.registerReadWriteAttribute(current, null, writeHandler);
resourceRegistration.registerReadWriteAttribute(current, null, ElytronReloadRequiredWriteAttributeHandler.INSTANCE);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import javax.net.ssl.SSLContext;

import org.jboss.as.controller.AbstractAddStepHandler;
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 @@ -143,9 +142,8 @@ class DirContextDefinition extends SimpleResourceDefinition {

@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
AbstractWriteAttributeHandler handler = new ElytronReloadRequiredWriteAttributeHandler(ATTRIBUTES);
for (AttributeDefinition current : ATTRIBUTES) {
resourceRegistration.registerReadWriteAttribute(current, null, handler);
resourceRegistration.registerReadWriteAttribute(current, null, ElytronReloadRequiredWriteAttributeHandler.INSTANCE);
}
}

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


import org.jboss.as.controller.AbstractAddStepHandler;
import org.jboss.as.controller.AbstractWriteAttributeHandler;
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
Expand Down Expand Up @@ -87,9 +86,8 @@ class DistributedRealmDefinition extends SimpleResourceDefinition {

@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
AbstractWriteAttributeHandler write = new ElytronReloadRequiredWriteAttributeHandler(ATTRIBUTES);
for (AttributeDefinition current : ATTRIBUTES) {
resourceRegistration.registerReadWriteAttribute(current, null, write);
resourceRegistration.registerReadWriteAttribute(current, null, ElytronReloadRequiredWriteAttributeHandler.INSTANCE);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
import org.jboss.as.controller.OperationContext.AttachmentKey;
import org.jboss.as.controller.OperationContext.Stage;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.OperationStepHandler;
import org.jboss.as.controller.PropertiesAttributeDefinition;
import org.jboss.as.controller.ReloadRequiredWriteAttributeHandler;
import org.jboss.as.controller.ResourceDefinition;
Expand Down Expand Up @@ -313,11 +312,10 @@ public void registerChildren(ManagementResourceRegistration resourceRegistration

@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
OperationStepHandler writeHandler = new ReloadRequiredWriteAttributeHandler(INITIAL_PROVIDERS, FINAL_PROVIDERS, DISALLOWED_PROVIDERS, REGISTER_JASPI_FACTORY);
resourceRegistration.registerReadWriteAttribute(INITIAL_PROVIDERS, null, writeHandler);
resourceRegistration.registerReadWriteAttribute(FINAL_PROVIDERS, null, writeHandler);
resourceRegistration.registerReadWriteAttribute(DISALLOWED_PROVIDERS, null, writeHandler);
resourceRegistration.registerReadWriteAttribute(DEFAULT_AUTHENTICATION_CONTEXT, null, new ElytronWriteAttributeHandler<Void>(DEFAULT_AUTHENTICATION_CONTEXT) {
resourceRegistration.registerReadWriteAttribute(INITIAL_PROVIDERS, null, ReloadRequiredWriteAttributeHandler.INSTANCE);
resourceRegistration.registerReadWriteAttribute(FINAL_PROVIDERS, null, ReloadRequiredWriteAttributeHandler.INSTANCE);
resourceRegistration.registerReadWriteAttribute(DISALLOWED_PROVIDERS, null, ReloadRequiredWriteAttributeHandler.INSTANCE);
resourceRegistration.registerReadWriteAttribute(DEFAULT_AUTHENTICATION_CONTEXT, null, new ElytronWriteAttributeHandler<Void>() {

@Override
protected boolean applyUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName,
Expand All @@ -337,8 +335,8 @@ protected void revertUpdateToRuntime(OperationContext context, ModelNode operati

});
resourceRegistration.registerReadWriteAttribute(SECURITY_PROPERTIES, null, new SecurityPropertiesWriteHandler(SECURITY_PROPERTIES));
resourceRegistration.registerReadWriteAttribute(REGISTER_JASPI_FACTORY, null, writeHandler);
resourceRegistration.registerReadWriteAttribute(DEFAULT_SSL_CONTEXT, null, new ElytronWriteAttributeHandler<Void>(DEFAULT_SSL_CONTEXT) {
resourceRegistration.registerReadWriteAttribute(REGISTER_JASPI_FACTORY, null, ReloadRequiredWriteAttributeHandler.INSTANCE);
resourceRegistration.registerReadWriteAttribute(DEFAULT_SSL_CONTEXT, null, new ElytronWriteAttributeHandler<Void>() {

@Override
protected boolean applyUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@
import static org.jboss.as.controller.security.CredentialReference.handleCredentialReferenceUpdate;
import static org.jboss.as.controller.security.CredentialReference.rollbackCredentialStoreUpdate;

import java.util.Collection;

import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.OperationStepHandler;
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.ReloadRequiredWriteAttributeHandler;
import org.jboss.as.controller.registry.Resource;
import org.jboss.as.controller.security.CredentialReference;
Expand All @@ -23,12 +22,11 @@
* @author <a href="mailto:thofman@redhat.com">Tomas Hofman</a>
*/
class ElytronReloadRequiredWriteAttributeHandler extends ReloadRequiredWriteAttributeHandler implements ElytronOperationStepHandler {
ElytronReloadRequiredWriteAttributeHandler(final AttributeDefinition... definitions) {
super(definitions);
}

ElytronReloadRequiredWriteAttributeHandler(final Collection<AttributeDefinition> definitions) {
super(definitions);
static final OperationStepHandler INSTANCE = new ElytronReloadRequiredWriteAttributeHandler();

private ElytronReloadRequiredWriteAttributeHandler() {
// Hide
}

@Override
Expand Down Expand Up @@ -59,7 +57,7 @@ protected boolean requiresRuntime(final OperationContext context) {
@Override
protected void revertUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode valueToRestore, ModelNode resolvedValue, Void handback) throws OperationFailedException {
if (attributeName.equals(CredentialReference.CREDENTIAL_REFERENCE)) {
rollbackCredentialStoreUpdate(getAttributeDefinition(attributeName), context, resolvedValue);
rollbackCredentialStoreUpdate(context.getResourceRegistration().getAttributeAccess(PathAddress.EMPTY_ADDRESS, attributeName).getAttributeDefinition(), context, resolvedValue);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@

package org.wildfly.extension.elytron;

import java.util.Collection;

import org.jboss.as.controller.AbstractWriteAttributeHandler;
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.OperationContext;

/**
Expand All @@ -17,13 +14,6 @@
* @author <a href="mailto:jperkins@redhat.com">James R. Perkins</a>
*/
abstract class ElytronWriteAttributeHandler<V> extends AbstractWriteAttributeHandler<V> implements ElytronOperationStepHandler {
protected ElytronWriteAttributeHandler(final AttributeDefinition... definitions) {
super(definitions);
}

protected ElytronWriteAttributeHandler(final Collection<AttributeDefinition> definitions) {
super(definitions);
}

@Override
protected boolean requiresRuntime(final OperationContext context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,8 @@ class ExpressionResolverResourceDefinition extends SimpleResourceDefinition {

@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
OperationStepHandler write = new ElytronReloadRequiredWriteAttributeHandler(ATTRIBUTES);
for (AttributeDefinition current : ATTRIBUTES) {
resourceRegistration.registerReadWriteAttribute(current, null, write);
resourceRegistration.registerReadWriteAttribute(current, null, ElytronReloadRequiredWriteAttributeHandler.INSTANCE);
}
}

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


import org.jboss.as.controller.AbstractAddStepHandler;
import org.jboss.as.controller.AbstractWriteAttributeHandler;
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
Expand Down Expand Up @@ -86,9 +85,8 @@ class FailoverRealmDefinition extends SimpleResourceDefinition {

@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
AbstractWriteAttributeHandler write = new ElytronReloadRequiredWriteAttributeHandler(ATTRIBUTES);
for (AttributeDefinition current : ATTRIBUTES) {
resourceRegistration.registerReadWriteAttribute(current, null, write);
resourceRegistration.registerReadWriteAttribute(current, null, ElytronReloadRequiredWriteAttributeHandler.INSTANCE);
}
}

Expand Down
Loading

0 comments on commit 2c28d35

Please sign in to comment.