Search in sources :

Example 11 with NetworkConfig

use of org.glassfish.grizzly.config.dom.NetworkConfig in project Payara by payara.

the class DirectAccessTest method doTest.

public void doTest() throws TransactionFailure {
    NetworkConfig networkConfig = habitat.getService(NetworkConfig.class);
    final NetworkListener listener = networkConfig.getNetworkListeners().getNetworkListener().get(0);
    final Http http = listener.findHttpProtocol().getHttp();
    ConfigBean config = (ConfigBean) ConfigBean.unwrap(http.getFileCache());
    ConfigBean config2 = (ConfigBean) ConfigBean.unwrap(http);
    Map<ConfigBean, Map<String, String>> changes = new HashMap<ConfigBean, Map<String, String>>();
    Map<String, String> configChanges = new HashMap<String, String>();
    configChanges.put("max-age-seconds", "12543");
    configChanges.put("max-cache-size-bytes", "1200");
    Map<String, String> config2Changes = new HashMap<String, String>();
    config2Changes.put("http2-enabled", "false");
    changes.put(config, configChanges);
    changes.put(config2, config2Changes);
    JavaConfig javaConfig = habitat.getService(JavaConfig.class);
    ConfigBean javaConfigBean = (ConfigBean) ConfigBean.unwrap(javaConfig);
    Map<String, String> javaConfigChanges = new HashMap<String, String>();
    javaConfigChanges.put("jvm-options", "-XFooBar=false");
    changes.put(javaConfigBean, javaConfigChanges);
    getHabitat().<ConfigSupport>getService(ConfigSupport.class).apply(changes);
}
Also used : JavaConfig(com.sun.enterprise.config.serverbeans.JavaConfig) ConfigSupport(org.jvnet.hk2.config.ConfigSupport) HashMap(java.util.HashMap) NetworkConfig(org.glassfish.grizzly.config.dom.NetworkConfig) Http(org.glassfish.grizzly.config.dom.Http) ConfigBean(org.jvnet.hk2.config.ConfigBean) Map(java.util.Map) HashMap(java.util.HashMap) NetworkListener(org.glassfish.grizzly.config.dom.NetworkListener)

Example 12 with NetworkConfig

use of org.glassfish.grizzly.config.dom.NetworkConfig in project Payara by payara.

the class EnabledTest method setup.

@Before
public void setup() {
    NetworkConfig service = getHabitat().getService(NetworkConfig.class);
    assertTrue(service != null);
    listeners = service.getNetworkListeners().getNetworkListener();
}
Also used : NetworkConfig(org.glassfish.grizzly.config.dom.NetworkConfig) Before(org.junit.Before)

Example 13 with NetworkConfig

use of org.glassfish.grizzly.config.dom.NetworkConfig in project Payara by payara.

the class SecureAdminConfigUpgrade method ensureConfigReady.

// private void prepareNonDASConfigs() throws TransactionFailure, PropertyVetoException {
// for (Config c : configs.getConfig()) {
// if (c.getName().equals(DAS_CONFIG_NAME)) {
// continue;
// }
// ensureConfigReady(c, SecureAdminCommand.PORT_UNIF_PROTOCOL_NAME);
// }
// }
private void ensureConfigReady(final Config c, final String adminListenerProtocol) throws TransactionFailure, PropertyVetoException {
    final NetworkConfig nc = c.getNetworkConfig();
    final NetworkListener nl = nc.getNetworkListener(SecureAdminCommand.ADMIN_LISTENER_NAME);
    if (nl != null) {
        return;
    }
    /*
         * Create an admin-listener for this configuration.
         */
    final Config config_w = writableConfig(c);
    createAdminNetworkListener(transaction(), nc, adminListenerProtocol);
    createAdminVirtualServer(transaction(), config_w);
}
Also used : Config(com.sun.enterprise.config.serverbeans.Config) NetworkConfig(org.glassfish.grizzly.config.dom.NetworkConfig) NetworkConfig(org.glassfish.grizzly.config.dom.NetworkConfig) NetworkListener(org.glassfish.grizzly.config.dom.NetworkListener)

Example 14 with NetworkConfig

use of org.glassfish.grizzly.config.dom.NetworkConfig in project Payara by payara.

the class SecureAdminUpgradeHelper method ensureConfigReady.

private boolean ensureConfigReady(final Config c) throws TransactionFailure {
    /*
         * See if this config is already set up for secure admin.
         */
    final NetworkConfig nc = c.getNetworkConfig();
    if (nc == null) {
        /*
             * If there is no network config for this configuration then it is
             * probably a test configuration of some sort.  In any case, there
             * is no lower-level network protocols to verify so declare this
             * config to be OK.
             */
        return true;
    }
    Protocol secAdminProtocol = nc.getProtocols().findProtocol(SecureAdminCommand.SEC_ADMIN_LISTENER_PROTOCOL_NAME);
    if (secAdminProtocol != null) {
        return true;
    }
    final EnableSecureAdminCommand enableCmd = new EnableSecureAdminCommand();
    final Config c_w = transaction().enroll(c);
    ConfigLevelContext configLevelContext = new ConfigLevelContext(topLevelContext(), c_w);
    for (Iterator<Work<ConfigLevelContext>> it = enableCmd.perConfigSteps(); it.hasNext(); ) {
        final Work<ConfigLevelContext> step = it.next();
        if (!step.run(configLevelContext)) {
            rollback();
            return false;
        }
    }
    return true;
}
Also used : ConfigLevelContext(com.sun.enterprise.security.admin.cli.SecureAdminCommand.ConfigLevelContext) Config(com.sun.enterprise.config.serverbeans.Config) NetworkConfig(org.glassfish.grizzly.config.dom.NetworkConfig) NetworkConfig(org.glassfish.grizzly.config.dom.NetworkConfig) Work(com.sun.enterprise.security.admin.cli.SecureAdminCommand.Work) Protocol(org.glassfish.grizzly.config.dom.Protocol)

Example 15 with NetworkConfig

use of org.glassfish.grizzly.config.dom.NetworkConfig in project Payara by payara.

the class ProtocolSslConfigHandler method delete.

@Override
public void delete(final DeleteSsl command, final ActionReport report) {
    try {
        NetworkConfig networkConfig = command.config.getNetworkConfig();
        final Protocol protocol = networkConfig.findProtocol(command.listenerId);
        if (protocol != null) {
            ConfigSupport.apply(new SingleConfigCode<Protocol>() {

                public Object run(Protocol param) {
                    param.setSecurityEnabled("false");
                    param.setSsl(null);
                    return null;
                }
            }, protocol);
        }
    } catch (TransactionFailure transactionFailure) {
        command.reportError(report, transactionFailure);
    }
}
Also used : TransactionFailure(org.jvnet.hk2.config.TransactionFailure) NetworkConfig(org.glassfish.grizzly.config.dom.NetworkConfig) Protocol(org.glassfish.grizzly.config.dom.Protocol)

Aggregations

NetworkConfig (org.glassfish.grizzly.config.dom.NetworkConfig)33 NetworkListener (org.glassfish.grizzly.config.dom.NetworkListener)21 Config (com.sun.enterprise.config.serverbeans.Config)18 TransactionFailure (org.jvnet.hk2.config.TransactionFailure)16 Protocol (org.glassfish.grizzly.config.dom.Protocol)14 ActionReport (org.glassfish.api.ActionReport)10 CommandTarget (org.glassfish.config.support.CommandTarget)10 Target (org.glassfish.internal.api.Target)10 NetworkListeners (org.glassfish.grizzly.config.dom.NetworkListeners)6 Protocols (org.glassfish.grizzly.config.dom.Protocols)6 VirtualServer (com.sun.enterprise.config.serverbeans.VirtualServer)5 HttpService (com.sun.enterprise.config.serverbeans.HttpService)4 ConfigBeanProxy (org.jvnet.hk2.config.ConfigBeanProxy)4 PropertyVetoException (java.beans.PropertyVetoException)3 Http (org.glassfish.grizzly.config.dom.Http)3 Ssl (org.glassfish.grizzly.config.dom.Ssl)3 Transport (org.glassfish.grizzly.config.dom.Transport)3 JavaConfig (com.sun.enterprise.config.serverbeans.JavaConfig)2 SystemProperty (com.sun.enterprise.config.serverbeans.SystemProperty)2 Result (com.sun.enterprise.util.Result)2