1 /*
2 * Copyright (c) 2002-2014, Mairie de 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.wssodatabase.authentication.business;
35
36 import java.util.Collection;
37 import java.util.List;
38
39 import fr.paris.lutece.plugins.mylutece.modules.wssodatabase.authentication.IdxWSSODatabaseUser;
40 import fr.paris.lutece.portal.service.plugin.Plugin;
41 import fr.paris.lutece.portal.service.security.LuteceAuthentication;
42 import fr.paris.lutece.portal.service.spring.SpringContextService;
43
44
45 /**
46 * Home for IdxWSSODatabase
47 *
48 */
49 public final class IdxWSSODatabaseHome
50 {
51 // Static variable pointed at the DAO instance
52 private static IIdxWSSODatabaseDAO _dao = (IdxWSSODatabaseDAO) SpringContextService.getPluginBean(
53 "mylutece-websso", "mylutece-wssodatabase.idxWSSODatabaseDAO" );
54
55 /**
56 * Private constructor - this class need not be instantiated
57 */
58 private IdxWSSODatabaseHome( )
59 {
60 }
61
62 // /////////////////////////////////////////////////////////////////////////
63 // Finders
64
65 /**
66 * Find users by guid
67 *
68 * @param strGuid the WSSO guid
69 * @param plugin The Plugin using this data access service
70 * @param authenticationService the LuteceAuthentication object
71 * @return IdxWSSODatabaseUser the user corresponding to the guid
72 */
73 public static IdxWSSODatabaseUser findUserByGuid( String strGuid, Plugin plugin,
74 LuteceAuthentication authenticationService )
75 {
76 return _dao.findUserByGuid( strGuid, plugin, authenticationService );
77 }
78
79 /**
80 * Find user's roles by guid
81 *
82 * @param strGuid the WSSO guid
83 * @param plugin The Plugin using this data access service
84 * @param authenticationService the LuteceAuthentication object
85 * @return ArrayList the roles list corresponding to the guid
86 */
87 public static List<String> findUserRolesFromGuid( String strGuid, Plugin plugin,
88 LuteceAuthentication authenticationService )
89 {
90 return _dao.findUserRolesFromGuid( strGuid, plugin, authenticationService );
91 }
92
93 /**
94 * Update the last login date of a user
95 * @param strGuid The GUID of the user to update
96 * @param dateLastLogin New date of last connection
97 * @param plugin The plugin
98 */
99 public static void updateDateLastLogin( String strGuid, java.util.Date dateLastLogin, Plugin plugin )
100 {
101 _dao.updateDateLastLogin( strGuid, dateLastLogin, plugin );
102 }
103
104 /**
105 * Find users by guid
106 *
107 * @param plugin The Plugin using this data access service
108 * @param authenticationService the LuteceAuthentication object
109 * @return IdxWSSODatabaseUser the user corresponding to the guid
110 */
111 public static Collection<IdxWSSODatabaseUser> findUsersList( Plugin plugin,
112 LuteceAuthentication authenticationService )
113 {
114 return _dao.findUsersList( plugin, authenticationService );
115 }
116
117 /**
118 * Find roles by a profil
119 *
120 * @param codeProfil the code of the profil
121 * @param plugin the current plugin
122 * @return the role list for the profil
123 */
124 public static List<String> findRolesFromProfil( String codeProfil, Plugin plugin )
125 {
126 return _dao.findRolesFromProfil( codeProfil, plugin );
127 }
128
129 /**
130 * Remove roles fora profil
131 *
132 * @param codeProfil the code of the profil
133 * @param plugin the current plugin
134 */
135 public static void removeRolesForProfil( String codeProfil, Plugin plugin )
136 {
137 _dao.removeRolesForProfil( codeProfil, plugin );
138 }
139
140 /**
141 * Add role for a profil
142 *
143 * @param codeProfil code of the profil
144 * @param codeRole the code of the role
145 * @param plugin the current profil
146 */
147 public static void addRoleForProfil( String codeProfil, String codeRole, Plugin plugin )
148 {
149 _dao.addRoleForProfil( codeProfil, codeRole, plugin );
150 }
151
152 /**
153 * Find users for a profil
154 *
155 * @param codeProfil code of the profil
156 * @param plugin the current plugin
157 * @return the user list for the profil
158 */
159 public static List<WssoUser> findWssoUsersForProfil( String codeProfil, Plugin plugin )
160 {
161 return _dao.findWssoUsersForProfil( codeProfil, plugin );
162 }
163
164 /**
165 * Add user for a profil
166 *
167 * @param wssoUserId the user id
168 * @param codeProfil code of the profil
169 * @param plugin the current plugin
170 */
171 public static void addUserForProfil( int wssoUserId, String codeProfil, Plugin plugin )
172 {
173 _dao.addUserForProfil( wssoUserId, codeProfil, plugin );
174 }
175
176 /**
177 * Remove user for a profil
178 *
179 * @param wssoUserId the user id
180 * @param codeProfil code of the profil
181 * @param plugin the current plugin
182 */
183 public static void removeUserForProfil( int wssoUserId, String codeProfil, Plugin plugin )
184 {
185 _dao.removeUserForProfil( wssoUserId, codeProfil, plugin );
186 }
187
188 /**
189 * remove profils for a user
190 *
191 * @param wssoUserId the user id
192 * @param plugin the current plugin
193 */
194 public static void removeProfilsForUser( int wssoUserId, Plugin plugin )
195 {
196 _dao.removeProfilsForUser( wssoUserId, plugin );
197 }
198 }