Search in sources :

Example 36 with OperationFailedException

use of org.jboss.as.controller.OperationFailedException in project wildfly by wildfly.

the class AbstractActiveMQComponentControlHandler method executeRuntimeStep.

@Override
protected void executeRuntimeStep(OperationContext context, ModelNode operation) throws OperationFailedException {
    final String operationName = operation.require(OP).asString();
    if (READ_ATTRIBUTE_OPERATION.equals(operationName)) {
        if (ActiveMQActivationService.ignoreOperationIfServerNotActive(context, operation)) {
            return;
        }
        readAttributeValidator.validate(operation);
        final String name = operation.require(NAME).asString();
        if (STARTED.getName().equals(name)) {
            ActiveMQComponentControl control = getActiveMQComponentControl(context, operation, false);
            context.getResult().set(control.isStarted());
        } else {
            handleReadAttribute(name, context, operation);
        }
        return;
    }
    if (ActiveMQActivationService.rollbackOperationIfServerNotActive(context, operation)) {
        return;
    }
    ActiveMQComponentControl control = null;
    boolean appliedToRuntime = false;
    Object handback = null;
    if (START.equals(operationName)) {
        control = getActiveMQComponentControl(context, operation, true);
        try {
            control.start();
            appliedToRuntime = true;
            context.getResult();
        } catch (Exception e) {
            context.getFailureDescription().set(e.getLocalizedMessage());
        }
    } else if (STOP.equals(operationName)) {
        control = getActiveMQComponentControl(context, operation, true);
        try {
            control.stop();
            appliedToRuntime = true;
            context.getResult();
        } catch (Exception e) {
            context.getFailureDescription().set(e.getLocalizedMessage());
        }
    } else {
        handback = handleOperation(operationName, context, operation);
        appliedToRuntime = handback != null;
    }
    OperationContext.RollbackHandler rh;
    if (appliedToRuntime) {
        final ActiveMQComponentControl rhControl = control;
        final Object rhHandback = handback;
        rh = new OperationContext.RollbackHandler() {

            @Override
            public void handleRollback(OperationContext context, ModelNode operation) {
                try {
                    if (START.equals(operationName)) {
                        rhControl.stop();
                    } else if (STOP.equals(operationName)) {
                        rhControl.start();
                    } else {
                        handleRevertOperation(operationName, context, operation, rhHandback);
                    }
                } catch (Exception e) {
                    ROOT_LOGGER.revertOperationFailed(e, getClass().getSimpleName(), operation.require(ModelDescriptionConstants.OP).asString(), PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR)));
                }
            }
        };
    } else {
        rh = OperationContext.RollbackHandler.NOOP_ROLLBACK_HANDLER;
    }
    context.completeStep(rh);
}
Also used : OperationContext(org.jboss.as.controller.OperationContext) ActiveMQComponentControl(org.apache.activemq.artemis.api.core.management.ActiveMQComponentControl) ModelNode(org.jboss.dmr.ModelNode) OperationFailedException(org.jboss.as.controller.OperationFailedException)

Example 37 with OperationFailedException

use of org.jboss.as.controller.OperationFailedException in project wildfly by wildfly.

the class ModClusterConfigurationServiceBuilder method configure.

@Override
public Builder<ModClusterConfiguration> configure(OperationContext context, ModelNode model) throws OperationFailedException {
    // Advertise
    optionalString(ADVERTISE_SOCKET.resolveModelAttribute(context, model)).ifPresent(advertiseSocketRef -> this.advertiseSocketDependency = new InjectedValueDependency<>(context.getCapabilityServiceName(SOCKET_BINDING_CAPABILITY_NAME, advertiseSocketRef, SocketBinding.class), SocketBinding.class));
    optionalString(ADVERTISE_SECURITY_KEY.resolveModelAttribute(context, model)).ifPresent(securityKey -> builder.advertise().setAdvertiseSecurityKey(securityKey));
    // MCMP
    builder.mcmp().setAdvertise(ADVERTISE.resolveModelAttribute(context, model).asBoolean()).setProxyURL(PROXY_URL.resolveModelAttribute(context, model).asString()).setAutoEnableContexts(AUTO_ENABLE_CONTEXTS.resolveModelAttribute(context, model).asBoolean()).setStopContextTimeout(STOP_CONTEXT_TIMEOUT.resolveModelAttribute(context, model).asInt()).setStopContextTimeoutUnit(TimeUnit.valueOf(STOP_CONTEXT_TIMEOUT.getMeasurementUnit().getName())).setSocketTimeout(SOCKET_TIMEOUT.resolveModelAttribute(context, model).asInt() * 1000).setSessionDrainingStrategy(Enum.valueOf(SessionDrainingStrategyEnum.class, SESSION_DRAINING_STRATEGY.resolveModelAttribute(context, model).asString()));
    if (model.hasDefined(CommonAttributes.EXCLUDED_CONTEXTS)) {
        String contexts = EXCLUDED_CONTEXTS.resolveModelAttribute(context, model).asString();
        Map<String, Set<String>> excludedContextsPerHost;
        if (contexts == null) {
            excludedContextsPerHost = Collections.emptyMap();
        } else {
            String trimmedContexts = contexts.trim();
            if (trimmedContexts.isEmpty()) {
                excludedContextsPerHost = Collections.emptyMap();
            } else {
                excludedContextsPerHost = new HashMap<>();
                for (String c : trimmedContexts.split(",")) {
                    String[] parts = c.trim().split(":");
                    if (parts.length > 2) {
                        throw ROOT_LOGGER.excludedContextsWrongFormat(trimmedContexts);
                    }
                    String host = null;
                    String trimmedContext = parts[0].trim();
                    if (parts.length == 2) {
                        host = trimmedContext;
                        trimmedContext = parts[1].trim();
                    }
                    String path = trimmedContext.equals("ROOT") ? "" : "/" + trimmedContext;
                    Set<String> paths = excludedContextsPerHost.computeIfAbsent(host, k -> new HashSet<>());
                    paths.add(path);
                }
            }
        }
        builder.mcmp().setExcludedContextsPerHost(excludedContextsPerHost);
    }
    // Balancer
    builder.balancer().setStickySession(STICKY_SESSION.resolveModelAttribute(context, model).asBoolean()).setStickySessionRemove(STICKY_SESSION_REMOVE.resolveModelAttribute(context, model).asBoolean()).setStickySessionForce(STICKY_SESSION_FORCE.resolveModelAttribute(context, model).asBoolean()).setWorkerTimeout(WORKER_TIMEOUT.resolveModelAttribute(context, model).asInt()).setMaxAttempts(MAX_ATTEMPTS.resolveModelAttribute(context, model).asInt());
    // Node
    builder.node().setFlushPackets(FLUSH_PACKETS.resolveModelAttribute(context, model).asBoolean()).setFlushWait(FLUSH_WAIT.resolveModelAttribute(context, model).asInt()).setPing(PING.resolveModelAttribute(context, model).asInt()).setSmax(SMAX.resolveModelAttribute(context, model).asInt()).setTtl(TTL.resolveModelAttribute(context, model).asInt()).setNodeTimeout(NODE_TIMEOUT.resolveModelAttribute(context, model).asInt());
    optionalString(BALANCER.resolveModelAttribute(context, model)).ifPresent(balancer -> builder.node().setBalancer(balancer));
    optionalString(LOAD_BALANCING_GROUP.resolveModelAttribute(context, model)).ifPresent(group -> builder.node().setLoadBalancingGroup(group));
    optionalList(PROXIES.resolveModelAttribute(context, model)).ifPresent(refs -> refs.stream().map(ModelNode::asString).forEach(ref -> outboundSocketBindings.add(new InjectedValueDependency<>(context.getCapabilityServiceName(OUTBOUND_SOCKET_BINDING_CAPABILITY_NAME, ref, OutboundSocketBinding.class), OutboundSocketBinding.class))));
    if (model.hasDefined(CommonAttributes.PROXY_LIST)) {
        throw new OperationFailedException(ROOT_LOGGER.proxyListNotAllowedInCurrentModel());
    }
    // Elytron-based security support
    Optional<String> sslContextRef = optionalString(SSL_CONTEXT.resolveModelAttribute(context, model));
    sslContextRef.ifPresent(sslContext -> this.sslContextDependency = new InjectedValueDependency<>(context.getCapabilityServiceName(SSL_CONTEXT_CAPABILITY_NAME, sslContext, SSLContext.class), SSLContext.class));
    if (model.get(ModClusterSSLResourceDefinition.PATH.getKeyValuePair()).isDefined()) {
        if (sslContextRef.isPresent()) {
            throw ROOT_LOGGER.bothElytronAndLegacySslContextDefined();
        }
        ModelNode sslModel = model.get(ModClusterSSLResourceDefinition.PATH.getKeyValuePair());
        ModClusterConfig sslConfiguration = new ModClusterConfig();
        optionalString(KEY_ALIAS.resolveModelAttribute(context, sslModel)).ifPresent(sslConfiguration::setSslKeyAlias);
        optionalString(PASSWORD.resolveModelAttribute(context, sslModel)).ifPresent(sslConfiguration::setSslTrustStorePassword);
        optionalString(PASSWORD.resolveModelAttribute(context, sslModel)).ifPresent(sslConfiguration::setSslKeyStorePassword);
        optionalString(CERTIFICATE_KEY_FILE.resolveModelAttribute(context, sslModel)).ifPresent(sslConfiguration::setSslKeyStore);
        optionalString(CIPHER_SUITE.resolveModelAttribute(context, sslModel)).ifPresent(sslConfiguration::setSslCiphers);
        optionalString(PROTOCOL.resolveModelAttribute(context, sslModel)).ifPresent(sslConfiguration::setSslProtocol);
        optionalString(CA_CERTIFICATE_FILE.resolveModelAttribute(context, sslModel)).ifPresent(sslConfiguration::setSslTrustStore);
        optionalString(CA_REVOCATION_URL.resolveModelAttribute(context, sslModel)).ifPresent(sslConfiguration::setSslCrlFile);
        builder.mcmp().setSocketFactory(new JSSESocketFactory(sslConfiguration));
    }
    return this;
}
Also used : OutboundSocketBinding(org.jboss.as.network.OutboundSocketBinding) SocketBinding(org.jboss.as.network.SocketBinding) FLUSH_WAIT(org.wildfly.extension.mod_cluster.ModClusterConfigResourceDefinition.FLUSH_WAIT) LOAD_BALANCING_GROUP(org.wildfly.extension.mod_cluster.ModClusterConfigResourceDefinition.LOAD_BALANCING_GROUP) SSLContext(javax.net.ssl.SSLContext) ROOT_LOGGER(org.wildfly.extension.mod_cluster.ModClusterLogger.ROOT_LOGGER) OutboundSocketBinding(org.jboss.as.network.OutboundSocketBinding) OperationContext(org.jboss.as.controller.OperationContext) SSL_CONTEXT(org.wildfly.extension.mod_cluster.ModClusterConfigResourceDefinition.SSL_CONTEXT) Map(java.util.Map) SessionDrainingStrategyEnum(org.jboss.modcluster.config.impl.SessionDrainingStrategyEnum) ServiceTarget(org.jboss.msc.service.ServiceTarget) WORKER_TIMEOUT(org.wildfly.extension.mod_cluster.ModClusterConfigResourceDefinition.WORKER_TIMEOUT) ModelNodes.optionalList(org.jboss.as.clustering.dmr.ModelNodes.optionalList) CA_REVOCATION_URL(org.wildfly.extension.mod_cluster.ModClusterSSLResourceDefinition.CA_REVOCATION_URL) AUTO_ENABLE_CONTEXTS(org.wildfly.extension.mod_cluster.ModClusterConfigResourceDefinition.AUTO_ENABLE_CONTEXTS) Collection(java.util.Collection) NetworkInterface(java.net.NetworkInterface) ADVERTISE_SECURITY_KEY(org.wildfly.extension.mod_cluster.ModClusterConfigResourceDefinition.ADVERTISE_SECURITY_KEY) Set(java.util.Set) ResourceServiceBuilder(org.jboss.as.clustering.controller.ResourceServiceBuilder) ADVERTISE_SOCKET(org.wildfly.extension.mod_cluster.ModClusterConfigResourceDefinition.ADVERTISE_SOCKET) InetSocketAddress(java.net.InetSocketAddress) Objects(java.util.Objects) SSL_CONTEXT_CAPABILITY_NAME(org.wildfly.extension.mod_cluster.ModClusterConfigResourceDefinition.SSL_CONTEXT_CAPABILITY_NAME) PASSWORD(org.wildfly.extension.mod_cluster.ModClusterSSLResourceDefinition.PASSWORD) PROTOCOL(org.wildfly.extension.mod_cluster.ModClusterSSLResourceDefinition.PROTOCOL) List(java.util.List) Stream(java.util.stream.Stream) OperationFailedException(org.jboss.as.controller.OperationFailedException) JSSESocketFactory(org.jboss.modcluster.mcmp.impl.JSSESocketFactory) ServiceName(org.jboss.msc.service.ServiceName) Optional(java.util.Optional) MAX_ATTEMPTS(org.wildfly.extension.mod_cluster.ModClusterConfigResourceDefinition.MAX_ATTEMPTS) ModelNode(org.jboss.dmr.ModelNode) Builder(org.wildfly.clustering.service.Builder) SESSION_DRAINING_STRATEGY(org.wildfly.extension.mod_cluster.ModClusterConfigResourceDefinition.SESSION_DRAINING_STRATEGY) ValueDependency(org.wildfly.clustering.service.ValueDependency) SMAX(org.wildfly.extension.mod_cluster.ModClusterConfigResourceDefinition.SMAX) Value(org.jboss.msc.value.Value) BALANCER(org.wildfly.extension.mod_cluster.ModClusterConfigResourceDefinition.BALANCER) ProxyConfiguration(org.jboss.modcluster.config.ProxyConfiguration) HashMap(java.util.HashMap) PROXY_URL(org.wildfly.extension.mod_cluster.ModClusterConfigResourceDefinition.PROXY_URL) PROXIES(org.wildfly.extension.mod_cluster.ModClusterConfigResourceDefinition.PROXIES) HashSet(java.util.HashSet) CIPHER_SUITE(org.wildfly.extension.mod_cluster.ModClusterSSLResourceDefinition.CIPHER_SUITE) SocketException(java.net.SocketException) KEY_ALIAS(org.wildfly.extension.mod_cluster.ModClusterSSLResourceDefinition.KEY_ALIAS) CERTIFICATE_KEY_FILE(org.wildfly.extension.mod_cluster.ModClusterSSLResourceDefinition.CERTIFICATE_KEY_FILE) SocketBinding(org.jboss.as.network.SocketBinding) InjectedValueDependency(org.wildfly.clustering.service.InjectedValueDependency) LinkedList(java.util.LinkedList) ModClusterConfiguration(org.jboss.modcluster.config.ModClusterConfiguration) PING(org.wildfly.extension.mod_cluster.ModClusterConfigResourceDefinition.PING) NODE_TIMEOUT(org.wildfly.extension.mod_cluster.ModClusterConfigResourceDefinition.NODE_TIMEOUT) STOP_CONTEXT_TIMEOUT(org.wildfly.extension.mod_cluster.ModClusterConfigResourceDefinition.STOP_CONTEXT_TIMEOUT) EXCLUDED_CONTEXTS(org.wildfly.extension.mod_cluster.ModClusterConfigResourceDefinition.EXCLUDED_CONTEXTS) ModClusterConfig(org.jboss.modcluster.config.impl.ModClusterConfig) ServiceBuilder(org.jboss.msc.service.ServiceBuilder) ModClusterConfigurationBuilder(org.jboss.modcluster.config.builder.ModClusterConfigurationBuilder) STICKY_SESSION(org.wildfly.extension.mod_cluster.ModClusterConfigResourceDefinition.STICKY_SESSION) STICKY_SESSION_FORCE(org.wildfly.extension.mod_cluster.ModClusterConfigResourceDefinition.STICKY_SESSION_FORCE) TimeUnit(java.util.concurrent.TimeUnit) CA_CERTIFICATE_FILE(org.wildfly.extension.mod_cluster.ModClusterSSLResourceDefinition.CA_CERTIFICATE_FILE) ServiceController(org.jboss.msc.service.ServiceController) ValueService(org.jboss.msc.service.ValueService) ADVERTISE(org.wildfly.extension.mod_cluster.ModClusterConfigResourceDefinition.ADVERTISE) TTL(org.wildfly.extension.mod_cluster.ModClusterConfigResourceDefinition.TTL) ModelNodes.optionalString(org.jboss.as.clustering.dmr.ModelNodes.optionalString) FLUSH_PACKETS(org.wildfly.extension.mod_cluster.ModClusterConfigResourceDefinition.FLUSH_PACKETS) SOCKET_TIMEOUT(org.wildfly.extension.mod_cluster.ModClusterConfigResourceDefinition.SOCKET_TIMEOUT) STICKY_SESSION_REMOVE(org.wildfly.extension.mod_cluster.ModClusterConfigResourceDefinition.STICKY_SESSION_REMOVE) Collections(java.util.Collections) Set(java.util.Set) HashSet(java.util.HashSet) OutboundSocketBinding(org.jboss.as.network.OutboundSocketBinding) OperationFailedException(org.jboss.as.controller.OperationFailedException) SessionDrainingStrategyEnum(org.jboss.modcluster.config.impl.SessionDrainingStrategyEnum) ModelNodes.optionalString(org.jboss.as.clustering.dmr.ModelNodes.optionalString) SSLContext(javax.net.ssl.SSLContext) ModClusterConfig(org.jboss.modcluster.config.impl.ModClusterConfig) InjectedValueDependency(org.wildfly.clustering.service.InjectedValueDependency) ModelNode(org.jboss.dmr.ModelNode) JSSESocketFactory(org.jboss.modcluster.mcmp.impl.JSSESocketFactory)

Example 38 with OperationFailedException

use of org.jboss.as.controller.OperationFailedException in project wildfly by wildfly.

the class JMSBridgeHandler method executeRuntimeStep.

@Override
protected void executeRuntimeStep(OperationContext context, ModelNode operation) throws OperationFailedException {
    final String bridgeName = PathAddress.pathAddress(operation.get(OP_ADDR)).getLastElement().getValue();
    final String operationName = operation.require(OP).asString();
    final boolean modify;
    if (READ_ATTRIBUTE_OPERATION.equals(operationName)) {
        modify = false;
    } else {
        modify = true;
    }
    final ServiceName bridgeServiceName = MessagingServices.getJMSBridgeServiceName(bridgeName);
    final ServiceController<?> bridgeService = context.getServiceRegistry(modify).getService(bridgeServiceName);
    if (bridgeService == null) {
        PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
        throw ControllerLogger.ROOT_LOGGER.managementResourceNotFound(address);
    }
    final JMSBridge bridge = JMSBridge.class.cast(bridgeService.getValue());
    if (READ_ATTRIBUTE_OPERATION.equals(operationName)) {
        readAttributeValidator.validate(operation);
        final String name = operation.require(NAME).asString();
        if (STARTED.equals(name)) {
            context.getResult().set(bridge.isStarted());
        } else if (PAUSED.getName().equals(name)) {
            context.getResult().set(bridge.isPaused());
        } else {
            throw MessagingLogger.ROOT_LOGGER.unsupportedAttribute(name);
        }
    } else if (START.equals(operationName)) {
        try {
            // we do not start the bridge directly but call startBridge() instead
            // to ensure the class loader will be able to load any external resources
            JMSBridgeService service = (JMSBridgeService) bridgeService.getService();
            service.startBridge();
        } catch (Exception e) {
            context.getFailureDescription().set(e.getLocalizedMessage());
        }
    } else if (STOP.equals(operationName)) {
        try {
            bridge.stop();
        } catch (Exception e) {
            context.getFailureDescription().set(e.getLocalizedMessage());
        }
    } else if (PAUSE.equals(operationName)) {
        try {
            bridge.pause();
        } catch (Exception e) {
            context.getFailureDescription().set(e.getLocalizedMessage());
        }
    } else if (RESUME.equals(operationName)) {
        try {
            bridge.resume();
        } catch (Exception e) {
            context.getFailureDescription().set(e.getLocalizedMessage());
        }
    } else {
        throw MessagingLogger.ROOT_LOGGER.unsupportedOperation(operationName);
    }
    context.completeStep(new OperationContext.RollbackHandler() {

        @Override
        public void handleRollback(OperationContext context, ModelNode operation) {
            try {
                if (START.equals(operationName)) {
                    bridge.stop();
                } else if (STOP.equals(operationName)) {
                    JMSBridgeService service = (JMSBridgeService) bridgeService.getService();
                    service.startBridge();
                } else if (PAUSE.equals(operationName)) {
                    bridge.resume();
                } else if (RESUME.equals(operationName)) {
                    bridge.pause();
                }
            } catch (Exception e) {
                MessagingLogger.ROOT_LOGGER.revertOperationFailed(e, getClass().getSimpleName(), operation.require(ModelDescriptionConstants.OP).asString(), PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR)));
            }
        }
    });
}
Also used : OperationContext(org.jboss.as.controller.OperationContext) ServiceName(org.jboss.msc.service.ServiceName) JMSBridge(org.apache.activemq.artemis.jms.bridge.JMSBridge) PathAddress(org.jboss.as.controller.PathAddress) ModelNode(org.jboss.dmr.ModelNode) OperationFailedException(org.jboss.as.controller.OperationFailedException)

Example 39 with OperationFailedException

use of org.jboss.as.controller.OperationFailedException in project wildfly by wildfly.

the class JMSBridgeRemove method recoverServices.

protected void recoverServices(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
    final PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
    final String bridgeName = address.getLastElement().getValue();
    final ServiceRegistry registry = context.getServiceRegistry(true);
    final ServiceName jmsBridgeServiceName = MessagingServices.getJMSBridgeServiceName(bridgeName);
    final ServiceController<?> jmsBridgeServiceController = registry.getService(jmsBridgeServiceName);
    if (jmsBridgeServiceController != null && jmsBridgeServiceController.getState() == ServiceController.State.UP) {
        JMSBridgeService jmsBridgeService = (JMSBridgeService) jmsBridgeServiceController.getService();
        try {
            jmsBridgeService.startBridge();
        } catch (Exception e) {
            throw MessagingLogger.ROOT_LOGGER.failedToRecover(e, bridgeName);
        }
    }
}
Also used : ServiceName(org.jboss.msc.service.ServiceName) PathAddress(org.jboss.as.controller.PathAddress) ServiceRegistry(org.jboss.msc.service.ServiceRegistry) OperationFailedException(org.jboss.as.controller.OperationFailedException)

Example 40 with OperationFailedException

use of org.jboss.as.controller.OperationFailedException in project wildfly by wildfly.

the class SecurityDomainAdd method createJSSESecurityDomain.

private JSSESecurityDomain createJSSESecurityDomain(OperationContext context, String securityDomain, ModelNode node) throws OperationFailedException {
    node = peek(node, JSSE, CLASSIC);
    if (node == null) {
        return null;
    }
    final JBossJSSESecurityDomain jsseSecurityDomain = new JBossJSSESecurityDomain(securityDomain);
    processKeyStore(context, node, KEYSTORE, new KeyStoreConfig() {

        public void setKeyStorePassword(String value) throws Exception {
            jsseSecurityDomain.setKeyStorePassword(value);
        }

        public void setKeyStoreType(String value) {
            jsseSecurityDomain.setKeyStoreType(value);
        }

        public void setKeyStoreURL(String value) throws IOException {
            jsseSecurityDomain.setKeyStoreURL(value);
        }

        public void setKeyStoreProvider(String value) {
            jsseSecurityDomain.setKeyStoreProvider(value);
        }

        public void setKeyStoreProviderArgument(String value) {
            jsseSecurityDomain.setKeyStoreProviderArgument(value);
        }
    });
    processKeyStore(context, node, Constants.TRUSTSTORE, new KeyStoreConfig() {

        public void setKeyStorePassword(String value) throws Exception {
            jsseSecurityDomain.setTrustStorePassword(value);
        }

        public void setKeyStoreType(String value) {
            jsseSecurityDomain.setTrustStoreType(value);
        }

        public void setKeyStoreURL(String value) throws IOException {
            jsseSecurityDomain.setTrustStoreURL(value);
        }

        public void setKeyStoreProvider(String value) {
            jsseSecurityDomain.setTrustStoreProvider(value);
        }

        public void setKeyStoreProviderArgument(String value) {
            jsseSecurityDomain.setTrustStoreProviderArgument(value);
        }
    });
    processKeyManager(context, node, Constants.KEY_MANAGER, new KeyManagerConfig() {

        public void setKeyManagerFactoryAlgorithm(String value) {
            jsseSecurityDomain.setKeyManagerFactoryAlgorithm(value);
        }

        public void setKeyManagerFactoryProvider(String value) {
            jsseSecurityDomain.setKeyManagerFactoryProvider(value);
        }
    });
    processKeyManager(context, node, Constants.TRUST_MANAGER, new KeyManagerConfig() {

        public void setKeyManagerFactoryAlgorithm(String value) {
            jsseSecurityDomain.setTrustManagerFactoryAlgorithm(value);
        }

        public void setKeyManagerFactoryProvider(String value) {
            jsseSecurityDomain.setTrustManagerFactoryProvider(value);
        }
    });
    String value;
    if (node.hasDefined(CLIENT_ALIAS)) {
        value = JSSEResourceDefinition.CLIENT_ALIAS.resolveModelAttribute(context, node).asString();
        jsseSecurityDomain.setClientAlias(value);
    }
    if (node.hasDefined(SERVER_ALIAS)) {
        value = JSSEResourceDefinition.SERVER_ALIAS.resolveModelAttribute(context, node).asString();
        jsseSecurityDomain.setServerAlias(value);
    }
    if (node.hasDefined(CLIENT_AUTH)) {
        boolean clientAuth = JSSEResourceDefinition.CLIENT_AUTH.resolveModelAttribute(context, node).asBoolean();
        jsseSecurityDomain.setClientAuth(clientAuth);
    }
    if (node.hasDefined(SERVICE_AUTH_TOKEN)) {
        value = JSSEResourceDefinition.SERVICE_AUTH_TOKEN.resolveModelAttribute(context, node).asString();
        try {
            jsseSecurityDomain.setServiceAuthToken(value);
        } catch (Exception e) {
            throw SecurityLogger.ROOT_LOGGER.runtimeException(e);
        }
    }
    if (node.hasDefined(CIPHER_SUITES)) {
        value = JSSEResourceDefinition.CIPHER_SUITES.resolveModelAttribute(context, node).asString();
        jsseSecurityDomain.setCipherSuites(value);
    }
    if (node.hasDefined(PROTOCOLS)) {
        value = JSSEResourceDefinition.PROTOCOLS.resolveModelAttribute(context, node).asString();
        jsseSecurityDomain.setProtocols(value);
    }
    if (node.hasDefined(ADDITIONAL_PROPERTIES)) {
        Properties properties = new Properties();
        properties.putAll(JSSEResourceDefinition.ADDITIONAL_PROPERTIES.unwrap(context, node));
        jsseSecurityDomain.setAdditionalProperties(properties);
    }
    return jsseSecurityDomain;
}
Also used : IOException(java.io.IOException) Properties(java.util.Properties) JBossJSSESecurityDomain(org.jboss.security.JBossJSSESecurityDomain) OperationFailedException(org.jboss.as.controller.OperationFailedException) IOException(java.io.IOException)

Aggregations

OperationFailedException (org.jboss.as.controller.OperationFailedException)113 ModelNode (org.jboss.dmr.ModelNode)86 PathAddress (org.jboss.as.controller.PathAddress)51 OperationContext (org.jboss.as.controller.OperationContext)49 OperationStepHandler (org.jboss.as.controller.OperationStepHandler)34 ServiceName (org.jboss.msc.service.ServiceName)33 Resource (org.jboss.as.controller.registry.Resource)26 ServiceController (org.jboss.msc.service.ServiceController)19 ServiceTarget (org.jboss.msc.service.ServiceTarget)15 PathElement (org.jboss.as.controller.PathElement)13 ServiceRegistry (org.jboss.msc.service.ServiceRegistry)12 IOException (java.io.IOException)11 Map (java.util.Map)11 ActiveMQServer (org.apache.activemq.artemis.core.server.ActiveMQServer)11 ArrayList (java.util.ArrayList)9 AttributeDefinition (org.jboss.as.controller.AttributeDefinition)9 ContextNames (org.jboss.as.naming.deployment.ContextNames)7 ServiceBuilder (org.jboss.msc.service.ServiceBuilder)7 List (java.util.List)6 ResourceServiceHandler (org.jboss.as.clustering.controller.ResourceServiceHandler)6