org.keycloak.storage.user

## Interface UserRegistrationProvider

- All Known Subinterfaces:
    UserCache, UserCache.Streams, UserProvider, UserProvider.Streams
  All Known Implementing Classes:
    JpaUserProvider, LDAPStorageProvider, MapUserProvider, UserCacheSession, UserStorageManager

      public interface UserRegistrationProvider

  This is an optional capability interface that is intended to be implemented by any `UserStorageProvider` that supports addition of new users. You must implement this interface if you want to use this storage for registering new users.
  Version:
    $Revision: 1 $
  Author:
    Bill Burke

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `UserModel` | `addUser(RealmModel realm, String username)` All storage providers that implement this interface will be looped through.
    `boolean` | `removeUser(RealmModel realm, UserModel user)` Called if user originated from this provider.

- - ### Method Detail

    - #### addUser

          UserModel addUser(RealmModel realm,
                            String username)

      All storage providers that implement this interface will be looped through. If this method returns null, then the next storage provider's addUser() method will be called. If no storage providers handle the add, then the user will be created in local storage. Returning null is useful when you want optional support for adding users. For example, our LDAP provider can enable and disable the ability to add users.
      Parameters:
        `realm` - a reference to the realm
        `username` - a username the created user will be assigned
      Returns:
        a model of created user

    - #### removeUser

          boolean removeUser(RealmModel realm,
                             UserModel user)

      Called if user originated from this provider. If a local user is linked to this provider, this method will be called before local storage's removeUser() method is invoked. If you are using an import strategy, and this is a local user linked to this provider, this method will be called before local storage's removeUser() method is invoked. Also, you DO NOT need to remove the imported user. The runtime will handle this for you.
      Parameters:
        `realm` - a reference to the realm
        `user` - a reference to the user that is removed
      Returns:
        true if the user was removed, false otherwise

Copyright © 2021 JBoss by Red Hat. All rights reserved.