String databaseSchema = config.get("databaseSchema"); String dataSource = config.get("dataSource"); if (dataSource != null) { if (config.getBoolean("jta", false)) { properties.put(AvailableSettings.JTA_DATASOURCE, dataSource); } else { properties.put(AvailableSettings.JDBC_URL, config.get("url")); properties.put(AvailableSettings.JDBC_DRIVER, config.get("driver")); String user = config.get("user"); if (user != null) { properties.put(AvailableSettings.JDBC_USER, user); String password = config.get("password"); if (password != null) { properties.put(AvailableSettings.JDBC_PASSWORD, password); String driverDialect = config.get("driverDialect"); if (driverDialect != null && driverDialect.length() > 0) { properties.put("hibernate.dialect", driverDialect); String schema = config.get("schema"); if (schema != null) { properties.put(JpaUtils.HIBERNATE_DEFAULT_SCHEMA, schema); properties.put("hibernate.show_sql", config.getBoolean("showSql", false)); properties.put("hibernate.format_sql", config.getBoolean("formatSql", true));
@Override public void init(Config.Scope config) { String[] include = config.getArray("include-events"); if (include != null) { for (String i : include) { includedEvents.add(EventType.valueOf(i.toUpperCase())); } } else { for (EventType i : EventType.values()) { includedEvents.add(i); } } String[] exclude = config.getArray("exclude-events"); if (exclude != null) { for (String e : exclude) { includedEvents.remove(EventType.valueOf(e.toUpperCase())); } } }
String dataSource = config.get("dataSource"); if (dataSource != null) { if (config.getBoolean("jta", jtaEnabled)) { properties.put(AvailableSettings.JPA_JTA_DATASOURCE, dataSource); } else { properties.put(AvailableSettings.JPA_JDBC_URL, config.get("url")); properties.put(AvailableSettings.JPA_JDBC_DRIVER, config.get("driver")); String user = config.get("user"); if (user != null) { properties.put(AvailableSettings.JPA_JDBC_USER, user); String password = config.get("password"); if (password != null) { properties.put(AvailableSettings.JPA_JDBC_PASSWORD, password); boolean initializeEmpty = config.getBoolean("initializeEmpty", true); File databaseUpdateFile = getDatabaseUpdateFile(); properties.put("hibernate.show_sql", config.getBoolean("showSql", false)); properties.put("hibernate.format_sql", config.getBoolean("formatSql", true)); int globalStatsInterval = config.getInt("globalStatsInterval", -1); if (globalStatsInterval != -1) { properties.put("hibernate.generate_statistics", true);
boolean clustered = config.getBoolean("clustered", false); boolean async = config.getBoolean("async", false); boolean allowDuplicateJMXDomains = config.getBoolean("allowDuplicateJMXDomains", true); String jgroupsUdpMcastAddr = config.get("jgroupsUdpMcastAddr", System.getProperty(InfinispanConnectionProvider.JGROUPS_UDP_MCAST_ADDR)); configureTransport(gcb, topologyInfo.getMyNodeName(), topologyInfo.getMySiteName(), jgroupsUdpMcastAddr); gcb.globalJmxStatistics() String sessionsMode = config.get("sessionsMode", "distributed"); if (sessionsMode.equalsIgnoreCase("replicated")) { sessionConfigBuilder.clustering().cacheMode(async ? CacheMode.REPL_ASYNC : CacheMode.REPL_SYNC); int owners = config.getInt("sessionsOwners", 2); logger.debugf("Session owners: %d", owners); int l1Lifespan = config.getInt("l1Lifespan", 600000); boolean l1Enabled = l1Lifespan > 0; sessionConfigBuilder.clustering() .hash() .numOwners(owners) .numSegments(config.getInt("sessionsSegments", 60)) .l1() .enabled(l1Enabled) boolean jdgEnabled = config.getBoolean("remoteStoreEnabled", false);
URI baseUri = new URI(config.get("baseUri", defaultUri));
String saslHostname = sasl.getHostname(); if(saslHostname == null) { saslHostname = config.get("defaultDomain","");
String dbName = config.get("db", "keycloak"); String uriString = config.get("uri"); if (uriString != null) { MongoClientURI uri = new MongoClientURI(uriString); return client; } else { String host = config.get("host", ServerAddress.defaultHost()); int port = config.getInt("port", ServerAddress.defaultPort()); String user = config.get("user"); String password = config.get("password");
synchronized(this) { if (httpClient == null) { long socketTimeout = config.getLong("socket-timeout-millis", -1L); long establishConnectionTimeout = config.getLong("establish-connection-timeout-millis", -1L); int maxPooledPerRoute = config.getInt("max-pooled-per-route", 0); int connectionPoolSize = config.getInt("connection-pool-size", 200); boolean disableCookies = config.getBoolean("disable-cookies", true); String clientKeystore = config.get("client-keystore"); String clientKeystorePassword = config.get("client-keystore-password"); String clientPrivateKeyPassword = config.get("client-key-password");
private void connectHandler(ProtonConnection connection) { String containerId = config.get("containerId", "keycloak-amqp"); connection.setContainer(containerId); connection.openHandler(conn -> {
options.setSsl(true); String path; if((path = config.get("jksKeyStorePath")) != null) { final JksOptions jksOptions = new JksOptions(); jksOptions.setPath(path); jksOptions.setPassword(config.get("keyStorePassword")); options.setKeyStoreOptions(jksOptions); } else if((path = config.get("pfxKeyStorePath")) != null) { final PfxOptions pfxOptions = new PfxOptions(); pfxOptions.setPath(path); pfxOptions.setPassword(config.get("keyStorePassword")); options.setPfxKeyCertOptions(pfxOptions); } else if((path = config.get("pemCertificatePath")) != null) { final PemKeyCertOptions pemKeyCertOptions = new PemKeyCertOptions(); pemKeyCertOptions.setCertPath(path); pemKeyCertOptions.setKeyPath(config.get("pemKeyPath")); options.setPemKeyCertOptions(pemKeyCertOptions); } else {
boolean clustered = config.getBoolean("clustered", false); nodeName = config.get("nodeName", System.getProperty(InfinispanConnectionProvider.JBOSS_NODE_NAME)); if (nodeName != null && nodeName.isEmpty()) { nodeName = null; siteName = config.get("siteName", System.getProperty(InfinispanConnectionProvider.JBOSS_SITE_NAME)); if (siteName != null && siteName.isEmpty()) { siteName = null;
protected String detectDialect(Connection connection) { String driverDialect = config.get("driverDialect"); if (driverDialect != null && driverDialect.length() > 0) { return driverDialect;
protected RemoteCacheManager getOrCreateSecuredRemoteCacheManager(Config.Scope config, String cacheName, RemoteCacheManager origManager) { String serverName = config.get("remoteStoreSecurityServerName", "keycloak-jdg-server"); String realm = config.get("remoteStoreSecurityRealm", "AllowScriptManager"); String username = config.get("remoteStoreSecurityUsername", "___script_manager"); String password = config.get("remoteStoreSecurityPassword", "not-so-secret-password");
@Override public void postInit(final KeycloakSessionFactory factory) { KeycloakModelUtils.runJobInTransaction(factory, new KeycloakSessionTask() { @Override public void run(KeycloakSession session) { compatMode = isCompatMode(session); if (compatMode) { compatProviderFactory = new MemUserSessionProviderFactory(); } } }); // Max count of worker errors. Initialization will end with exception when this number is reached final int maxErrors = config.getInt("maxErrors", 20); // Count of sessions to be computed in each segment final int sessionsPerSegment = config.getInt("sessionsPerSegment", 100); factory.register(new ProviderEventListener() { @Override public void onEvent(ProviderEvent event) { if (event instanceof PostMigrationEvent) { loadPersistentSessions(factory, maxErrors, sessionsPerSegment); } } }); }
@Override public void init(final Config.Scope config) { client = new DefaultOpenShiftClient(); OkHttpClient httpClient = client.adapt(OkHttpClient.class); if(config.getBoolean("enableNonTls", true)) { Integer port = config.getInt("port", 5672); String hostname = config.get("host", "localhost"); try { server = new AmqpServer(hostname, port, config, false, client, httpClient); } catch (RuntimeException e) { LOG.error("Unable to create AMQP Server using non-TLS", e); } } if(config.getBoolean("enableTls", true)) { Integer port = config.getInt("tlsPort", 5671); String hostname = config.get("tlsHost", "0.0.0.0"); try { tlsServer = new AmqpServer(hostname, port, config, true, client, httpClient); } catch (RuntimeException e) { LOG.error("Unable to create AMQP Server using TLS", e); } } }
protected synchronized RemoteCache loadRemoteCache(String cacheName) { RemoteCache remoteCache = InfinispanUtil.getRemoteCache(cacheManager.getCache(cacheName)); Boolean remoteStoreSecurity = config.getBoolean("remoteStoreSecurityEnabled"); if (remoteStoreSecurity == null) { try { logger.debugf("Detecting remote security settings of HotRod server, cache %s. Disable by explicitly setting \"remoteStoreSecurityEnabled\" property in spi=connectionsInfinispan/provider=default", cacheName); remoteStoreSecurity = false; final RemoteCache<Object, Object> scriptCache = remoteCache.getRemoteCacheManager().getCache(SCRIPT_CACHE_NAME); if (scriptCache == null) { logger.debug("Cannot detect remote security settings of HotRod server, disabling."); } else { scriptCache.containsKey(""); } } catch (HotRodClientException ex) { logger.debug("Seems that HotRod server requires authentication, enabling."); remoteStoreSecurity = true; } } if (remoteStoreSecurity) { logger.infof("Remote store security for cache %s is enabled. Disable by setting \"remoteStoreSecurityEnabled\" property to \"false\" in spi=connectionsInfinispan/provider=default", cacheName); RemoteCacheManager securedMgr = getOrCreateSecuredRemoteCacheManager(config, cacheName, remoteCache.getRemoteCacheManager()); return securedMgr.getCache(remoteCache.getName()); } else { logger.infof("Remote store security for cache %s is disabled. If server fails to connect to remote JDG server, enable it.", cacheName); return remoteCache; } }
private void configureRemoteActionTokenCacheStore(ConfigurationBuilder builder, boolean async) { String jdgServer = config.get("remoteStoreHost", "localhost"); Integer jdgPort = config.getInt("remoteStorePort", 11222); builder.persistence() .passivation(false) .addStore(RemoteStoreConfigurationBuilder.class) .fetchPersistentState(false) .ignoreModifications(false) .purgeOnStartup(false) .preload(true) .shared(true) .remoteCacheName(InfinispanConnectionProvider.ACTION_TOKEN_CACHE) .rawValues(true) .forceReturnValues(false) .marshaller(KeycloakHotRodMarshallerFactory.class.getName()) .protocolVersion(getHotrodVersion()) .addServer() .host(jdgServer) .port(jdgPort) .async() .enabled(async); }
private void configureRemoteCacheStore(ConfigurationBuilder builder, boolean async, String cacheName, boolean sessionCache) { String jdgServer = config.get("remoteStoreHost", "localhost"); Integer jdgPort = config.getInt("remoteStorePort", 11222); builder.persistence() .passivation(false) .addStore(RemoteStoreConfigurationBuilder.class) .fetchPersistentState(false) .ignoreModifications(false) .purgeOnStartup(false) .preload(false) .shared(true) .remoteCacheName(cacheName) .rawValues(true) .forceReturnValues(false) .marshaller(KeycloakHotRodMarshallerFactory.class.getName()) .protocolVersion(getHotrodVersion()) .addServer() .host(jdgServer) .port(jdgPort) // .connectionPool() // .maxActive(100) // .exhaustedAction(ExhaustedAction.CREATE_NEW) .async() .enabled(async); }
private void lazyInitBeforeUpdate() { if (state == STATE_BEFORE_INIT) { synchronized (this) { if (state == STATE_BEFORE_INIT) { try { this.client = createMongoClient(); String dbName = config.get("db", "keycloak"); this.db = client.getDB(dbName); state = STATE_BEFORE_UPDATE; } catch (Exception e) { throw new RuntimeException(e); } } } } }
protected void lazyInit() { if (cacheManager == null) { synchronized (this) { if (cacheManager == null) { String cacheContainer = config.get("cacheContainer"); if (cacheContainer != null) { initContainerManaged(cacheContainer); } else { initEmbedded(); } logger.infof(topologyInfo.toString()); remoteCacheProvider = new RemoteCacheProvider(config, cacheManager); } } } }