Class MockUserManager

  • All Implemented Interfaces:
    org.apache.jackrabbit.api.security.user.UserManager

    public class MockUserManager
    extends Object
    implements org.apache.jackrabbit.api.security.user.UserManager
    Mock UserManager implementation.
    • Field Detail

      • session

        protected javax.jcr.Session session
      • authorizables

        protected Map<String,​org.apache.jackrabbit.api.security.user.Authorizable> authorizables
    • Constructor Detail

      • MockUserManager

        public MockUserManager​(javax.jcr.Session session)
        Parameters:
        session - the jcr session where the people state is stored
    • Method Detail

      • isAutoSave

        public boolean isAutoSave()
        Specified by:
        isAutoSave in interface org.apache.jackrabbit.api.security.user.UserManager
      • autoSave

        public void autoSave​(boolean autoSave)
                      throws javax.jcr.RepositoryException
        Specified by:
        autoSave in interface org.apache.jackrabbit.api.security.user.UserManager
        Throws:
        javax.jcr.RepositoryException
      • createGroup

        @NotNull
        public @NotNull org.apache.jackrabbit.api.security.user.Group createGroup​(@NotNull
                                                                                  @NotNull String groupID)
                                                                           throws javax.jcr.RepositoryException
        Specified by:
        createGroup in interface org.apache.jackrabbit.api.security.user.UserManager
        Throws:
        javax.jcr.RepositoryException
      • createGroup

        @NotNull
        public @NotNull org.apache.jackrabbit.api.security.user.Group createGroup​(@NotNull
                                                                                  @NotNull Principal principal)
                                                                           throws javax.jcr.RepositoryException
        Specified by:
        createGroup in interface org.apache.jackrabbit.api.security.user.UserManager
        Throws:
        javax.jcr.RepositoryException
      • createGroup

        @NotNull
        public @NotNull org.apache.jackrabbit.api.security.user.Group createGroup​(@NotNull
                                                                                  @NotNull Principal principal,
                                                                                  @Nullable
                                                                                  @Nullable String intermediatePath)
                                                                           throws javax.jcr.RepositoryException
        Specified by:
        createGroup in interface org.apache.jackrabbit.api.security.user.UserManager
        Throws:
        javax.jcr.RepositoryException
      • createGroup

        @NotNull
        public @NotNull org.apache.jackrabbit.api.security.user.Group createGroup​(@NotNull
                                                                                  @NotNull String groupID,
                                                                                  @NotNull
                                                                                  @NotNull Principal principal,
                                                                                  @Nullable
                                                                                  @Nullable String intermediatePath)
                                                                           throws javax.jcr.RepositoryException
        Specified by:
        createGroup in interface org.apache.jackrabbit.api.security.user.UserManager
        Throws:
        javax.jcr.RepositoryException
      • toPrincipalName

        @Nullable
        protected @Nullable String toPrincipalName​(@Nullable
                                                   @Nullable String id,
                                                   @Nullable
                                                   @Nullable Principal principal)
        Calculates the principal name, preferring the supplied id or fallback to the Principal.getName() value
        Parameters:
        id - the user or group id
        principal - the principal
        Returns:
        the principal name
      • ensureAuthorizablePathExists

        protected javax.jcr.Node ensureAuthorizablePathExists​(String intermediatePath,
                                                              String principalName,
                                                              boolean isGroup)
                                                       throws javax.jcr.RepositoryException
        Creates the user/group home folder if they don't exist yet
        Parameters:
        intermediatePath - the parent path
        Throws:
        javax.jcr.RepositoryException
      • createSystemUser

        @NotNull
        public @NotNull org.apache.jackrabbit.api.security.user.User createSystemUser​(@NotNull
                                                                                      @NotNull String userID,
                                                                                      @Nullable
                                                                                      @Nullable String intermediatePath)
                                                                               throws javax.jcr.RepositoryException
        Specified by:
        createSystemUser in interface org.apache.jackrabbit.api.security.user.UserManager
        Throws:
        javax.jcr.RepositoryException
      • createUser

        @NotNull
        public @NotNull org.apache.jackrabbit.api.security.user.User createUser​(@NotNull
                                                                                @NotNull String userID,
                                                                                @Nullable
                                                                                @Nullable String password)
                                                                         throws javax.jcr.RepositoryException
        Specified by:
        createUser in interface org.apache.jackrabbit.api.security.user.UserManager
        Throws:
        javax.jcr.RepositoryException
      • createUser

        @NotNull
        public @NotNull org.apache.jackrabbit.api.security.user.User createUser​(@NotNull
                                                                                @NotNull String userID,
                                                                                @Nullable
                                                                                @Nullable String password,
                                                                                @NotNull
                                                                                @NotNull Principal principal,
                                                                                @Nullable
                                                                                @Nullable String intermediatePath)
                                                                         throws javax.jcr.RepositoryException
        Specified by:
        createUser in interface org.apache.jackrabbit.api.security.user.UserManager
        Throws:
        javax.jcr.RepositoryException
      • findAuthorizables

        @NotNull
        public @NotNull Iterator<org.apache.jackrabbit.api.security.user.Authorizable> findAuthorizables​(@NotNull
                                                                                                         @NotNull org.apache.jackrabbit.api.security.user.Query query)
                                                                                                  throws javax.jcr.RepositoryException
        Specified by:
        findAuthorizables in interface org.apache.jackrabbit.api.security.user.UserManager
        Throws:
        javax.jcr.RepositoryException
      • findAuthorizables

        @NotNull
        public @NotNull Iterator<org.apache.jackrabbit.api.security.user.Authorizable> findAuthorizables​(@NotNull
                                                                                                         @NotNull String relPath,
                                                                                                         @Nullable
                                                                                                         @Nullable String value)
                                                                                                  throws javax.jcr.RepositoryException
        Specified by:
        findAuthorizables in interface org.apache.jackrabbit.api.security.user.UserManager
        Throws:
        javax.jcr.RepositoryException
      • findAuthorizables

        @NotNull
        public @NotNull Iterator<org.apache.jackrabbit.api.security.user.Authorizable> findAuthorizables​(@NotNull
                                                                                                         @NotNull String relPath,
                                                                                                         @Nullable
                                                                                                         @Nullable String value,
                                                                                                         int searchType)
                                                                                                  throws javax.jcr.RepositoryException
        Specified by:
        findAuthorizables in interface org.apache.jackrabbit.api.security.user.UserManager
        Throws:
        javax.jcr.RepositoryException
      • getAuthorizable

        @Nullable
        public @Nullable org.apache.jackrabbit.api.security.user.Authorizable getAuthorizable​(@NotNull
                                                                                              @NotNull String id)
                                                                                       throws javax.jcr.RepositoryException
        Specified by:
        getAuthorizable in interface org.apache.jackrabbit.api.security.user.UserManager
        Throws:
        javax.jcr.RepositoryException
      • getAuthorizable

        @Nullable
        public @Nullable org.apache.jackrabbit.api.security.user.Authorizable getAuthorizable​(@NotNull
                                                                                              @NotNull Principal principal)
                                                                                       throws javax.jcr.RepositoryException
        Specified by:
        getAuthorizable in interface org.apache.jackrabbit.api.security.user.UserManager
        Throws:
        javax.jcr.RepositoryException
      • getAuthorizable

        @Nullable
        public <T extends org.apache.jackrabbit.api.security.user.Authorizable> T getAuthorizable​(@NotNull
                                                                                                  @NotNull String id,
                                                                                                  @NotNull
                                                                                                  @NotNull Class<T> authorizableClass)
                                                                                           throws javax.jcr.RepositoryException
        Specified by:
        getAuthorizable in interface org.apache.jackrabbit.api.security.user.UserManager
        Throws:
        javax.jcr.RepositoryException
      • getAuthorizableByPath

        @Nullable
        public @Nullable org.apache.jackrabbit.api.security.user.Authorizable getAuthorizableByPath​(@NotNull
                                                                                                    @NotNull String path)
                                                                                             throws javax.jcr.RepositoryException
        Specified by:
        getAuthorizableByPath in interface org.apache.jackrabbit.api.security.user.UserManager
        Throws:
        javax.jcr.RepositoryException