Class AnyUsersManager
java.lang.Object
eu.c6.gibraltar.api.common.AbstractManager
eu.c6.gibraltar.api.managers.users.AnyUsersManager
The Class AnyUsersManager to get, create and update users.
Users are identified by their login.
-
Field Summary
Fields inherited from class eu.c6.gibraltar.api.common.AbstractManager
APPLICATION_XLS, APPLICATION_XLS_TYPE, APPLICATION_XLSX, APPLICATION_XLSX_TYPE -
Constructor Summary
ConstructorsConstructorDescriptionAnyUsersManager(AnySession anySession) Instantiates a new Any users manager from user session. -
Method Summary
Modifier and TypeMethodDescriptionbooleanCreates the user with specified identifier, name, mail, roles, groups, active state and authentication mode.booleanDelete user with specified identifier.Gets the user using the user identifier (login).Gets the list of user items.getItemsAsExcel(String search) Gets the list of user items as Excel stream output.booleanisMemberOfGroup(String userid, String groupid) Checks if a user is a member of a group.search(IApiFilteredSearchRequest request) Search for users.booleanUpdate the user mail, roles, groups, active state, MFA reset or authentication mode.
-
Constructor Details
-
AnyUsersManager
Instantiates a new Any users manager from user session.- Parameters:
anySession- the Any session
-
-
Method Details
-
getItemsAsExcel
Gets the list of user items as Excel stream output.- Parameters:
search- Filters users using fulltext search term. Use NULL to not filter. Performances can be affected when using a filter.- Returns:
- Excel file input stream (media type : "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" (
String)) - Throws:
Exception- the exception if current user does not have permission to list users.
-
getItems
Gets the list of user items.- Parameters:
search- Filters users using fulltext search term. Use NULL to not filter. Performances can be affected when using a filter.- Returns:
- the user items
- Throws:
Exception- the exception if current user does not have permission to list users.
-
search
Search for users.- Parameters:
request- used for search terms and filters- Returns:
- the user items
- Throws:
Exception- the exception if current user does not have permission to list users.
-
get
Gets the user using the user identifier (login).- Parameters:
userid- the user id- Returns:
- the Any user
- Throws:
Exception- the exception
-
create
Creates the user with specified identifier, name, mail, roles, groups, active state and authentication mode.Example :
IAnyUser newUser = new AnyUser(); newUser.setId("user01"); newUser.setName("User 01"); myUser.setMail("new_address@c6.eu"); myUser.setAuthentication("inline"); myUser.setResetPassword(true); myUser.setRoles(Arrays.asList("standard")); ICObject extendedUserMetadata = new CObject(); extendedUserMetadata.set("employee_number", "123456"); extendedUserMetadata.set("date_birth", new Date(2000, 01, 01)); myUser.setExtendedMetadata(extendedUserMetadata); boolean created = userSession.getUsersManager().create(myUser);- Parameters:
user- the user item.- id : User identifier is required and must be only composed with lower case characters, underscore and number. Group identifier maximum length is 128 characters. Must be unique.
- name : Required. Must be unique.
- mail : Not required, mail address
- authentication mode : "inline" (
String) or "ldap" (String) - password : You must set it if you use authentication mode
"inline" (
String). - is_password_base64_encoded : TRUE/FALSE. Set it to TRUE if you have the password Base64 encoded.
- disabled : TRUE/FALSE. Set it to TRUE if you want to disable the user.
- groups : User will be added into each listed groups. Groups are identified by their name.
- roles : Each listed roles will be assigned to new user.
- password expired : Needed for authentication mode "inline"
(
String). If FALSE (default) and no password set an error will be raised. Set it to TRUE to reset password. In this case the user will have to choose its password when connected. - extended_metadata: Optional JSON node used to update custom metadata on the user. The metadata used here need to be declare on the user aspect first.
- Returns:
- true, if successfully created
- Throws:
Exception- the exception if :
-
update
Update the user mail, roles, groups, active state, MFA reset or authentication mode.You must set only the values you want to update.
Example :
IAnyUser myUser = new AnyUser("existing_user01"); myUser.setMail("new_address@c6.eu"); myUser.setPassword("new_address@c6.eu"); ICObject extendedUserMetadata = new CObject(); extendedUserMetadata.set("employee_number", "123456"); extendedUserMetadata.set("date_birth", new Date(2000, 01, 01)); myUser.setExtendedMetadata(extendedUserMetadata); boolean updated = userSession.getUsersManager().update(myUser);- Parameters:
user- the user item to update. You can update :- mail : mail address
- authentication mode : "inline" (
String) or "ldap" (String) - password : You must set it if you use authentication mode
"inline" (
String). - disabled : TRUE/FALSE. Set it to TRUE if you want to disable the user.
- groups : User groups are replaced by listed groups. Groups are identified by their name.
- roles : User roles are replace by listed roles.
- password expired : Set it to TRUE to reset password. In this case the user will have to choose its password when connected.
- is_password_base64_encoded : TRUE/FALSE. Set it to TRUE if you have the password Base64 encoded.
- reset MFA : Set to TRUE if you want to reset the MFA.
- reset columns : Set to TRUE if you want to reset user preferences for columns.
- extended_metadata: Optional JSON node used to update custom metadata on the user. The metadata used here need to be declare on the user aspect first.
- Returns:
- true, if successfully updated
- Throws:
Exception- the exception if :
-
delete
Delete user with specified identifier.- Parameters:
userid- the user identifier (login)- Returns:
- true, if successfully deleted
- Throws:
Exception- the exception if the current user does not have permission to delete user or user does not exist
-
isMemberOfGroup
Checks if a user is a member of a group.- Parameters:
userid- the user identifier (login)groupid- the group identifier (group name)- Returns:
- true, if is direct or indirect member of group
- Throws:
Exception- the exception if the current user does not have permission to list users
-