Class UserGroupMethods


  • public final class UserGroupMethods
    extends Object
    This class provides methods for access control list management in Gloop.
    • Constructor Detail

      • UserGroupMethods

        @Autowired
        UserGroupMethods​(io.toro.martini.permissions.AccessControlService accessControlService)
    • Method Detail

      • findUserById

        @GloopObjectParameter("user{\n  user#io.toro.martini.user.User{\n  }\n}")
        public static GloopModel findUserById​(@GloopParameter(allowNull=false)
                                              String userId)
        Retrieve a user by ID.
        Parameters:
        userId - the ID of the user to get
        Returns:
        the user, whose ID matches the provided string
        Since:
        1.0.2
      • findUserByEmail

        @GloopObjectParameter("user{\n  user#io.toro.martini.user.User{\n  }\n}")
        public static GloopModel findUserByEmail​(@GloopParameter(allowNull=false)
                                                 String emailAddress)
        Retrieve a user by email address.
        Parameters:
        emailAddress - the email address of the user to get
        Returns:
        the user, whose email address matches the provided string
        Since:
        1.0
      • groupExists

        public static boolean groupExists​(@GloopParameter(allowNull=false)
                                          String name)
        Checks whether or not a group with the provided name exists.
        Parameters:
        name - the name of the group to look for
        Returns:
        true if the provided group exists; false otherwise
        Since:
        1.0
      • groupsExist

        public static List<String> groupsExist​(@GloopParameter(allowNull=false)
                                               List<String> groupNames)
        Filters the provided list of group names, returning only the names of groups that exist.
        Parameters:
        groupNames - the list of group names to filter
        Returns:
        names of existing groups from the provided list
        Since:
        1.0
      • findUsers

        @GloopObjectParameter("users{\n  users#io.toro.martini.user.User[]{\n  }\n}")
        public static GloopModel findUsers​(Closure predicateClosure)
        Filters existing users, returning only users matching the provided predicate.
        Parameters:
        predicateClosure - a Groovy closure that receives one argument, called it that is a User object; and returns a boolean value indicating whether or not to include a user in the result or not
        Returns:
        filtered users
        Since:
        1.0
      • findGroups

        public static List<String> findGroups()
        Get the names of all registered groups.
        Returns:
        group names
        Since:
        1.0
      • saveGroup

        public static void saveGroup​(@GloopParameter(allowNull=false)
                                     String groupName)
        Save a new group.
        Parameters:
        groupName - the name of the group to persist
        Since:
        1.0
      • addUserToGroup

        public static void addUserToGroup​(@GloopParameter(allowNull=false)
                                          String username,
                                          @GloopParameter(allowNull=false)
                                          String groupname)
        Add a user to a group by name.
        Parameters:
        username - the name of the user to add to the group
        groupname - the name of the group where to add the user to
        Since:
        1.0
      • removeUserFromGroup

        public static void removeUserFromGroup​(@GloopParameter(allowNull=false)
                                               String username,
                                               @GloopParameter(allowNull=false)
                                               String groupname)
        Remove a user from a group by name.
        Parameters:
        username - the name of the user to remove from the group
        groupname - the name of the group where to remove the user from
        Since:
        1.0
      • deleteUser

        public static void deleteUser​(@GloopParameter(allowNull=false)
                                      String id)
        Delete a user by ID.
        Parameters:
        id - the ID of the user to delete
        Since:
        1.0
      • deleteUserByUsername

        public static void deleteUserByUsername​(@GloopParameter(allowNull=false)
                                                String username)
        Delete a user by username.
        Parameters:
        username - the username of the user to delete
        Since:
        1.0.2
      • deleteGroupByName

        public static void deleteGroupByName​(@GloopParameter(allowNull=false)
                                             String groupName)
        Delete a group by name.
        Parameters:
        groupName - the name of the group to delete
        Since:
        1.0.2
      • findAccessTokenByUserId

        @GloopObjectParameter("token{\n  token#io.toro.martini.user.AccessToken{\n  }\n}")
        public static GloopModel findAccessTokenByUserId​(String userId)
        Retrieves the access token of the user, whose id matches the provided string.
        Parameters:
        userId - the ID of the user
        Returns:
        the access token, if present
        Since:
        1.0.2
      • findAccessTokenByUsername

        @GloopObjectParameter("token{\n  token#io.toro.martini.user.AccessToken{\n  }\n}")
        public static GloopModel findAccessTokenByUsername​(String userName)
        Retrieves the access token of the user, whose username matches the provided string.
        Parameters:
        userName - the username of the user
        Returns:
        the access token, if present
        Since:
        1.0.2
      • generateToken

        @GloopObjectParameter("token{\n  token#io.toro.martini.user.AccessToken{\n  }\n}")
        public static GloopModel generateToken​(String userName)
        Generates an access token for the user, whose username matches the provided string.
        Parameters:
        userName - the username of the user
        Returns:
        the generated token