Search in sources :

Example 51 with Config

use of com.sun.enterprise.config.serverbeans.Config 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 52 with Config

use of com.sun.enterprise.config.serverbeans.Config 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 53 with Config

use of com.sun.enterprise.config.serverbeans.Config in project Payara by payara.

the class CLIUtil method chooseConfig.

/**
 * Selects a config of interest from the domain, based on the target.
 * (Eliminates duplicated code formerly in Create, Delete, and ListAuthRealm).
 *
 * @param domain
 * @param target
 * @return
 */
static Config chooseConfig(final Domain domain, final String target) {
    Config config = null;
    Config tmp = null;
    try {
        tmp = domain.getConfigs().getConfigByName(target);
    } catch (Exception ex) {
    }
    if (tmp != null) {
        return tmp;
    }
    Server targetServer = domain.getServerNamed(target);
    if (targetServer != null) {
        config = domain.getConfigNamed(targetServer.getConfigRef());
    }
    com.sun.enterprise.config.serverbeans.Cluster cluster = domain.getClusterNamed(target);
    if (cluster != null) {
        config = domain.getConfigNamed(cluster.getConfigRef());
    }
    return config;
}
Also used : Server(com.sun.enterprise.config.serverbeans.Server) Config(com.sun.enterprise.config.serverbeans.Config) MessageSecurityConfig(com.sun.enterprise.config.serverbeans.MessageSecurityConfig)

Example 54 with Config

use of com.sun.enterprise.config.serverbeans.Config in project Payara by payara.

the class UpdateResourceRef method execute.

/**
 * Execution method for updating the configuration of a ResourceRef. Will be
 * replicated if the target is a cluster.
 *
 * @param context context for the command.
 */
@Override
public void execute(AdminCommandContext context) {
    final ActionReport report = context.getActionReport();
    final Logger logger = context.getLogger();
    // Make a list of all ResourceRefs that need to change
    List<ResourceRef> resourceRefsToChange = new ArrayList<>();
    // Add the ResourceRef from a named server if the target is a server
    Server server = domain.getServerNamed(target);
    // if the target is a server
    if (server != null) {
        ResourceRef serverResourceRef = server.getResourceRef(name);
        // if the ResourceRef doesn't exist
        if (serverResourceRef == null) {
            report.failure(logger, LOCAL_STRINGS.getLocalString("resource.ref.not.exists", "Target {1} does not have a reference to resource {0}.", name, target));
            return;
        }
        resourceRefsToChange.add(serverResourceRef);
    }
    // Add the ResourceRef from a named config if the target is a config
    Config config = domain.getConfigNamed(target);
    // if the target is a config
    if (config != null) {
        ResourceRef configResourceRef = config.getResourceRef(name);
        // if the ResourceRef doesn't exist
        if (configResourceRef == null) {
            report.failure(logger, LOCAL_STRINGS.getLocalString("resource.ref.not.exists", "Target {1} does not have a reference to resource {0}.", name, target));
            return;
        }
        resourceRefsToChange.add(configResourceRef);
    }
    // Add the ResourceRefs from a named cluster if the target is a cluster
    Cluster cluster = domain.getClusterNamed(target);
    // if the target is a cluster
    if (cluster != null) {
        ResourceRef clusterResourceRef = cluster.getResourceRef(name);
        // if the ResourceRef doesn't exist
        if (clusterResourceRef == null) {
            report.failure(logger, LOCAL_STRINGS.getLocalString("resource.ref.not.exists", "Target {1} does not have a reference to resource {0}.", name, target));
            return;
        }
        resourceRefsToChange.add(clusterResourceRef);
        for (Server instance : cluster.getInstances()) {
            ResourceRef instanceResourceRef = instance.getResourceRef(name);
            // if the server in the cluster contains the ResourceRef
            if (instanceResourceRef != null) {
                resourceRefsToChange.add(instanceResourceRef);
            }
        }
    }
    // Add the ResourceRefs from a named Deployment Group if the target is a Deployment Group
    DeploymentGroup dg = domain.getDeploymentGroupNamed(target);
    if (dg != null) {
        ResourceRef ref = dg.getResourceRef(name);
        if (ref == null) {
            report.failure(logger, LOCAL_STRINGS.getLocalString("resource.ref.not.exists", "Target {1} does not have a reference to resource {0}.", name, target));
            return;
        }
        resourceRefsToChange.add(ref);
        for (Server instance : dg.getInstances()) {
            ResourceRef instanceResourceRef = instance.getResourceRef(name);
            // if the server in the dg contains the ResourceRef
            if (instanceResourceRef != null) {
                resourceRefsToChange.add(instanceResourceRef);
            }
        }
    }
    // Apply the configuration to the listed ResourceRefs
    try {
        ConfigSupport.apply(new ConfigCode() {

            @Override
            public Object run(ConfigBeanProxy... params) throws PropertyVetoException, TransactionFailure {
                for (ConfigBeanProxy proxy : params) {
                    if (proxy instanceof ResourceRef) {
                        ResourceRef resourceRefProxy = (ResourceRef) proxy;
                        if (enabled != null) {
                            resourceRefProxy.setEnabled(enabled.toString());
                        }
                    }
                }
                report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
                return true;
            }
        }, resourceRefsToChange.toArray(new ResourceRef[] {}));
    } catch (TransactionFailure ex) {
        report.failure(logger, ex.getLocalizedMessage());
    }
}
Also used : TransactionFailure(org.jvnet.hk2.config.TransactionFailure) Server(com.sun.enterprise.config.serverbeans.Server) Config(com.sun.enterprise.config.serverbeans.Config) ArrayList(java.util.ArrayList) Cluster(com.sun.enterprise.config.serverbeans.Cluster) ActionReport(org.glassfish.api.ActionReport) Logger(java.util.logging.Logger) PropertyVetoException(java.beans.PropertyVetoException) ConfigBeanProxy(org.jvnet.hk2.config.ConfigBeanProxy) ConfigCode(org.jvnet.hk2.config.ConfigCode) ResourceRef(com.sun.enterprise.config.serverbeans.ResourceRef) DeploymentGroup(fish.payara.enterprise.config.serverbeans.DeploymentGroup)

Example 55 with Config

use of com.sun.enterprise.config.serverbeans.Config in project Payara by payara.

the class ClusterCommandHelper method getAdminThreadPoolSize.

/**
 * Get the size of the admin threadpool
 */
private int getAdminThreadPoolSize(Logger logger) {
    final int DEFAULT_POOL_SIZE = 5;
    // Get the DAS configuratoin
    Config config = domain.getConfigNamed("server-config");
    if (config == null)
        return DEFAULT_POOL_SIZE;
    AdminEndpointDecider aed = new AdminEndpointDecider(config);
    return aed.getMaxThreadPoolSize();
}
Also used : Config(com.sun.enterprise.config.serverbeans.Config) AdminEndpointDecider(com.sun.enterprise.v3.admin.adapter.AdminEndpointDecider)

Aggregations

Config (com.sun.enterprise.config.serverbeans.Config)152 ActionReport (org.glassfish.api.ActionReport)73 TransactionFailure (org.jvnet.hk2.config.TransactionFailure)50 PropertyVetoException (java.beans.PropertyVetoException)34 Target (org.glassfish.internal.api.Target)31 CommandTarget (org.glassfish.config.support.CommandTarget)30 Properties (java.util.Properties)28 NetworkConfig (org.glassfish.grizzly.config.dom.NetworkConfig)23 Protocol (org.glassfish.grizzly.config.dom.Protocol)20 HashMap (java.util.HashMap)17 Server (com.sun.enterprise.config.serverbeans.Server)15 NetworkListener (org.glassfish.grizzly.config.dom.NetworkListener)15 Logger (java.util.logging.Logger)14 ColumnFormatter (com.sun.enterprise.util.ColumnFormatter)13 Protocols (org.glassfish.grizzly.config.dom.Protocols)12 ArrayList (java.util.ArrayList)11 List (java.util.List)11 BlockingQueueHandler (fish.payara.nucleus.notification.BlockingQueueHandler)10 Level (java.util.logging.Level)10 LogRecord (java.util.logging.LogRecord)10