Class AnyUsersManager

java.lang.Object
eu.c6.gibraltar.api.common.AbstractManager
eu.c6.gibraltar.api.managers.users.AnyUsersManager

public class AnyUsersManager extends AbstractManager
The Class AnyUsersManager to get, create and update users.

Users are identified by their login.

  • Constructor Details

    • AnyUsersManager

      public AnyUsersManager(AnySession anySession)
      Instantiates a new Any users manager from user session.
      Parameters:
      anySession - the Any session
  • Method Details

    • getItemsAsExcel

      public InputStream getItemsAsExcel(String search) throws Exception
      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

      public List<IAnyUser> getItems(String search) throws Exception
      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

      public List<IAnyUser> search(IApiFilteredSearchRequest request) throws Exception
      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

      public IAnyUser get(String userid) throws Exception
      Gets the user using the user identifier (login).
      Parameters:
      userid - the user id
      Returns:
      the Any user
      Throws:
      Exception - the exception
    • create

      public boolean create(IAnyUser user) throws Exception
      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 :
      • Current user does not have permission to create users
      • User login already exists.
      • User name already exist.
      • Current user do not have permission to assign specified roles.
      • Authentication mode is "inline" (String) and you did not specify to reset password or password is not set.
    • update

      public boolean update(IAnyUser user) throws Exception
      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 :
      • Current user does not have permission to create users
      • User login already exists.
      • User name already exist.
      • Current user do not have permission to assign specified roles.
      • Authentication mode is "inline" (String) and you did not specify to reset password or password is not set.
    • delete

      public boolean delete(String userid) throws Exception
      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

      public boolean isMemberOfGroup(String userid, String groupid) throws Exception
      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