Search in sources :

Example 1 with ConfigurableElement

use of org.wildfly.test.security.common.elytron.ConfigurableElement in project wildfly by wildfly.

the class AbstractElytronSetupTask method setup.

/**
     * Creates configuration elements (provided by implementation of {@link #getConfigurableElements()} method) and calls
     * {@link ConfigurableElement#create(CLIWrapper)} for them.
     */
protected void setup(final ModelControllerClient modelControllerClient) throws Exception {
    configurableElements = getConfigurableElements();
    if (configurableElements == null || configurableElements.length == 0) {
        LOGGER.warn("Empty Elytron configuration.");
        return;
    }
    try (CLIWrapper cli = new CLIWrapper(true)) {
        for (final ConfigurableElement configurableElement : configurableElements) {
            LOGGER.infov("Adding element {0} ({1})", configurableElement.getName(), configurableElement.getClass().getSimpleName());
            configurableElement.create(cli);
        }
    }
    ServerReload.reloadIfRequired(modelControllerClient);
}
Also used : ConfigurableElement(org.wildfly.test.security.common.elytron.ConfigurableElement) CLIWrapper(org.jboss.as.test.integration.management.util.CLIWrapper)

Example 2 with ConfigurableElement

use of org.wildfly.test.security.common.elytron.ConfigurableElement in project wildfly by wildfly.

the class AbstractElytronSetupTask method tearDown.

/**
     * Reverts configuration changes done by {@link #setup(ModelControllerClient)} method - i.e. calls {@link ConfigurableElement#remove(CLIWrapper)} method
     * on instances provided by {@link #getConfigurableElements()} (in reverse order).
     */
protected void tearDown(ModelControllerClient modelControllerClient) throws Exception {
    if (configurableElements == null || configurableElements.length == 0) {
        LOGGER.warn("Empty Elytron configuration.");
        return;
    }
    try (CLIWrapper cli = new CLIWrapper(true)) {
        final ListIterator<ConfigurableElement> reverseConfigIt = Arrays.asList(configurableElements).listIterator(configurableElements.length);
        while (reverseConfigIt.hasPrevious()) {
            final ConfigurableElement configurableElement = reverseConfigIt.previous();
            LOGGER.infov("Removing element {0} ({1})", configurableElement.getName(), configurableElement.getClass().getSimpleName());
            configurableElement.remove(cli);
        }
    }
    this.configurableElements = null;
    ServerReload.reloadIfRequired(modelControllerClient);
}
Also used : ConfigurableElement(org.wildfly.test.security.common.elytron.ConfigurableElement) CLIWrapper(org.jboss.as.test.integration.management.util.CLIWrapper)

Aggregations

CLIWrapper (org.jboss.as.test.integration.management.util.CLIWrapper)2 ConfigurableElement (org.wildfly.test.security.common.elytron.ConfigurableElement)2