/** * Constructs a new {@link ImpersonationAuthenticator}. */ public ImpersonationAuthenticator() { mImpersonationGroups = new HashMap<>(); mImpersonationUsers = new HashMap<>(); for (PropertyKey key : Configuration.keySet()) { String value = Configuration.getOrDefault(key, null); // Process impersonation groups Matcher matcher = PropertyKey.Template.MASTER_IMPERSONATION_GROUPS_OPTION.match(key.getName()); if (matcher.matches()) { String connectionUser = matcher.group(1); if (connectionUser != null) { mImpersonationGroups.put(connectionUser, Sets.newHashSet(SPLITTER.split(value))); } } // Process impersonation users matcher = PropertyKey.Template.MASTER_IMPERSONATION_USERS_OPTION.match(key.getName()); if (matcher.matches()) { String connectionUser = matcher.group(1); if (connectionUser != null) { mImpersonationUsers.put(connectionUser, Sets.newHashSet(SPLITTER.split(value))); } } } }
/** * Gets all global configuration properties filtered by the specified scope. * * @param scope the scope to filter by * @return the properties */ public static List<ConfigProperty> getConfiguration(Scope scope) { ConfigurationValueOptions useRawDisplayValue = ConfigurationValueOptions.defaults().useDisplayValue(true).useRawValue(true); return Configuration.keySet().stream() .filter(key -> key.getScope().contains(scope)) .filter(key -> key.isValid(key.getName())) .map(key -> new ConfigProperty() .setName(key.getName()) .setSource(Configuration.getSource(key).toString()).setValue( Configuration.isSet(key) ? Configuration.get(key, useRawDisplayValue) : null)) .collect(toList()); }
@Override public List<ConfigProperty> getConfiguration(GetConfigurationOptions options) { List<ConfigProperty> configInfoList = new ArrayList<>(); for (PropertyKey key : Configuration.keySet()) { if (key.isBuiltIn()) { String source = Configuration.getSource(key).toString(); String value = Configuration.getOrDefault(key, null, ConfigurationValueOptions.defaults().useDisplayValue(true) .useRawValue(options.isRawValue())); configInfoList .add(new ConfigProperty().setName(key.getName()).setValue(value).setSource(source)); } } return configInfoList; }