Search in sources :

Example 1 with org.jvnet.hk2.config

use of org.jvnet.hk2.config in project jdk8u_jdk by JetBrains.

the class Semicolon method main.

public static void main(String[] args) throws Throwable {
    System.setProperty("java.security.krb5.conf", System.getProperty("test.src", ".") + "/comments.conf");
    Config config = Config.getInstance();
    config.get("section", "value");
}
Also used : Config(sun.security.krb5.Config)

Example 2 with org.jvnet.hk2.config

use of org.jvnet.hk2.config in project jdk8u_jdk by JetBrains.

the class ConfigWithQuotations method main.

public static void main(String[] args) throws Exception {
    // This config file is generated using Kerberos.app on a Mac
    System.setProperty("java.security.krb5.conf", System.getProperty("test.src", ".") + "/edu.mit.Kerberos");
    Config config = Config.getInstance();
    System.out.println(config);
    if (!config.getDefaultRealm().equals("MAC.LOCAL")) {
        throw new Exception("Realm error");
    }
    if (!config.getKDCList("MAC.LOCAL").equals("kdc.mac.local:88")) {
        throw new Exception("KDC error");
    }
}
Also used : Config(sun.security.krb5.Config)

Example 3 with org.jvnet.hk2.config

use of org.jvnet.hk2.config in project jdk8u_jdk by JetBrains.

the class KDCOptions method setDefault.

private void setDefault() {
    try {
        Config config = Config.getInstance();
        // If key not present, returns Integer.MIN_VALUE, which is
        // almost all zero.
        int options = config.getIntValue("libdefaults", "kdc_default_options");
        if ((options & KDC_OPT_RENEWABLE_OK) == KDC_OPT_RENEWABLE_OK) {
            set(RENEWABLE_OK, true);
        } else {
            if (config.getBooleanValue("libdefaults", "renewable")) {
                set(RENEWABLE_OK, true);
            }
        }
        if ((options & KDC_OPT_PROXIABLE) == KDC_OPT_PROXIABLE) {
            set(PROXIABLE, true);
        } else {
            if (config.getBooleanValue("libdefaults", "proxiable")) {
                set(PROXIABLE, true);
            }
        }
        if ((options & KDC_OPT_FORWARDABLE) == KDC_OPT_FORWARDABLE) {
            set(FORWARDABLE, true);
        } else {
            if (config.getBooleanValue("libdefaults", "forwardable")) {
                set(FORWARDABLE, true);
            }
        }
    } catch (KrbException e) {
        if (DEBUG) {
            System.out.println("Exception in getting default values for " + "KDC Options from the configuration ");
            e.printStackTrace();
        }
    }
}
Also used : Config(sun.security.krb5.Config) KrbException(sun.security.krb5.KrbException)

Example 4 with org.jvnet.hk2.config

use of org.jvnet.hk2.config in project Payara by payara.

the class BaseRequestTracingNotifierConfigurer method execute.

@Override
public void execute(AdminCommandContext context) {
    final ActionReport actionReport = context.getActionReport();
    Properties extraProperties = actionReport.getExtraProperties();
    if (extraProperties == null) {
        extraProperties = new Properties();
        actionReport.setExtraProperties(extraProperties);
    }
    Config config = targetUtil.getConfig(target);
    final RequestTracingServiceConfiguration configuration = config.getExtensionByType(RequestTracingServiceConfiguration.class);
    ParameterizedType genericSuperclass = (ParameterizedType) getClass().getGenericSuperclass();
    notifierClass = (Class<C>) genericSuperclass.getActualTypeArguments()[0];
    C c = configuration.getNotifierByType(notifierClass);
    try {
        if (c == null) {
            ConfigSupport.apply(new SingleConfigCode<RequestTracingServiceConfiguration>() {

                @Override
                public Object run(final RequestTracingServiceConfiguration configurationProxy) throws PropertyVetoException, TransactionFailure {
                    C c = configurationProxy.createChild(notifierClass);
                    applyValues(c);
                    configurationProxy.getNotifierList().add(c);
                    actionReport.setActionExitCode(ActionReport.ExitCode.SUCCESS);
                    return configurationProxy;
                }
            }, configuration);
        } else {
            ConfigSupport.apply(new SingleConfigCode<C>() {

                public Object run(C cProxy) throws PropertyVetoException, TransactionFailure {
                    applyValues(cProxy);
                    actionReport.setActionExitCode(ActionReport.ExitCode.SUCCESS);
                    return cProxy;
                }
            }, c);
        }
        if (dynamic) {
            if (server.isDas()) {
                if (targetUtil.getConfig(target).isDas()) {
                    configureDynamically();
                }
            } else {
                configureDynamically();
            }
        }
    } catch (TransactionFailure ex) {
        logger.log(Level.WARNING, "Exception during command ", ex);
        actionReport.setMessage(ex.getCause().getMessage());
        actionReport.setActionExitCode(ActionReport.ExitCode.FAILURE);
    }
}
Also used : ParameterizedType(java.lang.reflect.ParameterizedType) PropertyVetoException(java.beans.PropertyVetoException) TransactionFailure(org.jvnet.hk2.config.TransactionFailure) Config(com.sun.enterprise.config.serverbeans.Config) ActionReport(org.glassfish.api.ActionReport) Properties(java.util.Properties) RequestTracingServiceConfiguration(fish.payara.nucleus.requesttracing.configuration.RequestTracingServiceConfiguration)

Example 5 with org.jvnet.hk2.config

use of org.jvnet.hk2.config in project Payara by payara.

the class BaseNotificationConfigurer method execute.

@Override
public void execute(final AdminCommandContext context) {
    final ActionReport actionReport = context.getActionReport();
    Properties extraProperties = actionReport.getExtraProperties();
    if (extraProperties == null) {
        extraProperties = new Properties();
        actionReport.setExtraProperties(extraProperties);
    }
    Config configuration = targetUtil.getConfig(target);
    final NotificationServiceConfiguration notificationServiceConfiguration = configuration.getExtensionByType(NotificationServiceConfiguration.class);
    ParameterizedType genericSuperclass = (ParameterizedType) getClass().getGenericSuperclass();
    notifierConfigurationClass = (Class<C>) genericSuperclass.getActualTypeArguments()[0];
    C c = notificationServiceConfiguration.getNotifierConfigurationByType(notifierConfigurationClass);
    try {
        if (c == null) {
            ConfigSupport.apply(new SingleConfigCode<NotificationServiceConfiguration>() {

                @Override
                public Object run(final NotificationServiceConfiguration notificationServiceConfigurationProxy) throws PropertyVetoException, TransactionFailure {
                    C c = notificationServiceConfigurationProxy.createChild(notifierConfigurationClass);
                    applyValues(c);
                    notificationServiceConfigurationProxy.getNotifierConfigurationList().add(c);
                    actionReport.setActionExitCode(ActionReport.ExitCode.SUCCESS);
                    ParameterMap params = new ParameterMap();
                    params.add("enabled", Boolean.TRUE.toString());
                    params.add("dynamic", Boolean.TRUE.toString());
                    params.add("target", target);
                    ActionReport healthCheckSubReport = actionReport.addSubActionsReport();
                    CommandRunner.CommandInvocation healthCheckCommandInvocation = commandRunner.getCommandInvocation(getHealthCheckNotifierCommandName(), healthCheckSubReport, context.getSubject());
                    healthCheckCommandInvocation.parameters(params);
                    healthCheckCommandInvocation.execute();
                    if (healthCheckSubReport.hasFailures()) {
                        logger.log(Level.SEVERE, "Error occurred while configuring notifier with command: " + getHealthCheckNotifierCommandName());
                    }
                    ActionReport requestTracingSubReport = actionReport.addSubActionsReport();
                    CommandRunner.CommandInvocation requestTracingCommandInvocation = commandRunner.getCommandInvocation(getRequestTracingNotifierCommandName(), requestTracingSubReport, context.getSubject());
                    requestTracingCommandInvocation.parameters(params);
                    requestTracingCommandInvocation.execute();
                    if (requestTracingSubReport.hasFailures()) {
                        logger.log(Level.SEVERE, "Error occurred while configuring notifier with command: " + getRequestTracingNotifierCommandName());
                    }
                    return notificationServiceConfigurationProxy;
                }
            }, notificationServiceConfiguration);
        } else {
            ConfigSupport.apply(new SingleConfigCode<C>() {

                public Object run(C cProxy) throws PropertyVetoException, TransactionFailure {
                    applyValues(cProxy);
                    actionReport.setActionExitCode(ActionReport.ExitCode.SUCCESS);
                    return cProxy;
                }
            }, c);
        }
        if (dynamic) {
            if (server.isDas()) {
                if (targetUtil.getConfig(target).isDas()) {
                    configureDynamically();
                }
            } else {
                configureDynamically();
            }
        }
    } catch (TransactionFailure ex) {
        logger.log(Level.WARNING, "Exception during command ", ex);
        actionReport.setMessage(ex.getCause().getMessage());
        actionReport.setActionExitCode(ActionReport.ExitCode.FAILURE);
    }
}
Also used : TransactionFailure(org.jvnet.hk2.config.TransactionFailure) Config(com.sun.enterprise.config.serverbeans.Config) ActionReport(org.glassfish.api.ActionReport) Properties(java.util.Properties) ParameterizedType(java.lang.reflect.ParameterizedType) PropertyVetoException(java.beans.PropertyVetoException) NotificationServiceConfiguration(fish.payara.nucleus.notification.configuration.NotificationServiceConfiguration)

Aggregations

TransactionFailure (org.jvnet.hk2.config.TransactionFailure)100 Config (com.sun.enterprise.config.serverbeans.Config)81 ActionReport (org.glassfish.api.ActionReport)79 PropertyVetoException (java.beans.PropertyVetoException)69 Property (org.jvnet.hk2.config.types.Property)53 Properties (java.util.Properties)24 CommandTarget (org.glassfish.config.support.CommandTarget)24 Target (org.glassfish.internal.api.Target)23 ArrayList (java.util.ArrayList)20 HashMap (java.util.HashMap)16 List (java.util.List)16 NetworkConfig (org.glassfish.grizzly.config.dom.NetworkConfig)16 ConfigBeanProxy (org.jvnet.hk2.config.ConfigBeanProxy)16 NetworkListener (org.glassfish.grizzly.config.dom.NetworkListener)15 Protocol (org.glassfish.grizzly.config.dom.Protocol)15 PropertyChangeEvent (java.beans.PropertyChangeEvent)14 Server (com.sun.enterprise.config.serverbeans.Server)13 IOException (java.io.IOException)12 Protocols (org.glassfish.grizzly.config.dom.Protocols)12 File (java.io.File)11