@Override public void init(Config.Scope config) { String eventsDirectoryConfigVal = config.get("eventsDirectory"); if (eventsDirectoryConfigVal != null && !eventsDirectoryConfigVal.isEmpty()) { logger.debug("Using events directory from configuration file: " + eventsDirectoryConfigVal); this.eventsDirectory = eventsDirectoryConfigVal; } else { String eventsDirectoryEnvVal = System.getenv(EVENTS_DIRECTORY_ENV); logger.debug("Using events directory from " + EVENTS_DIRECTORY_ENV + " environment variable: " + eventsDirectoryEnvVal); this.eventsDirectory = eventsDirectoryEnvVal; } }
private Connection getConnection() { try { String dataSourceLookup = config.get("dataSource"); if (dataSourceLookup != null) { DataSource dataSource = (DataSource) new InitialContext().lookup(dataSourceLookup); return dataSource.getConnection(); } else { Class.forName(config.get("driver")); return DriverManager.getConnection(config.get("url"), config.get("user"), config.get("password")); } } catch (Exception e) { throw new RuntimeException("Failed to connect to database", e); } }
@Override public Connection getConnection() { try { String dataSourceLookup = config.get("dataSource"); if (dataSourceLookup != null) { DataSource dataSource = (DataSource) new InitialContext().lookup(dataSourceLookup); return dataSource.getConnection(); } else { Class.forName(config.get("driver")); return DriverManager.getConnection(config.get("url"), config.get("user"), config.get("password")); } } catch (Exception e) { throw new RuntimeException("Failed to connect to database", e); } }
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 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); } } }
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); }
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); } } } }
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); } } } } }
@Override public String getSchema() { return config.get("schema"); }
private File getDatabaseUpdateFile() { String databaseUpdateFile = config.get("migrationExport", "keycloak-database-update.sql"); return new File(databaseUpdateFile); }
FilesystemHealthIndicator(Config.Scope config) { super("filesystem"); this.path = config.get("path", DEFAULT_PATH); this.thresholdInBytes = config.getLong("thresholdInBytes", DEFAULT_THRESHOLD_IN_BYTES); }
@Override public void init(Config.Scope config) { String d = config.get("dir"); File rootDir = null; if (d != null) { rootDir = new File(d); } themeProvider = new FolderThemeProvider(rootDir); }
public static String getAdminRealm() { return configProvider.scope("admin").get("realm", "master"); }
public ExtendingThemeManager(KeycloakSession session, ConcurrentHashMap<ExtendingThemeManagerFactory.ThemeKey, Theme> themeCache) { this.session = session; this.themeCache = themeCache; this.defaultTheme = Config.scope("theme").get("default", "keycloak"); }
private MigrationStrategy getMigrationStrategy() { String migrationStrategy = config.get("migrationStrategy"); if (migrationStrategy == null) { // Support 'databaseSchema' for backwards compatibility migrationStrategy = config.get("databaseSchema"); } if (migrationStrategy != null) { return MigrationStrategy.valueOf(migrationStrategy.toUpperCase()); } else { return MigrationStrategy.UPDATE; } }
private ProtocolVersion getHotrodVersion() { String hotrodVersionStr = config.get("hotrodProtocolVersion", ProtocolVersion.DEFAULT_PROTOCOL_VERSION.toString()); ProtocolVersion hotrodVersion = ProtocolVersion.parseVersion(hotrodVersionStr); if (hotrodVersion == null) { hotrodVersion = ProtocolVersion.DEFAULT_PROTOCOL_VERSION; } logger.debugf("HotRod protocol version: %s", hotrodVersion); return hotrodVersion; }
private MigrationStrategy getMigrationStrategy() { String migrationStrategy = config.get("migrationStrategy"); if (migrationStrategy == null) { // Support 'databaseSchema' for backwards compatibility migrationStrategy = config.get("databaseSchema"); } if (migrationStrategy != null) { return MigrationStrategy.valueOf(migrationStrategy.toUpperCase()); } else { return MigrationStrategy.UPDATE; } }