Package io.toro.martini
Class UserGroupMethods
- java.lang.Object
- 
- io.toro.martini.UserGroupMethods
 
- 
 public final class UserGroupMethods extends Object This class provides methods for access control list management in Gloop.
- 
- 
Constructor SummaryConstructors Constructor Description UserGroupMethods(io.toro.martini.permissions.AccessControlService accessControlService)
 - 
Method SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method Description static voidaddUserToGroup(String username, String groupname)Add a user to a group by name.static voiddeleteGroupByName(String groupName)Delete a group by name.static voiddeleteUser(String id)Delete a user by ID.static voiddeleteUserByUsername(String username)Delete a user by username.static GloopModelfindAccessTokenByUserId(String userId)Retrieves the access token of the user, whose id matches the provided string.static GloopModelfindAccessTokenByUsername(String userName)Retrieves the access token of the user, whose username matches the provided string.static List<String>findGroups()Get the names of all registered groups.static GloopModelfindUser(String username)Retrieve the user matching the provided username.static GloopModelfindUser(String username, String password)Retrieve the user, whose credentials match the provided username and password.static GloopModelfindUserByEmail(String emailAddress)Retrieve a user by email address.static GloopModelfindUserById(String userId)Retrieve a user by ID.static GloopModelfindUsers(Closure predicateClosure)Filters existing users, returning only users matching the provided predicate.static GloopModelgenerateToken(String userName)Generates an access token for the user, whose username matches the provided string.static booleangroupExists(String name)Checks whether or not a group with the provided name exists.static List<String>groupsExist(List<String> groupNames)Filters the provided list of group names, returning only the names of groups that exist.static voidremoveUserFromGroup(String username, String groupname)Remove a user from a group by name.static voidsaveGroup(String groupName)Save a new group.static voidsaveUser(GloopModel user)
 
- 
- 
- 
Constructor Detail- 
UserGroupMethods@Autowired UserGroupMethods(io.toro.martini.permissions.AccessControlService accessControlService) 
 
- 
 - 
Method Detail- 
findUser@GloopObjectParameter("user{\n user#io.toro.martini.user.User{\n }\n}") public static GloopModel findUser(@GloopParameter(allowNull=false) String username) Retrieve the user matching the provided username.- Returns:
- the user, whose username matches the provided string
- Since:
- 1.0
 
 - 
findUser@GloopObjectParameter("user{\n user#io.toro.martini.user.User{\n }\n}") public static GloopModel findUser(@GloopParameter(allowNull=false) String username, @GloopParameter(allowNull=false) String password) Retrieve the user, whose credentials match the provided username and password.- Returns:
- the user, whose credentials matched the provided username and password
- Since:
- 1.0
 
 - 
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
 
 - 
groupExistspublic 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
 
 - 
groupsExistpublic 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
 
 - 
saveUserpublic static void saveUser(@GloopParameter(allowNull=false) @GloopObjectParameter("user#io.toro.martini.user.User{\n}") GloopModel user) - Parameters:
- user- the user to persist
- 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- itthat is a- Userobject; and returns a boolean value indicating whether or not to include a user in the result or not
- Returns:
- filtered users
- Since:
- 1.0
 
 - 
findGroupspublic static List<String> findGroups() Get the names of all registered groups.- Returns:
- group names
- Since:
- 1.0
 
 - 
saveGrouppublic static void saveGroup(@GloopParameter(allowNull=false) String groupName) Save a new group.- Parameters:
- groupName- the name of the group to persist
- Since:
- 1.0
 
 - 
addUserToGrouppublic 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
 
 - 
removeUserFromGrouppublic 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
 
 - 
deleteUserpublic 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
 
 - 
deleteUserByUsernamepublic 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
 
 - 
deleteGroupByNamepublic 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
 
 
- 
 
-