Class DefaultSyncHandler

  • All Implemented Interfaces:
    SyncHandler

    @Service
    public class DefaultSyncHandler
    extends Object
    implements SyncHandler
    DefaultSyncHandler implements an sync handler that synchronizes users and groups from an external identity provider with the repository users.

    Please refer to DefaultSyncConfigImpl for configuration options.

    • Constructor Detail

      • DefaultSyncHandler

        public DefaultSyncHandler()
        Default constructor for OSGi
      • DefaultSyncHandler

        public DefaultSyncHandler​(DefaultSyncConfig config)
        Constructor for non-OSGi cases.
        Parameters:
        config - the configuration
    • Method Detail

      • getName

        @NotNull
        public @NotNull String getName()
        Returns the name of this sync handler.
        Specified by:
        getName in interface SyncHandler
        Returns:
        sync handler name
      • createContext

        @NotNull
        public @NotNull SyncContext createContext​(@NotNull
                                                  @NotNull ExternalIdentityProvider idp,
                                                  @NotNull
                                                  @NotNull org.apache.jackrabbit.api.security.user.UserManager userManager,
                                                  @NotNull
                                                  @NotNull javax.jcr.ValueFactory valueFactory)
        Initializes a sync context which is used to start the sync operations.
        Specified by:
        createContext in interface SyncHandler
        Parameters:
        idp - the external identity provider used for syncing
        userManager - user manager for managing authorizables
        valueFactory - the value factory to create values
        Returns:
        the sync context
      • findIdentity

        public SyncedIdentity findIdentity​(@NotNull
                                           @NotNull org.apache.jackrabbit.api.security.user.UserManager userManager,
                                           @NotNull
                                           @NotNull String id)
                                    throws javax.jcr.RepositoryException
        Tries to find the identity with the given authorizable id or name.
        Specified by:
        findIdentity in interface SyncHandler
        Parameters:
        userManager - the user manager
        id - the id or name of the authorizable
        Returns:
        a synced identity object or null
        Throws:
        javax.jcr.RepositoryException - if an error occurs
      • requiresSync

        public boolean requiresSync​(@NotNull
                                    @NotNull SyncedIdentity identity)
        Checks if the identity requires sync based on the configuration, type and last sync time.
        Specified by:
        requiresSync in interface SyncHandler
        Parameters:
        identity - the identity to check
        Returns:
        true if the identity requires synchronization.
      • listIdentities

        @NotNull
        public @NotNull Iterator<SyncedIdentity> listIdentities​(@NotNull
                                                                @NotNull org.apache.jackrabbit.api.security.user.UserManager userManager)
                                                         throws javax.jcr.RepositoryException
        Lists all externally synced identities.
        Specified by:
        listIdentities in interface SyncHandler
        Parameters:
        userManager - the user manager
        Returns:
        an iterator over all authorizable that are externally synced.
        Throws:
        javax.jcr.RepositoryException - if an error occurs