Search in sources :

Example 1 with Config

use of org.neo4j.driver.v1.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 Config

use of org.neo4j.driver.v1.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 Config

use of org.neo4j.driver.v1.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 Config

use of org.neo4j.driver.v1.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)

Example 5 with Config

use of org.neo4j.driver.v1.Config in project neo4j by neo4j.

the class BoltCausalClusteringIT method shouldPickANewServerToWriteToOnLeaderSwitch.

@Test
public void shouldPickANewServerToWriteToOnLeaderSwitch() throws Throwable {
    // given
    cluster = clusterRule.withNumberOfReadReplicas(0).startCluster();
    CoreClusterMember leader = cluster.awaitLeader();
    LeaderSwitcher leaderSwitcher = new LeaderSwitcher(cluster);
    Config config = Config.build().withLogging(new JULogging(Level.OFF)).toConfig();
    Set<BoltServerAddress> seenAddresses = new HashSet<>();
    try (Driver driver = GraphDatabase.driver(leader.routingURI(), AuthTokens.basic("neo4j", "neo4j"), config)) {
        boolean success = false;
        long deadline = System.currentTimeMillis() + (30 * 1000);
        while (!success) {
            if (System.currentTimeMillis() > deadline) {
                fail("Failed to write to the new leader in time. Addresses seen: " + seenAddresses);
            }
            try (Session session = driver.session(AccessMode.WRITE)) {
                BoltServerAddress boltServerAddress = ((RoutingNetworkSession) session).address();
                session.run("CREATE (p:Person)");
                seenAddresses.add(boltServerAddress);
                success = seenAddresses.size() >= 2;
            } catch (Exception e) {
                Thread.sleep(100);
            }
            /*
                 * Having the latch release here ensures that we've done at least one pass through the loop, which means
                 * we've completed a connection before the forced master switch.
                 */
            if (seenAddresses.size() >= 1) {
                leaderSwitcher.start();
            }
        }
    } finally {
        leaderSwitcher.stop();
        assertTrue(leaderSwitcher.hadLeaderSwitch());
        assertThat(seenAddresses.size(), greaterThanOrEqualTo(2));
    }
}
Also used : CoreClusterMember(org.neo4j.causalclustering.discovery.CoreClusterMember) Config(org.neo4j.driver.v1.Config) Driver(org.neo4j.driver.v1.Driver) TimeoutException(java.util.concurrent.TimeoutException) SessionExpiredException(org.neo4j.driver.v1.exceptions.SessionExpiredException) ServiceUnavailableException(org.neo4j.driver.v1.exceptions.ServiceUnavailableException) IOException(java.io.IOException) ClientException(org.neo4j.driver.v1.exceptions.ClientException) BoltServerAddress(org.neo4j.driver.internal.net.BoltServerAddress) RoutingNetworkSession(org.neo4j.driver.internal.RoutingNetworkSession) JULogging(org.neo4j.driver.internal.logging.JULogging) HashSet(java.util.HashSet) Session(org.neo4j.driver.v1.Session) RoutingNetworkSession(org.neo4j.driver.internal.RoutingNetworkSession) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)9 Driver (org.neo4j.driver.v1.Driver)9 Config (sun.security.krb5.Config)8 Session (org.neo4j.driver.v1.Session)7 StatementResult (org.neo4j.driver.v1.StatementResult)4 IOException (java.io.IOException)3 Config (org.opencypher.Config)3 KrbException (sun.security.krb5.KrbException)3 RemoteException (java.rmi.RemoteException)2 GuardTimeoutException (org.neo4j.kernel.guard.GuardTimeoutException)2 GraphDatabaseAPI (org.neo4j.kernel.internal.GraphDatabaseAPI)2 CommunityNeoServer (org.neo4j.server.CommunityNeoServer)2 ShellException (org.neo4j.shell.ShellException)2 CyNodeLoadingHandler (uk.ac.rothamsted.rdf.neo4j.load.support.CyNodeLoadingHandler)2 CyNodeLoadingProcessor (uk.ac.rothamsted.rdf.neo4j.load.support.CyNodeLoadingProcessor)2 CyRelationLoadingHandler (uk.ac.rothamsted.rdf.neo4j.load.support.CyRelationLoadingHandler)2 CyRelationLoadingProcessor (uk.ac.rothamsted.rdf.neo4j.load.support.CyRelationLoadingProcessor)2 Neo4jDataManager (uk.ac.rothamsted.rdf.neo4j.load.support.Neo4jDataManager)2 RdfDataManager (uk.ac.rothamsted.rdf.neo4j.load.support.RdfDataManager)2 RdfDataManagerTest (uk.ac.rothamsted.rdf.neo4j.load.support.RdfDataManagerTest)2