From d5ad563565c0f66f06d8131e41573b239adb54ff Mon Sep 17 00:00:00 2001 From: Tomasz Adamski Date: Sun, 14 May 2017 15:02:45 +0200 Subject: [PATCH] [WFLY-8765] IIOP migration: only print warnings when legacy configuration is invalid (backward compatibility) --- .../wildfly/iiop/openjdk/ConfigValidator.java | 59 ++++++++++++------- .../iiop/openjdk/logging/IIOPLogger.java | 11 ++-- .../jacorb/IORTransportConfigDefinition.java | 8 --- .../org/jboss/as/jacorb/MigrateOperation.java | 2 +- 4 files changed, 44 insertions(+), 36 deletions(-) diff --git a/iiop-openjdk/src/main/java/org/wildfly/iiop/openjdk/ConfigValidator.java b/iiop-openjdk/src/main/java/org/wildfly/iiop/openjdk/ConfigValidator.java index ea4a9d687fd3..ef86a99aa602 100644 --- a/iiop-openjdk/src/main/java/org/wildfly/iiop/openjdk/ConfigValidator.java +++ b/iiop-openjdk/src/main/java/org/wildfly/iiop/openjdk/ConfigValidator.java @@ -27,6 +27,9 @@ import org.jboss.dmr.ModelNode; import org.wildfly.iiop.openjdk.logging.IIOPLogger; +import java.util.LinkedList; +import java.util.List; + /** * @author Tomasz Adamski */ @@ -35,7 +38,9 @@ public class ConfigValidator { private ConfigValidator(){ } - public static void validateConfig(final OperationContext context, final ModelNode resourceModel) throws OperationFailedException { + public static List validateConfig(final OperationContext context, final ModelNode resourceModel) throws OperationFailedException { + final List warnings = new LinkedList<>(); + final boolean supportSSL = IIOPRootDefinition.SUPPORT_SSL.resolveModelAttribute(context, resourceModel).asBoolean(); final boolean serverRequiresSsl = IIOPRootDefinition.SERVER_REQUIRES_SSL.resolveModelAttribute(context, resourceModel).asBoolean(); final boolean clientRequiresSsl = IIOPRootDefinition.CLIENT_REQUIRES_SSL.resolveModelAttribute(context, resourceModel).asBoolean(); @@ -43,9 +48,11 @@ public static void validateConfig(final OperationContext context, final ModelNod final boolean sslConfigured = isSSLConfigured(context, resourceModel); validateSSLConfig(supportSSL, sslConfigured, serverRequiresSsl, clientRequiresSsl); - validateSSLSocketBinding(context, resourceModel, sslConfigured); - validateIORTransportConfig(context, resourceModel, supportSSL, serverRequiresSsl); + validateSSLSocketBinding(context, resourceModel, sslConfigured, warnings); + validateIORTransportConfig(context, resourceModel, supportSSL, serverRequiresSsl, warnings); validateORBInitializerConfig(context, resourceModel); + + return warnings; } private static boolean isSSLConfigured(final OperationContext context, final ModelNode resourceModel) throws OperationFailedException { @@ -71,56 +78,68 @@ private static void validateSSLConfig(final boolean supportSSL, final boolean ss } } - private static void validateSSLSocketBinding(final OperationContext context, final ModelNode resourceModel, final boolean sslConfigured) throws OperationFailedException{ + private static void validateSSLSocketBinding(final OperationContext context, final ModelNode resourceModel, final boolean sslConfigured, final List warnings) throws OperationFailedException{ ModelNode sslSocketBinding = IIOPRootDefinition.SSL_SOCKET_BINDING.resolveModelAttribute(context, resourceModel); if(sslSocketBinding.isDefined() && !sslConfigured){ - IIOPLogger.ROOT_LOGGER.sslPortWithoutSslConfiguration(); + final String warning = IIOPLogger.ROOT_LOGGER.sslPortWithoutSslConfiguration(); + IIOPLogger.ROOT_LOGGER.warn(warning); + warnings.add(warning); } } private static void validateIORTransportConfig(final OperationContext context, final ModelNode resourceModel, final boolean sslConfigured, - final boolean serverRequiresSsl) throws OperationFailedException { - validateSSLAttribute(context, resourceModel, sslConfigured, serverRequiresSsl, IIOPRootDefinition.INTEGRITY); - validateSSLAttribute(context, resourceModel, sslConfigured, serverRequiresSsl, IIOPRootDefinition.CONFIDENTIALITY); - validateSSLAttribute(context, resourceModel, sslConfigured, serverRequiresSsl, IIOPRootDefinition.TRUST_IN_CLIENT); - validateTrustInTarget(context, resourceModel, sslConfigured); - validateSupportedAttribute(context, resourceModel, IIOPRootDefinition.DETECT_MISORDERING); - validateSupportedAttribute(context, resourceModel, IIOPRootDefinition.DETECT_REPLAY); + final boolean serverRequiresSsl, final List warnings) throws OperationFailedException { + validateSSLAttribute(context, resourceModel, sslConfigured, serverRequiresSsl, IIOPRootDefinition.INTEGRITY, warnings); + validateSSLAttribute(context, resourceModel, sslConfigured, serverRequiresSsl, IIOPRootDefinition.CONFIDENTIALITY, warnings); + validateSSLAttribute(context, resourceModel, sslConfigured, serverRequiresSsl, IIOPRootDefinition.TRUST_IN_CLIENT, warnings); + validateTrustInTarget(context, resourceModel, sslConfigured, warnings); + validateSupportedAttribute(context, resourceModel, IIOPRootDefinition.DETECT_MISORDERING, warnings); + validateSupportedAttribute(context, resourceModel, IIOPRootDefinition.DETECT_REPLAY, warnings); } - private static void validateSSLAttribute(final OperationContext context, final ModelNode resourceModel, final boolean sslConfigured, final boolean serverRequiresSsl, final AttributeDefinition attributeDefinition) throws OperationFailedException { + private static void validateSSLAttribute(final OperationContext context, final ModelNode resourceModel, final boolean sslConfigured, final boolean serverRequiresSsl, final AttributeDefinition attributeDefinition, final List warnings) throws OperationFailedException { final ModelNode attributeNode = attributeDefinition.resolveModelAttribute(context, resourceModel); if(attributeNode.isDefined()){ final String attribute = attributeNode.asString(); if(sslConfigured) { if(attribute.equals(Constants.IOR_NONE)){ - throw IIOPLogger.ROOT_LOGGER.inconsistentSupportedTransportConfig(attributeDefinition.getName()); + final String warning = IIOPLogger.ROOT_LOGGER.inconsistentSupportedTransportConfig(attributeDefinition.getName()); + IIOPLogger.ROOT_LOGGER.warn(warning); + warnings.add(warning); } if (serverRequiresSsl && attribute.equals(Constants.IOR_SUPPORTED)) { - throw IIOPLogger.ROOT_LOGGER.inconsistentRequiredTransportConfig(Constants.SECURITY_SERVER_REQUIRES_SSL, attributeDefinition.getName()); + final String warning = IIOPLogger.ROOT_LOGGER.inconsistentRequiredTransportConfig(Constants.SECURITY_SERVER_REQUIRES_SSL, attributeDefinition.getName()); + IIOPLogger.ROOT_LOGGER.warn(warning); + warnings.add(warning); } } else { if(!attribute.equals(Constants.IOR_NONE)){ - throw IIOPLogger.ROOT_LOGGER.inconsistentUnsupportedTransportConfig(attributeDefinition.getName()); + final String warning = IIOPLogger.ROOT_LOGGER.inconsistentUnsupportedTransportConfig(attributeDefinition.getName()); + IIOPLogger.ROOT_LOGGER.warn(warning); + warnings.add(warning); } } } } - private static void validateTrustInTarget(final OperationContext context, final ModelNode resourceModel, final boolean sslConfigured) throws OperationFailedException { + private static void validateTrustInTarget(final OperationContext context, final ModelNode resourceModel, final boolean sslConfigured, final List warnings) throws OperationFailedException { final ModelNode establishTrustInTargetNode = IIOPRootDefinition.TRUST_IN_TARGET.resolveModelAttribute(context, resourceModel); if(establishTrustInTargetNode.isDefined()){ final String establishTrustInTarget = establishTrustInTargetNode.asString(); if(sslConfigured && establishTrustInTarget.equals(Constants.IOR_NONE)){ - throw IIOPLogger.ROOT_LOGGER.inconsistentSupportedTransportConfig(Constants.IOR_TRANSPORT_TRUST_IN_TARGET); + final String warning = IIOPLogger.ROOT_LOGGER.inconsistentSupportedTransportConfig(Constants.IOR_TRANSPORT_TRUST_IN_TARGET); + IIOPLogger.ROOT_LOGGER.warn(warning); + warnings.add(warning); } } } - private static void validateSupportedAttribute(final OperationContext context, final ModelNode resourceModel, final AttributeDefinition attributeDefinition) throws OperationFailedException{ + private static void validateSupportedAttribute(final OperationContext context, final ModelNode resourceModel, final AttributeDefinition attributeDefinition, final List warnings) throws OperationFailedException{ final ModelNode attributeNode = attributeDefinition.resolveModelAttribute(context, resourceModel); if(attributeNode.isDefined() && !attributeNode.asString().equals(Constants.IOR_SUPPORTED)) { - throw IIOPLogger.ROOT_LOGGER.inconsistentSupportedTransportConfig(attributeDefinition.getName()); + final String warning = IIOPLogger.ROOT_LOGGER.inconsistentSupportedTransportConfig(attributeDefinition.getName()); + IIOPLogger.ROOT_LOGGER.warn(warning); + warnings.add(warning); } } diff --git a/iiop-openjdk/src/main/java/org/wildfly/iiop/openjdk/logging/IIOPLogger.java b/iiop-openjdk/src/main/java/org/wildfly/iiop/openjdk/logging/IIOPLogger.java index 8b9e66590c49..b59ef9dd83c0 100644 --- a/iiop-openjdk/src/main/java/org/wildfly/iiop/openjdk/logging/IIOPLogger.java +++ b/iiop-openjdk/src/main/java/org/wildfly/iiop/openjdk/logging/IIOPLogger.java @@ -381,16 +381,14 @@ public interface IIOPLogger extends BasicLogger { OperationFailedException sslNotConfigured(); @Message(id = 104, value = "Inconsistent transport-config configuration: %s is supported but it is configured with NONE value") - OperationFailedException inconsistentSupportedTransportConfig(final String transportAttributeName); + String inconsistentSupportedTransportConfig(final String transportAttributeName); @Message(id = 105, value = "Inconsistent transport-config configuration: %s is not supported but it is not configured with NONE value") - OperationFailedException inconsistentUnsupportedTransportConfig(final String transportAttributeName); + String inconsistentUnsupportedTransportConfig(final String transportAttributeName); @Message(id = 106, value = "Inconsistent transport-config configuration: %s is set to true, but %s is not configured as required") - OperationFailedException inconsistentRequiredTransportConfig(final String requiredAttributeName, final String transportAttributeName); + String inconsistentRequiredTransportConfig(final String requiredAttributeName, final String transportAttributeName); - @Message(id = 107, value = "Inconsistent transport-config configuration: %s is set to false, but %s is configured as required") - OperationFailedException inconsistentNotRequiredTransportConfig(final String requiredAttributeName, final String transportAttributeName); @Message(id = 108, value = "Security attribute server-requires-ssl is not supported in previous iiop-openjdk versions and can't be converted") String serverRequiresSslNotSupportedInPreviousVersions(); @@ -402,9 +400,8 @@ public interface IIOPLogger extends BasicLogger { @Message(id = 110, value = "Client requires SSL but server does not support it") IllegalStateException serverDoesNotSupportSsl(); - @LogMessage(level = WARN) @Message(id = 111, value = "SSL has not been configured but ssl-port property has been specified - the connection will use clear-text protocol") - void sslPortWithoutSslConfiguration(); + String sslPortWithoutSslConfiguration(); @Message(id = 112, value = "Security initializer was set to 'elytron' but no authentication-context has been specified") OperationFailedException elytronInitializerMissingAuthContext(); diff --git a/legacy/jacorb/src/main/java/org/jboss/as/jacorb/IORTransportConfigDefinition.java b/legacy/jacorb/src/main/java/org/jboss/as/jacorb/IORTransportConfigDefinition.java index 0972f47978a0..8a8398e699ac 100644 --- a/legacy/jacorb/src/main/java/org/jboss/as/jacorb/IORTransportConfigDefinition.java +++ b/legacy/jacorb/src/main/java/org/jboss/as/jacorb/IORTransportConfigDefinition.java @@ -55,12 +55,9 @@ class IORTransportConfigDefinition extends PersistentResourceDefinition { static final ParameterValidator VALIDATOR = new EnumValidator( IORTransportConfigValues.class, true, true); - static final ModelNode DEFAULT_VALUE = new ModelNode(IORTransportConfigValues.NONE.toString()); - static final AttributeDefinition INTEGRITY = new SimpleAttributeDefinitionBuilder(JacORBSubsystemConstants.IOR_TRANSPORT_INTEGRITY, ModelType.STRING, true) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) - .setDefaultValue(DEFAULT_VALUE) .setValidator(VALIDATOR) .setAllowExpression(true) .build(); @@ -68,7 +65,6 @@ class IORTransportConfigDefinition extends PersistentResourceDefinition { static final AttributeDefinition CONFIDENTIALITY = new SimpleAttributeDefinitionBuilder(JacORBSubsystemConstants.IOR_TRANSPORT_CONFIDENTIALITY, ModelType.STRING, true) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) - .setDefaultValue(DEFAULT_VALUE) .setValidator(VALIDATOR) .setAllowExpression(true) .build(); @@ -76,7 +72,6 @@ class IORTransportConfigDefinition extends PersistentResourceDefinition { static final AttributeDefinition TRUST_IN_TARGET = new SimpleAttributeDefinitionBuilder(JacORBSubsystemConstants.IOR_TRANSPORT_TRUST_IN_TARGET, ModelType.STRING, true) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) - .setDefaultValue(DEFAULT_VALUE) .setValidator(new EnumValidator(IORTransportConfigValues.class, true, true, IORTransportConfigValues.NONE, IORTransportConfigValues.SUPPORTED)) .setAllowExpression(true) @@ -85,7 +80,6 @@ class IORTransportConfigDefinition extends PersistentResourceDefinition { static final AttributeDefinition TRUST_IN_CLIENT = new SimpleAttributeDefinitionBuilder(JacORBSubsystemConstants.IOR_TRANSPORT_TRUST_IN_CLIENT, ModelType.STRING, true) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) - .setDefaultValue(DEFAULT_VALUE) .setValidator(VALIDATOR) .setAllowExpression(true) .build(); @@ -93,7 +87,6 @@ class IORTransportConfigDefinition extends PersistentResourceDefinition { static final AttributeDefinition DETECT_REPLAY = new SimpleAttributeDefinitionBuilder(JacORBSubsystemConstants.IOR_TRANSPORT_DETECT_REPLAY, ModelType.STRING, true) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) - .setDefaultValue(DEFAULT_VALUE) .setValidator(VALIDATOR) .setAllowExpression(true) .build(); @@ -101,7 +94,6 @@ class IORTransportConfigDefinition extends PersistentResourceDefinition { static final SimpleAttributeDefinition DETECT_MISORDERING = new SimpleAttributeDefinitionBuilder(JacORBSubsystemConstants.IOR_TRANSPORT_DETECT_MISORDERING, ModelType.STRING, true) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) - .setDefaultValue(DEFAULT_VALUE) .setValidator(VALIDATOR) .setAllowExpression(true) .build(); diff --git a/legacy/jacorb/src/main/java/org/jboss/as/jacorb/MigrateOperation.java b/legacy/jacorb/src/main/java/org/jboss/as/jacorb/MigrateOperation.java index a049209355ed..38e75e456291 100644 --- a/legacy/jacorb/src/main/java/org/jboss/as/jacorb/MigrateOperation.java +++ b/legacy/jacorb/src/main/java/org/jboss/as/jacorb/MigrateOperation.java @@ -154,7 +154,7 @@ public void execute(OperationContext operationContext, ModelNode modelNode) thro checkPropertiesWithExpression(jacorbModel, warnings); final ModelNode openjdkModel = TransformUtils.transformModel(jacorbModel); - ConfigValidator.validateConfig(context, openjdkModel); + warnings.addAll(ConfigValidator.validateConfig(context, openjdkModel)); final PathAddress openjdkAddress = subsystemsAddress.append(OPENJDK_SUBSYSTEM_ELEMENT); addOpenjdkSubsystem(openjdkAddress, openjdkModel, migrateOperations);