Search in sources :

Example 1 with org.apache.struts2.config

use of org.apache.struts2.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.apache.struts2.config

use of org.apache.struts2.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.apache.struts2.config

use of org.apache.struts2.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.apache.struts2.config

use of org.apache.struts2.config in project qi4j-sdk by Qi4j.

the class Qi4jCodebehindPackageProvider method loadPackageConfig.

/**
 * Finds or creates the package configuration for an Action class.
 *
 * The namespace annotation is honored, if found,
 * and the namespace is checked for a parent configuration.
 *
 * @param actionNamespace The configuration namespace
 * @param actionPackage   The Java package containing our Action classes
 * @param actionClass     The Action class instance
 *
 * @return PackageConfig object for the Action class
 */
protected PackageConfig.Builder loadPackageConfig(String actionNamespace, String actionPackage, Class actionClass) {
    PackageConfig.Builder parent = null;
    // Check for the @Namespace annotation
    if (actionClass != null) {
        Namespace ns = (Namespace) actionClass.getAnnotation(Namespace.class);
        if (ns != null) {
            parent = loadPackageConfig(actionNamespace, actionPackage, null);
            actionNamespace = ns.value();
            actionPackage = actionClass.getName();
        // See if the namespace has been overridden by the @Action annotation
        } else {
            org.apache.struts2.config.Action actionAnn = (org.apache.struts2.config.Action) actionClass.getAnnotation(org.apache.struts2.config.Action.class);
            if (actionAnn != null && !actionAnn.DEFAULT_NAMESPACE.equals(actionAnn.namespace())) {
                // we pass null as the namespace in case the parent package hasn't been loaded yet
                parent = loadPackageConfig(null, actionPackage, null);
                actionPackage = actionClass.getName();
            }
        }
    }
    PackageConfig.Builder pkgConfig = packageLoader.getPackage(actionPackage);
    if (pkgConfig == null) {
        pkgConfig = new PackageConfig.Builder(actionPackage);
        pkgConfig.namespace(actionNamespace);
        if (parent == null) {
            PackageConfig cfg = configuration.getPackageConfig(defaultParentPackage);
            if (cfg != null) {
                pkgConfig.addParent(cfg);
            } else {
                throw new ConfigurationException("ClasspathPackageProvider: Unable to locate default parent package: " + defaultParentPackage);
            }
        }
        packageLoader.registerPackage(pkgConfig);
    // if the parent package was first created by a child, ensure the namespace is correct
    } else if (pkgConfig.getNamespace() == null) {
        pkgConfig.namespace(actionNamespace);
    }
    if (parent != null) {
        packageLoader.registerChildToParent(pkgConfig, parent);
    }
    if (LOG.isDebugEnabled()) {
        LOG.debug("class:" + actionClass + " parent:" + parent + " current:" + (pkgConfig != null ? pkgConfig.getName() : ""));
    }
    return pkgConfig;
}
Also used : ConfigurationException(com.opensymphony.xwork2.config.ConfigurationException) org.apache.struts2.config(org.apache.struts2.config) PackageConfig(com.opensymphony.xwork2.config.entities.PackageConfig)

Example 5 with org.apache.struts2.config

use of org.apache.struts2.config in project Payara by payara.

the class WebContainerImpl method setConfiguration.

// --------------------------------------------------------- Public Methods
public void setConfiguration(WebContainerConfig config) {
    if (!initialized) {
        init();
    }
    this.config = config;
    final WebContainerConfig webConfig = config;
    try {
        VirtualServer vs = getVirtualServer(config.getVirtualServerId());
        if (vs != null) {
            ((StandardHost) vs).setDefaultWebXmlLocation(config.getDefaultWebXml().getPath());
        }
        com.sun.enterprise.config.serverbeans.VirtualServer vsBean = httpService.getVirtualServerByName(config.getVirtualServerId());
        if (vsBean != null) {
            ConfigSupport.apply(new SingleConfigCode<com.sun.enterprise.config.serverbeans.VirtualServer>() {

                public Object run(com.sun.enterprise.config.serverbeans.VirtualServer avs) throws PropertyVetoException, TransactionFailure {
                    avs.setId(webConfig.getVirtualServerId());
                    if (webConfig.getDocRootDir() != null) {
                        avs.setDocroot(webConfig.getDocRootDir().getAbsolutePath());
                    }
                    avs.setHosts(webConfig.getHostNames());
                    avs.setNetworkListeners(webConfig.getListenerName());
                    Property property = avs.createChild(Property.class);
                    property.setName("default-web-xml");
                    property.setValue(webConfig.getDefaultWebXml().getPath());
                    avs.getProperty().add(property);
                    return avs;
                }
            }, vsBean);
        } else {
            vs = createVirtualServer(config.getVirtualServerId(), config.getDocRootDir());
            addVirtualServer(vs);
        }
        EmbeddedWebArchivist archivist = habitat.<EmbeddedWebArchivist>getService(EmbeddedWebArchivist.class);
        archivist.setDefaultWebXml(config.getDefaultWebXml());
        embedded.setDirectoryListing(config.getListings());
        WebListener listener = getWebListener(config.getListenerName());
        if (listener == null) {
            listener = getWebListener(config.getPort());
            if (listener == null) {
                boolean found = false;
                for (Map.Entry entry : webContainer.getConnectorMap().entrySet()) {
                    if (((WebConnector) entry.getValue()).getPort() == config.getPort()) {
                        found = true;
                        log.info("Port " + config.getPort() + " is already configured");
                    }
                }
                if (!found) {
                    listener = createWebListener(config.getListenerName(), HttpListener.class);
                    listener.setPort(config.getPort());
                    addWebListener(listener, config.getVirtualServerId());
                }
            }
        } else {
            if (listener.getPort() != config.getPort()) {
                listener.setPort(config.getPort());
            }
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
Also used : WebContainerConfig(org.glassfish.embeddable.web.config.WebContainerConfig) PropertyVetoException(java.beans.PropertyVetoException) GlassFishException(org.glassfish.embeddable.GlassFishException) PropertyVetoException(java.beans.PropertyVetoException) StandardHost(org.apache.catalina.core.StandardHost) org.jvnet.hk2.config(org.jvnet.hk2.config) Property(org.jvnet.hk2.config.types.Property) Map(java.util.Map)

Aggregations

Config (sun.security.krb5.Config)8 Dispatcher (org.apache.struts2.dispatcher.Dispatcher)4 KrbException (sun.security.krb5.KrbException)3 ConfigurationException (com.opensymphony.xwork2.config.ConfigurationException)2 PackageConfig (com.opensymphony.xwork2.config.entities.PackageConfig)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 org.apache.struts2.config (org.apache.struts2.config)2 ExecuteOperations (org.apache.struts2.dispatcher.ExecuteOperations)2 Test (org.junit.Test)2 RequestContext (com.agiletec.aps.system.RequestContext)1 InitOperations (com.agiletec.apsadmin.system.dispatcher.InitOperations)1 PrepareOperations (com.agiletec.apsadmin.system.dispatcher.PrepareOperations)1 ActionConfig (com.opensymphony.xwork2.config.entities.ActionConfig)1 ResultTypeConfig (com.opensymphony.xwork2.config.entities.ResultTypeConfig)1 PropertyVetoException (java.beans.PropertyVetoException)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 PrintStream (java.io.PrintStream)1 Annotation (java.lang.annotation.Annotation)1