@Override protected void doActivate(ComponentContext context) throws Exception { Dictionary<?, ?> properties = context.getProperties(); maxage = PropertiesUtil.toLong(properties.get(PROP_MAX_AGE), -1); if (maxage < 0) { throw new ConfigurationException( PROP_MAX_AGE, "Max Age must be specified and greater than 0."); } }
@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 long 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 Long getLongProperty(final String pid, final String property, final Long defaultValue) { long placeholder = -1L; long defaultTemp = defaultValue != null ? defaultValue : placeholder; try { Configuration conf = configAdmin.getConfiguration(pid); @SuppressWarnings("unchecked") Dictionary<String, Object> props = conf.getProperties(); if (props != null) { long result = PropertiesUtil.toLong(props.get(property), defaultTemp); return result == placeholder ? null : result; } } catch (IOException e) { LOGGER.error("Could not get property", e); } return defaultValue; }