View Javadoc
1   /*
2    * Copyright (c) 2002-2021, City of Paris
3    * All rights reserved.
4    *
5    * Redistribution and use in source and binary forms, with or without
6    * modification, are permitted provided that the following conditions
7    * are met:
8    *
9    *  1. Redistributions of source code must retain the above copyright notice
10   *     and the following disclaimer.
11   *
12   *  2. Redistributions in binary form must reproduce the above copyright notice
13   *     and the following disclaimer in the documentation and/or other materials
14   *     provided with the distribution.
15   *
16   *  3. Neither the name of 'Mairie de Paris' nor 'Lutece' nor the names of its
17   *     contributors may be used to endorse or promote products derived from
18   *     this software without specific prior written permission.
19   *
20   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23   * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
24   * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25   * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26   * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27   * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28   * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30   * POSSIBILITY OF SUCH DAMAGE.
31   *
32   * License 1.0
33   */
34  package fr.paris.lutece.plugins.mylutece.modules.database.authentication.business;
35  
36  import fr.paris.lutece.plugins.mylutece.modules.database.authentication.BaseUser;
37  import fr.paris.lutece.portal.service.plugin.Plugin;
38  import fr.paris.lutece.portal.service.security.LuteceAuthentication;
39  
40  import java.sql.Timestamp;
41  
42  import java.util.Collection;
43  import java.util.List;
44  
45  /**
46   *
47   * @author Etienne
48   */
49  public interface IDatabaseDAO
50  {
51      /**
52       * Find users by login
53       *
54       * @param strLogin
55       *            the login
56       * @param plugin
57       *            The Plugin using this data access service
58       * @param authenticationService
59       *            the LuteceAuthentication object
60       * @return BaseUser the user corresponding to the login
61       */
62      BaseUser selectLuteceUserByLogin( String strLogin, Plugin plugin, LuteceAuthentication authenticationService );
63  
64      /**
65       * Check if a user has reset his password from his login
66       *
67       * @param strLogin
68       *            the login
69       * @param plugin
70       *            The Plugin using this data access service
71       * @param authenticationService
72       *            the LuteceAuthentication object
73       * @return boolean true if the password vhas been reset, false otherwise
74       */
75      boolean selectResetPasswordFromLogin( String strLogin, Plugin plugin );
76  
77      /**
78       * Gets the password max valid date of a user from his login.
79       * 
80       * @param strLogin
81       *            the login of the user
82       * @param plugin
83       *            The plugin
84       * @return The date of end of validity of the password of the user, or null if none has been set.
85       */
86      Timestamp selectPasswordMaxValideDateFromLogin( String strLogin, Plugin plugin );
87  
88      /**
89       * Load the list of {@link BaseUser}
90       * 
91       * @param plugin
92       *            The Plugin using this data access service
93       * @param authenticationService
94       *            the authentication service
95       * @return The Collection of the {@link BaseUser}
96       */
97      Collection<BaseUser> selectLuteceUserList( Plugin plugin, LuteceAuthentication authenticationService );
98  
99      /**
100      * Select the list of DatabaseUsers for a login
101      *
102      * @param strLogin
103      *            The login of DatabaseUser
104      * @param plugin
105      *            The Plugin using this data access service
106      * @return The Collection of the DatabaseUsers
107      */
108     List<String> selectUserRolesFromLogin( String strLogin, Plugin plugin );
109 
110     /**
111      * Delete roles for a user
112      * 
113      * @param nIdUser
114      *            The id of the user
115      * @param plugin
116      *            The Plugin using this data access service
117      */
118     void deleteRolesForUser( int nIdUser, Plugin plugin );
119 
120     /**
121      * Assign a role to user
122      * 
123      * @param nIdUser
124      *            The id of the user
125      * @param strRoleKey
126      *            The key of the role
127      * @param plugin
128      *            The Plugin using this data access service
129      */
130     void createRoleForUser( int nIdUser, String strRoleKey, Plugin plugin );
131 
132     /**
133      * Find user's groups by login
134      *
135      * @param strLogin
136      *            the login
137      * @param plugin
138      *            The Plugin using this data access service
139      * @return ArrayList the group key list corresponding to the login
140      */
141     List<String> selectUserGroupsFromLogin( String strLogin, Plugin plugin );
142 
143     /**
144      * Load the list of DatabaseUsers for a Lutece role
145      * 
146      * @param strRoleKey
147      *            The role key of DatabaseUser
148      * @param plugin
149      *            The Plugin using this data access service
150      * @return The Collection of the logins
151      */
152     Collection<String> selectLoginListForRoleKey( String strRoleKey, Plugin plugin );
153 
154     /**
155      * Delete groups for a user
156      * 
157      * @param nIdUser
158      *            The id of the user
159      * @param plugin
160      *            The Plugin using this data access service
161      */
162     void deleteGroupsForUser( int nIdUser, Plugin plugin );
163 
164     /**
165      * Assign a group to user
166      * 
167      * @param nIdUser
168      *            The id of the user
169      * @param strGroupKey
170      *            The key of the group
171      * @param plugin
172      *            The Plugin using this data access service
173      */
174     void createGroupForUser( int nIdUser, String strGroupKey, Plugin plugin );
175 
176     /**
177      * Find assigned users to the given group
178      * 
179      * @param strGroupKey
180      *            The group key
181      * @param plugin
182      *            Plugin
183      * @return a list of DatabaseUser
184      */
185     List<DatabaseUser> selectGroupUsersFromGroupKey( String strGroupKey, Plugin plugin );
186 
187     /**
188      * Update the reset password attribut of a user from his login
189      * 
190      * @param strUserName
191      *            Login of the user to update
192      * @param bNewValue
193      *            New value
194      * @param plugin
195      *            The plugin
196      */
197     void updateResetPasswordFromLogin( String strUserName, boolean bNewValue, Plugin plugin );
198 
199     /**
200      * Get the id of a user from his login
201      * 
202      * @param strLogin
203      *            Login of the user
204      * @param plugin
205      *            The plugin
206      * @return The id of the user
207      */
208     int findUserIdFromLogin( String strLogin, Plugin plugin );
209 }