UserBulkUpdateProvider interface

This commit is contained in:
Bill Burke 2016-11-29 18:43:22 -05:00
parent a677ab64e3
commit 9e50a45b4c
10 changed files with 40 additions and 35 deletions

View file

@ -155,11 +155,6 @@ public class EjbExampleUserStorageProvider implements UserStorageProvider,
return true;
}
@Override
public void grantToAllUsers(RealmModel realm, RoleModel role) {
}
@Override
public void onCache(RealmModel realm, CachedUserModel user, UserModel delegate) {
String password = ((UserAdapter)delegate).getPassword();

View file

@ -93,11 +93,6 @@ public class FilePropertiesStorageProvider extends BasePropertiesStorageProvider
return createAdapter(realm, username);
}
@Override
public void grantToAllUsers(RealmModel realm, RoleModel role) {
// unsupported
}
@Override
public boolean updateCredential(RealmModel realm, UserModel user, CredentialInput input) {
if (!(input instanceof UserCredentialModel)) return false;

View file

@ -168,11 +168,6 @@ public class LDAPStorageProvider implements UserStorageProvider,
return Collections.EMPTY_LIST;
}
@Override
public void grantToAllUsers(RealmModel realm, RoleModel role) {
}
public boolean synchronizeRegistrations() {
return "true".equalsIgnoreCase(model.getConfig().getFirst(LDAPConstants.SYNC_REGISTRATIONS)) && editMode == UserStorageProvider.EditMode.WRITABLE;
}

View file

@ -19,6 +19,7 @@ package org.keycloak.models;
import org.keycloak.component.ComponentModel;
import org.keycloak.provider.Provider;
import org.keycloak.storage.user.UserBulkUpdateProvider;
import org.keycloak.storage.user.UserLookupProvider;
import org.keycloak.storage.user.UserQueryProvider;
import org.keycloak.storage.user.UserRegistrationProvider;
@ -33,7 +34,8 @@ import java.util.Set;
public interface UserProvider extends Provider,
UserLookupProvider,
UserQueryProvider,
UserRegistrationProvider {
UserRegistrationProvider,
UserBulkUpdateProvider {
// Note: The reason there are so many query methods here is for layering a cache on top of an persistent KeycloakSession
public void addFederatedIdentity(RealmModel realm, UserModel user, FederatedIdentityModel socialLink);

View file

@ -33,21 +33,22 @@ public interface UserStorageProvider extends Provider {
void preRemove(RealmModel realm, RoleModel role);
/**
* Optional type that can be by implementations to describe edit mode of federation storage
* Optional type that can be used by implementations to
* describe edit mode of user storage
*
*/
enum EditMode {
/**
* federation storage is read-only
* user storage is read-only
*/
READ_ONLY,
/**
* federation storage is writable
* user storage is writable
*
*/
WRITABLE,
/**
* updates to user are stored locally and not synced with federation storage.
* updates to user are stored locally and not synced with user storage.
*
*/
UNSYNCED

View file

@ -0,0 +1,28 @@
/*
* Copyright 2016 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.keycloak.storage.user;
import org.keycloak.models.RealmModel;
import org.keycloak.models.RoleModel;
/**
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
* @version $Revision: 1 $
*/
public interface UserBulkUpdateProvider {
void grantToAllUsers(RealmModel realm, RoleModel role);
}

View file

@ -30,6 +30,5 @@ public interface UserRegistrationProvider {
boolean removeUser(RealmModel realm, UserModel user);
void grantToAllUsers(RealmModel realm, RoleModel role);
}

View file

@ -37,6 +37,7 @@ import org.keycloak.models.cache.CachedUserModel;
import org.keycloak.models.cache.OnUserCache;
import org.keycloak.storage.federated.UserFederatedStorageProvider;
import org.keycloak.storage.user.ImportedUserValidation;
import org.keycloak.storage.user.UserBulkUpdateProvider;
import org.keycloak.storage.user.UserLookupProvider;
import org.keycloak.storage.user.UserQueryProvider;
import org.keycloak.storage.user.UserRegistrationProvider;
@ -521,12 +522,11 @@ public class UserStorageManager implements UserProvider, OnUserCache {
@Override
public void grantToAllUsers(RealmModel realm, RoleModel role) {
// not federation-aware for now
List<UserRegistrationProvider> storageProviders = getStorageProviders(session, realm, UserRegistrationProvider.class);
LinkedList<UserRegistrationProvider> providers = new LinkedList<>();
List<UserBulkUpdateProvider> storageProviders = getStorageProviders(session, realm, UserBulkUpdateProvider.class);
LinkedList<UserBulkUpdateProvider> providers = new LinkedList<>();
providers.add(localStorage());
providers.addAll(storageProviders);
for (UserRegistrationProvider provider : providers) {
for (UserBulkUpdateProvider provider : providers) {
provider.grantToAllUsers(realm, role);
}
}

View file

@ -88,11 +88,6 @@ public class DummyUserFederationProvider implements UserStorageProvider,
}
@Override
public void grantToAllUsers(RealmModel realm, RoleModel role) {
}
@Override
public void preRemove(RealmModel realm) {
}

View file

@ -149,11 +149,6 @@ public class UserMapStorage implements UserLookupProvider, UserStorageProvider,
return userPasswords.remove(user.getUsername()) != null;
}
@Override
public void grantToAllUsers(RealmModel realm, RoleModel role) {
}
@Override
public void preRemove(RealmModel realm) {