String providerName = elements[0];
Set<String> users = providerUsers.get(providerName);
if (users == null)
{
AuthenticationProvider provider = findAuthenticationProviderByName(providerName, authenticationProviders);
if (provider == null)
{
throw new IllegalArgumentException("Cannot find provider with name '" + providerName + "'");
}
users = new HashSet<String>();
providerUsers.put(providerName, users);
requestProviders.put(providerName, provider);
}
users.add(userId);
}
if (!providerUsers.isEmpty())
{
for (Map.Entry<String, Set<String>> entry : providerUsers.entrySet())
{
String providerName = entry.getKey();
AuthenticationProvider provider = requestProviders.get(providerName);
Set<String> usersToDelete = entry.getValue();
PreferencesProvider preferencesProvider = provider.getPreferencesProvider();
if (preferencesProvider != null && !usersToDelete.isEmpty())
{
String[] users = usersToDelete.toArray(new String[usersToDelete.size()]);
preferencesProvider.deletePreferences(users);