Search in sources :

Example 1 with ImportedUserValidation

use of org.keycloak.storage.user.ImportedUserValidation in project keycloak by keycloak.

the class UserStorageManager method importValidation.

/**
 * Allows a UserStorageProvider to proxy and/or synchronize an imported user.
 *
 * @param realm
 * @param user
 * @return
 */
protected UserModel importValidation(RealmModel realm, UserModel user) {
    if (user == null || user.getFederationLink() == null)
        return user;
    UserStorageProviderModel model = getStorageProviderModel(realm, user.getFederationLink());
    if (model == null) {
        // remove linked user with unknown storage provider.
        logger.debugf("Removed user with federation link of unknown storage provider '%s'", user.getUsername());
        deleteInvalidUser(realm, user);
        return null;
    }
    if (!model.isEnabled()) {
        return new ReadOnlyUserModelDelegate(user) {

            @Override
            public boolean isEnabled() {
                return false;
            }
        };
    }
    ImportedUserValidation importedUserValidation = getStorageProviderInstance(model, ImportedUserValidation.class, true);
    if (importedUserValidation == null)
        return user;
    UserModel validated = importedUserValidation.validate(realm, user);
    if (validated == null) {
        deleteInvalidUser(realm, user);
        return null;
    } else {
        return validated;
    }
}
Also used : ReadOnlyUserModelDelegate(org.keycloak.models.utils.ReadOnlyUserModelDelegate) UserModel(org.keycloak.models.UserModel) CachedUserModel(org.keycloak.models.cache.CachedUserModel) ImportedUserValidation(org.keycloak.storage.user.ImportedUserValidation)

Aggregations

UserModel (org.keycloak.models.UserModel)1 CachedUserModel (org.keycloak.models.cache.CachedUserModel)1 ReadOnlyUserModelDelegate (org.keycloak.models.utils.ReadOnlyUserModelDelegate)1 ImportedUserValidation (org.keycloak.storage.user.ImportedUserValidation)1