Skip to content

Commit

Permalink
[WFLY-8765] IIOP migration: only print warnings when legacy configura…
Browse files Browse the repository at this point in the history
…tion is invalid (backward compatibility)
  • Loading branch information
tadamski committed May 14, 2017
1 parent 27a2e40 commit d5ad563
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 36 deletions.
Expand Up @@ -27,6 +27,9 @@
import org.jboss.dmr.ModelNode; import org.jboss.dmr.ModelNode;
import org.wildfly.iiop.openjdk.logging.IIOPLogger; import org.wildfly.iiop.openjdk.logging.IIOPLogger;


import java.util.LinkedList;
import java.util.List;

/** /**
* @author <a href="mailto:tadamski@redhat.com">Tomasz Adamski</a> * @author <a href="mailto:tadamski@redhat.com">Tomasz Adamski</a>
*/ */
Expand All @@ -35,17 +38,21 @@ public class ConfigValidator {
private ConfigValidator(){ private ConfigValidator(){
} }


public static void validateConfig(final OperationContext context, final ModelNode resourceModel) throws OperationFailedException { public static List<String> validateConfig(final OperationContext context, final ModelNode resourceModel) throws OperationFailedException {
final List<String> warnings = new LinkedList<>();

final boolean supportSSL = IIOPRootDefinition.SUPPORT_SSL.resolveModelAttribute(context, resourceModel).asBoolean(); final boolean supportSSL = IIOPRootDefinition.SUPPORT_SSL.resolveModelAttribute(context, resourceModel).asBoolean();
final boolean serverRequiresSsl = IIOPRootDefinition.SERVER_REQUIRES_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(); final boolean clientRequiresSsl = IIOPRootDefinition.CLIENT_REQUIRES_SSL.resolveModelAttribute(context, resourceModel).asBoolean();


final boolean sslConfigured = isSSLConfigured(context, resourceModel); final boolean sslConfigured = isSSLConfigured(context, resourceModel);


validateSSLConfig(supportSSL, sslConfigured, serverRequiresSsl, clientRequiresSsl); validateSSLConfig(supportSSL, sslConfigured, serverRequiresSsl, clientRequiresSsl);
validateSSLSocketBinding(context, resourceModel, sslConfigured); validateSSLSocketBinding(context, resourceModel, sslConfigured, warnings);
validateIORTransportConfig(context, resourceModel, supportSSL, serverRequiresSsl); validateIORTransportConfig(context, resourceModel, supportSSL, serverRequiresSsl, warnings);
validateORBInitializerConfig(context, resourceModel); validateORBInitializerConfig(context, resourceModel);

return warnings;
} }


private static boolean isSSLConfigured(final OperationContext context, final ModelNode resourceModel) throws OperationFailedException { private static boolean isSSLConfigured(final OperationContext context, final ModelNode resourceModel) throws OperationFailedException {
Expand All @@ -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<String> warnings) throws OperationFailedException{
ModelNode sslSocketBinding = IIOPRootDefinition.SSL_SOCKET_BINDING.resolveModelAttribute(context, resourceModel); ModelNode sslSocketBinding = IIOPRootDefinition.SSL_SOCKET_BINDING.resolveModelAttribute(context, resourceModel);
if(sslSocketBinding.isDefined() && !sslConfigured){ 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, private static void validateIORTransportConfig(final OperationContext context, final ModelNode resourceModel, final boolean sslConfigured,
final boolean serverRequiresSsl) throws OperationFailedException { final boolean serverRequiresSsl, final List<String> warnings) throws OperationFailedException {
validateSSLAttribute(context, resourceModel, sslConfigured, serverRequiresSsl, IIOPRootDefinition.INTEGRITY); validateSSLAttribute(context, resourceModel, sslConfigured, serverRequiresSsl, IIOPRootDefinition.INTEGRITY, warnings);
validateSSLAttribute(context, resourceModel, sslConfigured, serverRequiresSsl, IIOPRootDefinition.CONFIDENTIALITY); validateSSLAttribute(context, resourceModel, sslConfigured, serverRequiresSsl, IIOPRootDefinition.CONFIDENTIALITY, warnings);
validateSSLAttribute(context, resourceModel, sslConfigured, serverRequiresSsl, IIOPRootDefinition.TRUST_IN_CLIENT); validateSSLAttribute(context, resourceModel, sslConfigured, serverRequiresSsl, IIOPRootDefinition.TRUST_IN_CLIENT, warnings);
validateTrustInTarget(context, resourceModel, sslConfigured); validateTrustInTarget(context, resourceModel, sslConfigured, warnings);
validateSupportedAttribute(context, resourceModel, IIOPRootDefinition.DETECT_MISORDERING); validateSupportedAttribute(context, resourceModel, IIOPRootDefinition.DETECT_MISORDERING, warnings);
validateSupportedAttribute(context, resourceModel, IIOPRootDefinition.DETECT_REPLAY); 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<String> warnings) throws OperationFailedException {
final ModelNode attributeNode = attributeDefinition.resolveModelAttribute(context, resourceModel); final ModelNode attributeNode = attributeDefinition.resolveModelAttribute(context, resourceModel);
if(attributeNode.isDefined()){ if(attributeNode.isDefined()){
final String attribute = attributeNode.asString(); final String attribute = attributeNode.asString();
if(sslConfigured) { if(sslConfigured) {
if(attribute.equals(Constants.IOR_NONE)){ 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)) { 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 { } else {
if(!attribute.equals(Constants.IOR_NONE)){ 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<String> warnings) throws OperationFailedException {
final ModelNode establishTrustInTargetNode = IIOPRootDefinition.TRUST_IN_TARGET.resolveModelAttribute(context, resourceModel); final ModelNode establishTrustInTargetNode = IIOPRootDefinition.TRUST_IN_TARGET.resolveModelAttribute(context, resourceModel);
if(establishTrustInTargetNode.isDefined()){ if(establishTrustInTargetNode.isDefined()){
final String establishTrustInTarget = establishTrustInTargetNode.asString(); final String establishTrustInTarget = establishTrustInTargetNode.asString();
if(sslConfigured && establishTrustInTarget.equals(Constants.IOR_NONE)){ 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<String> warnings) throws OperationFailedException{
final ModelNode attributeNode = attributeDefinition.resolveModelAttribute(context, resourceModel); final ModelNode attributeNode = attributeDefinition.resolveModelAttribute(context, resourceModel);
if(attributeNode.isDefined() && !attributeNode.asString().equals(Constants.IOR_SUPPORTED)) { 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);
} }
} }


Expand Down
Expand Up @@ -381,16 +381,14 @@ public interface IIOPLogger extends BasicLogger {
OperationFailedException sslNotConfigured(); OperationFailedException sslNotConfigured();


@Message(id = 104, value = "Inconsistent transport-config configuration: %s is supported but it is configured with NONE value") @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") @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") @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") @Message(id = 108, value = "Security attribute server-requires-ssl is not supported in previous iiop-openjdk versions and can't be converted")
String serverRequiresSslNotSupportedInPreviousVersions(); String serverRequiresSslNotSupportedInPreviousVersions();
Expand All @@ -402,9 +400,8 @@ public interface IIOPLogger extends BasicLogger {
@Message(id = 110, value = "Client requires SSL but server does not support it") @Message(id = 110, value = "Client requires SSL but server does not support it")
IllegalStateException serverDoesNotSupportSsl(); 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") @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") @Message(id = 112, value = "Security initializer was set to 'elytron' but no authentication-context has been specified")
OperationFailedException elytronInitializerMissingAuthContext(); OperationFailedException elytronInitializerMissingAuthContext();
Expand Down
Expand Up @@ -55,28 +55,23 @@ class IORTransportConfigDefinition extends PersistentResourceDefinition {
static final ParameterValidator VALIDATOR = new EnumValidator<IORTransportConfigValues>( static final ParameterValidator VALIDATOR = new EnumValidator<IORTransportConfigValues>(
IORTransportConfigValues.class, true, true); IORTransportConfigValues.class, true, true);


static final ModelNode DEFAULT_VALUE = new ModelNode(IORTransportConfigValues.NONE.toString());

static final AttributeDefinition INTEGRITY = static final AttributeDefinition INTEGRITY =
new SimpleAttributeDefinitionBuilder(JacORBSubsystemConstants.IOR_TRANSPORT_INTEGRITY, ModelType.STRING, true) new SimpleAttributeDefinitionBuilder(JacORBSubsystemConstants.IOR_TRANSPORT_INTEGRITY, ModelType.STRING, true)
.setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES)
.setDefaultValue(DEFAULT_VALUE)
.setValidator(VALIDATOR) .setValidator(VALIDATOR)
.setAllowExpression(true) .setAllowExpression(true)
.build(); .build();


static final AttributeDefinition CONFIDENTIALITY = static final AttributeDefinition CONFIDENTIALITY =
new SimpleAttributeDefinitionBuilder(JacORBSubsystemConstants.IOR_TRANSPORT_CONFIDENTIALITY, ModelType.STRING, true) new SimpleAttributeDefinitionBuilder(JacORBSubsystemConstants.IOR_TRANSPORT_CONFIDENTIALITY, ModelType.STRING, true)
.setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES)
.setDefaultValue(DEFAULT_VALUE)
.setValidator(VALIDATOR) .setValidator(VALIDATOR)
.setAllowExpression(true) .setAllowExpression(true)
.build(); .build();


static final AttributeDefinition TRUST_IN_TARGET = static final AttributeDefinition TRUST_IN_TARGET =
new SimpleAttributeDefinitionBuilder(JacORBSubsystemConstants.IOR_TRANSPORT_TRUST_IN_TARGET, ModelType.STRING, true) new SimpleAttributeDefinitionBuilder(JacORBSubsystemConstants.IOR_TRANSPORT_TRUST_IN_TARGET, ModelType.STRING, true)
.setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES)
.setDefaultValue(DEFAULT_VALUE)
.setValidator(new EnumValidator<IORTransportConfigValues>(IORTransportConfigValues.class, true, true, .setValidator(new EnumValidator<IORTransportConfigValues>(IORTransportConfigValues.class, true, true,
IORTransportConfigValues.NONE, IORTransportConfigValues.SUPPORTED)) IORTransportConfigValues.NONE, IORTransportConfigValues.SUPPORTED))
.setAllowExpression(true) .setAllowExpression(true)
Expand All @@ -85,23 +80,20 @@ class IORTransportConfigDefinition extends PersistentResourceDefinition {
static final AttributeDefinition TRUST_IN_CLIENT = static final AttributeDefinition TRUST_IN_CLIENT =
new SimpleAttributeDefinitionBuilder(JacORBSubsystemConstants.IOR_TRANSPORT_TRUST_IN_CLIENT, ModelType.STRING, true) new SimpleAttributeDefinitionBuilder(JacORBSubsystemConstants.IOR_TRANSPORT_TRUST_IN_CLIENT, ModelType.STRING, true)
.setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES)
.setDefaultValue(DEFAULT_VALUE)
.setValidator(VALIDATOR) .setValidator(VALIDATOR)
.setAllowExpression(true) .setAllowExpression(true)
.build(); .build();


static final AttributeDefinition DETECT_REPLAY = static final AttributeDefinition DETECT_REPLAY =
new SimpleAttributeDefinitionBuilder(JacORBSubsystemConstants.IOR_TRANSPORT_DETECT_REPLAY, ModelType.STRING, true) new SimpleAttributeDefinitionBuilder(JacORBSubsystemConstants.IOR_TRANSPORT_DETECT_REPLAY, ModelType.STRING, true)
.setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES)
.setDefaultValue(DEFAULT_VALUE)
.setValidator(VALIDATOR) .setValidator(VALIDATOR)
.setAllowExpression(true) .setAllowExpression(true)
.build(); .build();


static final SimpleAttributeDefinition DETECT_MISORDERING = static final SimpleAttributeDefinition DETECT_MISORDERING =
new SimpleAttributeDefinitionBuilder(JacORBSubsystemConstants.IOR_TRANSPORT_DETECT_MISORDERING, ModelType.STRING, true) new SimpleAttributeDefinitionBuilder(JacORBSubsystemConstants.IOR_TRANSPORT_DETECT_MISORDERING, ModelType.STRING, true)
.setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES)
.setDefaultValue(DEFAULT_VALUE)
.setValidator(VALIDATOR) .setValidator(VALIDATOR)
.setAllowExpression(true) .setAllowExpression(true)
.build(); .build();
Expand Down
Expand Up @@ -154,7 +154,7 @@ public void execute(OperationContext operationContext, ModelNode modelNode) thro
checkPropertiesWithExpression(jacorbModel, warnings); checkPropertiesWithExpression(jacorbModel, warnings);


final ModelNode openjdkModel = TransformUtils.transformModel(jacorbModel); final ModelNode openjdkModel = TransformUtils.transformModel(jacorbModel);
ConfigValidator.validateConfig(context, openjdkModel); warnings.addAll(ConfigValidator.validateConfig(context, openjdkModel));


final PathAddress openjdkAddress = subsystemsAddress.append(OPENJDK_SUBSYSTEM_ELEMENT); final PathAddress openjdkAddress = subsystemsAddress.append(OPENJDK_SUBSYSTEM_ELEMENT);
addOpenjdkSubsystem(openjdkAddress, openjdkModel, migrateOperations); addOpenjdkSubsystem(openjdkAddress, openjdkModel, migrateOperations);
Expand Down

0 comments on commit d5ad563

Please sign in to comment.