Class DatabaseService


  • public final class DatabaseService
    extends java.lang.Object
    DatabaseService
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void changeUserPasswordAndNotify​(java.lang.String strBaseURL, fr.paris.lutece.portal.service.plugin.Plugin plugin, java.util.Locale locale)
      Change all user's password and notify them with an email.
      boolean checkPassword​(java.lang.String strUserGuid, java.lang.String strPassword, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Check the password
      void doAutoLoginDatabaseUser​(javax.servlet.http.HttpServletRequest request, DatabaseUser databaseUser, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Login automatically the database user
      DatabaseUser doCreateUser​(DatabaseUser user, java.lang.String strPassword, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Do create a new database user
      void doInsertNewPasswordInHistory​(java.lang.String strPassword, int nUserId, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Log a password change in the password history
      void doModifyPassword​(DatabaseUser user, java.lang.String strPassword, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Do modify the password
      void doModifyResetPassword​(DatabaseUser user, boolean bNewValue, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Do modify the reset password attribute
      void doUpdateUser​(DatabaseUser user, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Update the info of the user
      java.util.List<DatabaseUser> getAuthorizedUsers​(fr.paris.lutece.portal.business.user.AdminUser adminUser, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Get authorized users list
      java.util.List<DatabaseUser> getFilteredUsersInterface​(DatabaseUserFilter duFilter, boolean bIsSearch, java.util.List<DatabaseUser> listUsers, javax.servlet.http.HttpServletRequest request, java.util.Map<java.lang.String,​java.lang.Object> model, fr.paris.lutece.util.url.UrlItem url)
      Get the filtered list of database users
      java.util.List<DatabaseUser> getListFilteredUsers​(javax.servlet.http.HttpServletRequest request, DatabaseUserFilter duFilter, java.util.List<DatabaseUser> listUsers)
      Get th list of filteredUsers
      java.util.Map<java.lang.String,​java.lang.Object> getManageAdvancedParameters​(fr.paris.lutece.portal.business.user.AdminUser user)
      Build the advanced parameters management
      static DatabaseService getService()
      Returns the instance of the singleton
      java.lang.String getXmlFromUser​(DatabaseUser user, boolean bExportRoles, boolean bExportGroups, boolean bExportAttributes, java.util.List<fr.paris.lutece.plugins.mylutece.business.attribute.IAttribute> listAttributes, java.util.Locale locale)
      Get a XML string describing a given user
      void init()
      Initialize the Database service
      boolean isAuthorized​(DatabaseUser user, fr.paris.lutece.portal.business.user.AdminUser adminUser, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Check if an Lutece user should be visible to the user according its workgroup
      boolean isPluginJcaptchaEnable()
      Check if the plugin jcaptcha is activated or not
      boolean isUserActive​(java.lang.String strUserName, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Check if the user is active or not
      boolean mustUserChangePassword​(fr.paris.lutece.portal.service.security.LuteceUser databaseUser, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Check whether a user must change his password
      void setDatabaseUserParameterService​(DatabaseUserParameterService userParamService)
      Set the database user parameter service
      void setPasswordFactory​(fr.paris.lutece.util.password.IPasswordFactory passwordFactory)
      Set the password factory
      void updateUserExpirationDate​(int nIdUser, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Update the user expiration date with new values, and notify him with an email.
      void updateUserLastLoginDate​(java.lang.String strLogin, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Update a user last login date.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • setDatabaseUserParameterService

        public void setDatabaseUserParameterService​(DatabaseUserParameterService userParamService)
        Set the database user parameter service
        Parameters:
        userParamService - the user parameter service
      • setPasswordFactory

        public void setPasswordFactory​(fr.paris.lutece.util.password.IPasswordFactory passwordFactory)
        Set the password factory
        Parameters:
        passwordFactory - the password factory
      • init

        public void init()
        Initialize the Database service
      • getService

        public static DatabaseService getService()
        Returns the instance of the singleton
        Returns:
        The instance of the singleton
      • getManageAdvancedParameters

        public java.util.Map<java.lang.String,​java.lang.Object> getManageAdvancedParameters​(fr.paris.lutece.portal.business.user.AdminUser user)
        Build the advanced parameters management
        Parameters:
        user - the admin user
        Returns:
        The model for the advanced parameters
      • isAuthorized

        public boolean isAuthorized​(DatabaseUser user,
                                    fr.paris.lutece.portal.business.user.AdminUser adminUser,
                                    fr.paris.lutece.portal.service.plugin.Plugin plugin)
        Check if an Lutece user should be visible to the user according its workgroup
        Parameters:
        user - the Lutece user
        adminUser - the admin user
        plugin - the plugin
        Returns:
        true if the Lutece user should be visible, false otherwise
      • getAuthorizedUsers

        public java.util.List<DatabaseUser> getAuthorizedUsers​(fr.paris.lutece.portal.business.user.AdminUser adminUser,
                                                               fr.paris.lutece.portal.service.plugin.Plugin plugin)
        Get authorized users list
        Parameters:
        adminUser - the admin user
        plugin - the plugin
        Returns:
        a list of users
      • getFilteredUsersInterface

        public java.util.List<DatabaseUser> getFilteredUsersInterface​(DatabaseUserFilter duFilter,
                                                                      boolean bIsSearch,
                                                                      java.util.List<DatabaseUser> listUsers,
                                                                      javax.servlet.http.HttpServletRequest request,
                                                                      java.util.Map<java.lang.String,​java.lang.Object> model,
                                                                      fr.paris.lutece.util.url.UrlItem url)
        Get the filtered list of database users
        Parameters:
        duFilter - The filter
        bIsSearch - True if the user used search filters, false otherwise
        listUsers - the initial list to filter
        request - HttpServletRequest
        model - Map
        url - UrlItem
        Returns:
        the filtered list
      • getListFilteredUsers

        public java.util.List<DatabaseUser> getListFilteredUsers​(javax.servlet.http.HttpServletRequest request,
                                                                 DatabaseUserFilter duFilter,
                                                                 java.util.List<DatabaseUser> listUsers)
        Get th list of filteredUsers
        Parameters:
        request - the HTTP request
        duFilter - the filter
        listUsers - the list of users
        Returns:
        a list of DatabaseUser
      • doCreateUser

        public DatabaseUser doCreateUser​(DatabaseUser user,
                                         java.lang.String strPassword,
                                         fr.paris.lutece.portal.service.plugin.Plugin plugin)
        Do create a new database user
        Parameters:
        user - the user
        strPassword - the password
        plugin - the plugin
        Returns:
        the new database user with a new ID
      • doModifyPassword

        public void doModifyPassword​(DatabaseUser user,
                                     java.lang.String strPassword,
                                     fr.paris.lutece.portal.service.plugin.Plugin plugin)
        Do modify the password
        Parameters:
        user - the DatabaseUser
        strPassword - the new password not encrypted
        plugin - the plugin
      • doModifyResetPassword

        public void doModifyResetPassword​(DatabaseUser user,
                                          boolean bNewValue,
                                          fr.paris.lutece.portal.service.plugin.Plugin plugin)
        Do modify the reset password attribute
        Parameters:
        user - the DatabaseUser
        bNewValue - the new value
        plugin - the plugin
      • doUpdateUser

        public void doUpdateUser​(DatabaseUser user,
                                 fr.paris.lutece.portal.service.plugin.Plugin plugin)
        Update the info of the user
        Parameters:
        user - the user
        plugin - the plugin
      • checkPassword

        public boolean checkPassword​(java.lang.String strUserGuid,
                                     java.lang.String strPassword,
                                     fr.paris.lutece.portal.service.plugin.Plugin plugin)
        Check the password
        Parameters:
        strUserGuid - the user guid
        strPassword - the password
        plugin - the plugin
        Returns:
        true if the password is the same as stored in the database, false otherwise
      • isUserActive

        public boolean isUserActive​(java.lang.String strUserName,
                                    fr.paris.lutece.portal.service.plugin.Plugin plugin)
        Check if the user is active or not
        Parameters:
        strUserName - the user name
        plugin - the plugin
        Returns:
        true if it is active, false otherwise
      • isPluginJcaptchaEnable

        public boolean isPluginJcaptchaEnable()
        Check if the plugin jcaptcha is activated or not
        Returns:
        true if it is activated, false otherwise
      • changeUserPasswordAndNotify

        public void changeUserPasswordAndNotify​(java.lang.String strBaseURL,
                                                fr.paris.lutece.portal.service.plugin.Plugin plugin,
                                                java.util.Locale locale)
        Change all user's password and notify them with an email.
        Parameters:
        strBaseURL - The base url of the application
        plugin - The plugin
        locale - The locale to use
      • mustUserChangePassword

        public boolean mustUserChangePassword​(fr.paris.lutece.portal.service.security.LuteceUser databaseUser,
                                              fr.paris.lutece.portal.service.plugin.Plugin plugin)
        Check whether a user must change his password
        Parameters:
        databaseUser - The user to check
        plugin - The plugin
        Returns:
        True if a user must change his password, false otherwise.
      • doInsertNewPasswordInHistory

        public void doInsertNewPasswordInHistory​(java.lang.String strPassword,
                                                 int nUserId,
                                                 fr.paris.lutece.portal.service.plugin.Plugin plugin)
        Log a password change in the password history
        Parameters:
        strPassword - New password of the user
        nUserId - Id of the user
        plugin - The plugin
      • updateUserExpirationDate

        public void updateUserExpirationDate​(int nIdUser,
                                             fr.paris.lutece.portal.service.plugin.Plugin plugin)
        Update the user expiration date with new values, and notify him with an email.
        Parameters:
        nIdUser - Id of the user to update
        plugin - The plugin
      • updateUserLastLoginDate

        public void updateUserLastLoginDate​(java.lang.String strLogin,
                                            fr.paris.lutece.portal.service.plugin.Plugin plugin)
        Update a user last login date.
        Parameters:
        strLogin - Login of the user to update
        plugin - The plugin
      • getXmlFromUser

        public java.lang.String getXmlFromUser​(DatabaseUser user,
                                               boolean bExportRoles,
                                               boolean bExportGroups,
                                               boolean bExportAttributes,
                                               java.util.List<fr.paris.lutece.plugins.mylutece.business.attribute.IAttribute> listAttributes,
                                               java.util.Locale locale)
        Get a XML string describing a given user
        Parameters:
        user - The user to get the XML of.
        bExportRoles - True to export roles of the user, false otherwise.
        bExportGroups - True to export groups of the user, false otherwise.
        bExportAttributes - True to export attributes of the user, false otherwise.
        listAttributes - The list of attributes to export.
        locale - The locale
        Returns:
        A string of XML with the information of the user.
      • doAutoLoginDatabaseUser

        public void doAutoLoginDatabaseUser​(javax.servlet.http.HttpServletRequest request,
                                            DatabaseUser databaseUser,
                                            fr.paris.lutece.portal.service.plugin.Plugin plugin)
        Login automatically the database user
        Parameters:
        request - the HTTP request
        DatabaseUser - databaseUser
        plugin - the plugin