@Activate private void activate(ComponentContext componentContext) { Dictionary config = componentContext.getProperties(); requestThreadLocal = PropertiesUtil.toBoolean( config.get(PARAM_REQUEST_THREAD_LOCAL), PARAM_REQUEST_THREAD_LOCAL_DEFAULT); }
@SuppressWarnings("rawtypes") protected void activate(ComponentContext context) { Dictionary props = context.getProperties(); usingSession = PropertiesUtil.toBoolean(props.get(USE_SESSION), false); secureCookie = PropertiesUtil.toBoolean(props.get(SECURE_COOKIE), false); ttl = PropertiesUtil.toLong(props.get(TTL), 1200000); trustedAuthCookieName = PropertiesUtil.toString(props.get(COOKIE_NAME), ""); sharedSecret = PropertiesUtil.toString( props.get(SERVER_TOKEN_SHARED_SECRET), "default-setting-change-before-use"); trustedTokenEnabled = PropertiesUtil.toBoolean(props.get(SERVER_TOKEN_ENABLED), true); debugCookies = PropertiesUtil.toBoolean(props.get(DEBUG_COOKIES), false); tokenStore.setDebugCookies(debugCookies); String safeHostsAddr = PropertiesUtil.toString(props.get(SERVER_TOKEN_SAFE_HOSTS_ADDR), ""); safeHostAddrSet.clear(); if (safeHostsAddr != null) { for (String address : StringUtils.split(safeHostsAddr, ';')) { safeHostAddrSet.add(address); } } String trustedProxyServerAddr = PropertiesUtil.toString(props.get(TRUSTED_PROXY_SERVER_ADDR), ""); trustedProxyServerAddrSet.clear(); if (trustedProxyServerAddr != null) { for (String address : StringUtils.split(trustedProxyServerAddr, ';')) { trustedProxyServerAddrSet.add(address); } } String wrappers = PropertiesUtil.toString(props.get(SERVER_TOKEN_SAFE_WRAPPERS), ""); if (wrappers == null || wrappers.length() == 0) { wrappers = DEFAULT_WRAPPERS; } safeWrappers = StringUtils.split(wrappers, ";"); String tokenFile = PropertiesUtil.toString(props.get(TOKEN_FILE_NAME), ""); String serverId = clusterTrackingService.getCurrentServerId(); tokenStore.doInit(cacheManager, tokenFile, serverId, ttl); trustedHeaderName = PropertiesUtil.toString(props.get(TRUSTED_HEADER_NAME), ""); trustedParameterName = PropertiesUtil.toString(props.get(TRUSTED_PARAMETER_NAME), ""); }
/** * Get the value of an OSGi configuration boolean property for a given PID. * * @param pid The PID of the OSGi component to retrieve * @param property The property of the config to retrieve * @param value The value to assign the provided property * @return The property value */ public boolean getBooleanProperty( final String pid, final String property, final boolean defaultValue) { try { Configuration conf = configAdmin.getConfiguration(pid); @SuppressWarnings("unchecked") Dictionary<String, Object> props = conf.getProperties(); if (props != null) { return PropertiesUtil.toBoolean(props.get(property), defaultValue); } } catch (IOException e) { LOGGER.error("Could not get property", e); } return defaultValue; }