public ReloadableProperties load(String nameProperty, String fallbackName, Map options) { ReloadableProperties result; FileNameKey key = new FileNameKey(nameProperty, fallbackName, options); key.setDebug(debug); synchronized (staticCache) { result = staticCache.get(key); if (result == null) { result = new ReloadableProperties(key); staticCache.put(key, result); } } return result.obtained(); }
public synchronized Map<String, String> invertedPropertiesMap() { if (invertedProps == null) { invertedProps = new HashMap<>(props.size()); for (Map.Entry<Object, Object> val : props.entrySet()) { String str = (String) val.getValue(); if (!looksLikeRegexp(str)) { invertedProps.put(str, (String) val.getKey()); } } } return invertedProps; }
/** * Performs initialization of file paths. A standard JAAS override. */ @Override public void initialize(Subject subject, CallbackHandler callbackHandler, Map<String, ?> sharedState, Map<String, ?> options) { super.initialize(subject, callbackHandler, sharedState, options); usersByDn = load(USER_FILE_PROP_NAME, "", options).invertedPropertiesMap(); regexpByUser = load(USER_FILE_PROP_NAME, "", options).regexpPropertiesMap(); rolesByUser = load(ROLE_FILE_PROP_NAME, "", options).invertedPropertiesValuesMap(); }
@Override public void initialize(Subject subject, CallbackHandler callbackHandler, Map<String, ?> sharedState, Map<String, ?> options) { this.subject = subject; this.callbackHandler = callbackHandler; loginSucceeded = false; init(options); users = load(USER_FILE_PROP_NAME, "user", options).getProps(); roles = load(ROLE_FILE_PROP_NAME, "role", options).invertedPropertiesValuesMap(); }
public synchronized ReloadableProperties obtained() { if (reloadTime < 0 || (key.isReload() && hasModificationAfter(reloadTime))) { props = new Properties(); try { load(key.file(), props); invertedProps = null; invertedValueProps = null; regexpProps = null; if (key.isDebug()) { logger.debug("Load of: " + key); } } catch (IOException e) { ActiveMQServerLogger.LOGGER.failedToLoadProperty(e, key.toString(), e.getLocalizedMessage()); if (key.isDebug()) { logger.debug("Load of: " + key + ", failure exception" + e); } } reloadTime = System.currentTimeMillis(); } return this; }
public synchronized Map<String, Pattern> regexpPropertiesMap() { if (regexpProps == null) { regexpProps = new HashMap<>(props.size()); for (Map.Entry<Object, Object> val : props.entrySet()) { String str = (String) val.getValue(); if (looksLikeRegexp(str)) { try { Pattern p = Pattern.compile(str.substring(1, str.length() - 1)); regexpProps.put((String) val.getKey(), p); } catch (PatternSyntaxException e) { ActiveMQServerLogger.LOGGER.warn("Ignoring invalid regexp: " + str); } } } } return regexpProps; }