public static EngineLocalConfig getInstance() { return getInstance(null); }
private static Map<String, String> getParams(HttpServletRequest req) { Map<String, String> params = null; if (EngineLocalConfig.getInstance().getBoolean("ENGINE_SSO_ENABLE_EXTERNAL_SSO")) { params = new HashMap<>(); Enumeration<String> headerNames = req.getHeaderNames(); while (headerNames.hasMoreElements()) { String headerName = headerNames.nextElement(); params.put(headerName, req.getHeader(headerName)); } } return params; }
public SsoPostLoginServlet() { maxUserSessions = EngineLocalConfig.getInstance().getInteger("ENGINE_MAX_USER_SESSIONS"); }
/** * Returns a reference to the singleton, initializing it if needed. */ public static LocalConfig getInstance() { if (instance == null) { synchronized(LocalConfig.class) { if (instance == null) { LocalConfig tmp = new LocalConfig(); tmp.config = EngineLocalConfig.getInstance(); instance = tmp; } } } return instance; }
public static String getEngineSsoUrl(HttpServletRequest request) { if (EngineLocalConfig.getInstance().getBoolean("ENGINE_SSO_INSTALLED_ON_ENGINE_HOST")) { return String.format("%s://%s:%s%s", request.getScheme(), FiltersHelper.getRedirectUriServerName(request.getServerName()), request.getServerPort(), EngineLocalConfig.getInstance().getProperty("ENGINE_SSO_SERVICE_URI")); } return EngineLocalConfig.getInstance().getProperty("ENGINE_SSO_AUTH_URL"); }
public static String getEngineUrl(HttpServletRequest request) { return String.format("%s://%s:%s%s", request.getScheme(), FiltersHelper.getRedirectUriServerName(request.getServerName()), request.getServerPort(), EngineLocalConfig.getInstance().getProperty("ENGINE_URI")); }
private static HttpPost createPost(String path) throws Exception { EngineLocalConfig config = EngineLocalConfig.getInstance(); String base = config.getProperty("ENGINE_SSO_SERVICE_URL"); HttpPost request = new HttpPost(); request.setURI(new URI(base + path)); request.setHeader("Accept", "application/json"); request.setHeader("Content-Language", "en-US"); return request; }
@Override public void init(ServletConfig config) throws ServletException { super.init(config); // we use %{x} convention to avoid conflict with jboss properties targetUrl = injectLocalHost(EngineLocalConfig.getInstance().expandString( config.getInitParameter(TARGET_URL).replaceAll("%\\{", "\\${"))); url404 = url404Default; if (StringUtils.isNotEmpty(config.getInitParameter(URL404))) { url404 = config.getInitParameter(URL404); } url404 = injectLocalHost(EngineLocalConfig.getInstance().expandString(url404.replaceAll("%\\{", "\\${"))); }
private void loadDbFacadeConfig() { final EngineLocalConfig config = EngineLocalConfig.getInstance(); try { connectionTimeout = config.getInteger("ENGINE_DB_CONNECTION_TIMEOUT"); checkInterval = config.getInteger("ENGINE_DB_CHECK_INTERVAL"); } catch (Exception exception) { log.warn("Can't load connection checking parameters of DB facade, " + "will continue using the default values. Error: {}", exception.getMessage()); log.debug("Exception", exception); } } }
private static HttpGet createGet(String path) throws Exception { EngineLocalConfig config = EngineLocalConfig.getInstance(); String base = config.getProperty("ENGINE_SSO_SERVICE_URL"); HttpGet request = new HttpGet(); request.setURI(new URI(base + path)); request.setHeader("Accept", "application/json"); return request; }
private static void setClientIdSecretBasicAuthHeader(HttpUriRequest request) { EngineLocalConfig config = EngineLocalConfig.getInstance(); byte[] encodedBytes = Base64.encodeBase64(String.format("%s:%s", config.getProperty("ENGINE_SSO_CLIENT_ID"), config.getProperty("ENGINE_SSO_CLIENT_SECRET")).getBytes()); request.setHeader(FiltersHelper.Constants.HEADER_AUTHORIZATION, String.format("Basic %s", new String(encodedBytes))); }
/** * Returns UI plugin <em>data path</em>, under which UI plugin descriptor (JSON) files are placed. */ public static String resolvePluginDataPath() { return ConfigUtil.resolvePath(EngineLocalConfig.getInstance().getUsrDir().getAbsolutePath(), UI_PLUGIN_DIR); }
/** * Returns UI plugin <em>config path</em>, under which UI plugin configuration (JSON) files are placed. */ public static String resolvePluginConfigPath() { return ConfigUtil.resolvePath(EngineLocalConfig.getInstance().getEtcDir().getAbsolutePath(), UI_PLUGIN_DIR); }
@Override public String getSysprepPath(int osId, Version version) { return EngineLocalConfig.getInstance().expandString(getValueByVersion(idToUnameLookup.get(osId), "sysprepPath", version)); }
@Override public void init(ServletConfig config) throws ServletException { super.init(config); String applicationName = getServletContext().getInitParameter(APP_NAME); if (applicationName == null) { throw new ServletException("Application name not specified"); //$NON-NLS-1$ } Path symbolMapDirectory = EngineLocalConfig.getInstance().getUsrDir().toPath().resolve("gwt-symbols"); //$NON-NLS-1$ Path symbolMapZipFile = symbolMapDirectory.resolve(applicationName + "/symbolMaps.zip"); //$NON-NLS-1$ try { initDeobfuscator(FileSystems.newFileSystem(symbolMapZipFile, null)); } catch (Exception e) { log.warn("Cannot read GWT symbol maps: " + symbolMapZipFile, e); //$NON-NLS-1$ } }
private static synchronized void initCaCertificate() { if (caCertificate == null) { caCertificate = new Resource( EngineLocalConfig.getInstance().getPKICACert(), Format.X509_PEM_CA, null); } }
private void initServerUrl() throws NotificationServiceException { EngineLocalConfig config = EngineLocalConfig.getInstance(); try { if (isHttpsProtocol) { serverUrl = config.getExternalHttpsUrl(HEALTH_SERVLET_PATH); } else { serverUrl = config.getExternalHttpUrl(HEALTH_SERVLET_PATH); } log.info("Engine health servlet URL is \"{}\".", serverUrl); } catch(MalformedURLException exception) { throw new NotificationServiceException("Can't get engine health servlet URL.", exception); } }
private static synchronized void initEngineCertificate() { if (engineCertificate == null) { engineCertificate = new Resource( EngineLocalConfig.getInstance().getPKIEngineCert(), Format.X509_PEM, Config.getValue(ConfigValues.SSHKeyAlias)); } }
@Override public void beforeAll(ExtensionContext extensionContext) { Map<String, String> newValues = extensionContext .getTestClass() .flatMap(c -> ReflectionUtils.findMethod(c, CONFIG_PROVIDER_METHOD)) .map(m -> { try { return (Stream<Pair<String, String>>) m.invoke(null); } catch (Exception e) { return Stream.empty(); } }) .orElse(Stream.empty()) .map(x -> (Pair<String, String>) x) .collect(Collectors.toMap(Pair::getFirst, Pair::getSecond)); EngineLocalConfig.getInstance(newValues); }
private static CloseableHttpClient createClient() throws IOException, GeneralSecurityException { EngineLocalConfig config = EngineLocalConfig.getInstance(); return new HttpClientBuilder() .setSslProtocol(config.getProperty("ENGINE_SSO_SERVICE_SSL_PROTOCOL")) .setPoolSize(config.getInteger("ENGINE_SSO_SERVICE_CLIENT_POOL_SIZE")) .setReadTimeout(0) .setRetryCount(config.getInteger("ENGINE_SSO_SERVICE_CONNECTION_RETRY_COUNT")) .setTrustManagerAlgorithm(TrustManagerFactory.getDefaultAlgorithm()) .setTrustStore(config.getProperty("ENGINE_HTTPS_PKI_TRUST_STORE")) .setTrustStorePassword(config.getProperty("ENGINE_HTTPS_PKI_TRUST_STORE_PASSWORD")) .setTrustStoreType(config.getProperty("ENGINE_HTTPS_PKI_TRUST_STORE_TYPE")) .setValidateAfterInactivity(config.getInteger("ENGINE_SSO_SERVICE_CONNECTION_VALIDATE_AFTER_INACTIVITY")) .setVerifyChain(config.getBoolean("ENGINE_SSO_SERVICE_SSL_VERIFY_CHAIN")) .setVerifyHost(config.getBoolean("ENGINE_SSO_SERVICE_SSL_VERIFY_HOST")) .build(); }