@PostConstruct public void readConfiguration(){ final Config authConfig = this.config.getConfig( "server.auth.endpoints" ); loginTemplate = authConfig.getString( "login-template", "login.html" ); loginPage = authConfig.getString( "login-page" ); errorPage = authConfig.getString( "error-page" ); successPage = authConfig.getString( "success-page" ); callbackUrl = authConfig.getString( "callback-url" ); callbackUrlMethod = config.getString( "callback-url-http-method", "POST" ); logoutUrl = authConfig.getString( "logout-url" ); logoutUrlMethod = authConfig.getString( "logout-url-http-method", "POST" ); permissionDeniedPage = authConfig.getString( "permission-denied-page" ); }
@PostConstruct @SuppressWarnings("unchecked") public void loadConfig(){ metricConfiguration = new MetricConfiguration( (Class<? extends ReporterConfiguration>) config.getClass( REPORTER_CONFIGURATION_CLASS ), (Class<? extends MetricRegistryListener>) config.getClass( REPORTER_LISTENER_CLASS ), (Class<? extends MetricFilter>) config.getClass( REPORTER_FILTER_CLASS ), (Class<? extends MetricStore>) config.getClass( REPORTER_STORE_CLASS ), config.getBoolean( SHOULD_STORE_INDIVIDUAL_WEB_METRICS ), config.getBoolean( SHOULD_STORE_SUMMARIZED_WEB_METRICS ), config.getBoolean( IS_MODULE_ENABLED ), config.getLong( REPORTER_INTERVAL ), cdi ); }
@PostConstruct public void configureEndpointContext(){ isRestEnabled = config.getBoolean( "server.uworkers.rest-api.enabled" ); restApiPrefix = config.getString( "server.uworkers.rest-api.base-endpoint" ); maxTaskPoolSize = config.getInteger( "server.uworkers.rest-api.max-task-pool-size" ); defaultEndpointConfig = createEndpointConfig( "default" ); }
void loadJvmMetrics(){ final Config config = this.config.getConfig(JVM_METRICS); for (String key : config.getKeys()) { if ( config.getBoolean( key ) ) { jvmMetrics.get(key).accept(key); } } }
String configuredRole() { return config.getString( "server.auth.fixed-auth.role" ); } }
@Override public void load(Undertow.Builder server, DeploymentContext context) { Config httpConfig = config.getConfig("server.http"); if ( httpConfig.getBoolean("enabled") ) loadHttpListener( httpConfig, server ); }
private AuthenticationRule convertConfToRule( final Config ruleConf ) { final List<String> defaultIdentityManagersAndAuthMechanisms = Collections.singletonList("default"); final List<String> defaultExcludedPatterns = authConfig.getStringList("default-excluded-patterns"); final List<IdentityManager> identityManagers = getIdentityManagerFor( ruleConf, defaultIdentityManagersAndAuthMechanisms ); final List<AuthenticationMechanism> mechanisms = extractNeededMechanisms( ruleConf.getStringList("auth-mechanisms", defaultIdentityManagersAndAuthMechanisms) ); final List<String> excludedPatterns = ruleConf.getStringList("exclude-patterns", new ArrayList<>()); final boolean authenticationRequired = ruleConf.getBoolean( "authentication-required", true ); excludedPatterns.addAll( defaultExcludedPatterns ); return new AuthenticationRule( ruleConf.getString( "pattern" ), identityManagers, mechanisms, ruleConf.getStringList( "expected-roles", Collections.emptyList() ), excludedPatterns, authenticationRequired ); }
/** * Create a SSLContext. * * @return * @throws IOException */ public SSLContext createSSLContext() throws IOException { if ( !httpsConfig.getBoolean("enabled") ) return null; return createSSLContext( httpsConfig.getString("keystore"), httpsConfig.getString("truststore"), httpsConfig.getString("password") ); }
private void setSocketOptions(final Builder builder) { Config socketOptions = undertowConfig.getConfig( "server.undertow.socket-options" ); for ( String key : socketOptions.getKeys() ) { ConfigurableOption option = getConfigOption( key, socketOptions.getObject(key) ); if ( option != null ) { log.info( " " + option.getOption() + ": " + option.getValue() ); builder.setSocketOption(option.getOption(), option.getValue()); } } } }
void loadHttpListener( Config httpConfig, Undertow.Builder server ){ final int port = httpConfig.getInteger("port"); final String host = httpConfig.getString("host"); log.info( "Listening for HTTP requests at " + host + ":" + port ); server.addHttpListener(port, host); } }
boolean getBoolean(String path, boolean defaultValue);
Class<?> getClass( String path, Class<?> defaultClass );
Config readDataSources(){ Config config = kikahaConf.getConfig("server.datasources"); if ( config == null ) config = kikahaConf.getConfig("server.db.datasources"); else { log.warn( "Found deprecated 'server.datasources' configuration." ); log.warn( "Consider use 'server.db.datasources' instead." ); } return config; }
public int getParallelism(){ return config.getInteger( "parallelism" ); } }
@Override public DataSource newDataSource(String name, Config config) { try { log.debug( "Creating new Datasource: " + name + ". " + config ); final String className = config.getString("driver-class-name"); final Class<?> aClass = Class.forName(className); final Driver driver = (Driver)aClass.newInstance(); final String jdbcUrl = config.getString("jdbc-url"); final Properties properties = new Properties(); properties.putAll( config.toMap() ); properties.put( "user", config.getString("username") ); return new SimpleDataSource( driver, jdbcUrl, properties ); } catch (Throwable e) { throw new IllegalStateException(e); } } }
private Map<String, DataSource> startAndCacheConfiguredDataSources() { final Map<String, DataSource> cachedDatasources = new HashMap<>(); final Config dataSources = readDataSources(); for ( String confKey : dataSources.getKeys() ) { final Config config = dataSources.getConfig(confKey); final DataSource dataSource = defaultDataSourceFactory.newDataSource(confKey, config); cachedDatasources.put( confKey, dataSource ); } return cachedDatasources; }
@Override public void load( final Builder server, final DeploymentContext context ) throws IOException { final List<Config> configList = config.getConfigList( "server.smart-routes.static-headers" ); if ( configList != null ) for ( final Config staticHeaderConfig : configList ) { final String url = staticHeaderConfig.getString( "url" ); final Map<String, Object> headers = readHeadersFrom( staticHeaderConfig ); final HttpHandler httpHandler = context.rootHandler(); final HttpHandler staticHandler = StaticHeadersHttpHandler.create( httpHandler, url, headers ); context.rootHandler( staticHandler ); } }
CORSConfig loadCorsConfig(){ final List<String> allowedOrigins = config.getStringList("server.smart-routes.cors.allowed-origins"); return new CORSConfig( config.getBoolean("server.smart-routes.cors.always-allow-origin"), config.getBoolean("server.smart-routes.cors.always-allow-credentials"), asSet(config.getStringList("server.smart-routes.cors.allowed-methods")), asSet( allowedOrigins ), asMatcherSet( allowedOrigins )); }
@PostConstruct public void loadConfig(){ List<Config> configs = config.getConfigList("server.smart-routes.rewrite"); rewriteRoutes = configs.stream().map( c-> SmartRouteRule.from(c) ).collect(Collectors.toList()); configs = config.getConfigList("server.smart-routes.reverse"); reverseRoutes = configs.stream().map( c-> SmartRouteRule.from(c) ).collect(Collectors.toList()); isHttp2EnabledForProxy = config.getBoolean( "server.smart-routes.reverse-with-http2", true ); }