1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 package fr.paris.lutece.plugins.mylutece.modules.database.authentication.service.parameter;
35
36 import fr.paris.lutece.plugins.mylutece.modules.database.authentication.business.DatabaseUserHome;
37 import fr.paris.lutece.plugins.mylutece.modules.database.authentication.business.parameter.DatabaseUserParameterHome;
38 import fr.paris.lutece.plugins.mylutece.modules.database.authentication.service.DatabaseService;
39 import fr.paris.lutece.portal.service.plugin.Plugin;
40 import fr.paris.lutece.portal.service.spring.SpringContextService;
41 import fr.paris.lutece.util.ReferenceItem;
42 import fr.paris.lutece.util.ReferenceList;
43
44 import java.sql.Timestamp;
45 import java.util.Collections;
46 import java.util.List;
47
48
49
50
51
52
53 public final class DatabaseUserParameterService implements IDatabaseUserParameterService
54 {
55 private static final String BEAN_DATABASE_USER_PARAMETER_SERVICE = "mylutece-database.databaseUserParameterService";
56
57
58 private static final String PARAMETER_ACCOUNT_CREATION_VALIDATION_EMAIL = "account_creation_validation_email";
59 private static final String PARAMETER_ENABLE_JCAPTCHA = "enable_jcaptcha";
60 private static final String PARAMETER_AUTO_LOGIN_AFTER_VALIDATION_EMAIL = "auto_login_after_validation_email";
61
62
63
64
65 private DatabaseUserParameterService( )
66 {
67 }
68
69
70
71
72
73
74 public static DatabaseUserParameterService getService( )
75 {
76 return SpringContextService.getBean( BEAN_DATABASE_USER_PARAMETER_SERVICE );
77 }
78
79
80
81
82
83
84
85
86
87
88 public ReferenceItem findByKey( String strParameterKey, Plugin plugin )
89 {
90 return DatabaseUserParameterHome.findByKey( strParameterKey, plugin );
91 }
92
93
94
95
96
97
98
99
100
101 public void update( ReferenceItem userParam, Plugin plugin )
102 {
103 if ( userParam != null )
104 {
105 DatabaseUserParameterHome.update( userParam, plugin );
106 }
107 }
108
109
110
111
112
113
114
115
116 public ReferenceList findAll( Plugin plugin )
117 {
118 return DatabaseUserParameterHome.findAll( plugin );
119 }
120
121
122
123
124
125
126
127
128 public boolean isPasswordEncrypted( Plugin plugin )
129 {
130 return false;
131 }
132
133
134
135
136
137
138
139
140 public String getEncryptionAlgorithm( Plugin plugin )
141 {
142 return "";
143 }
144
145
146
147
148
149
150
151
152 public boolean isAccountCreationValidationEmail( Plugin plugin )
153 {
154 boolean bIsValidationEmail = false;
155 ReferenceItem userParam = findByKey( PARAMETER_ACCOUNT_CREATION_VALIDATION_EMAIL, plugin );
156
157 if ( ( userParam != null ) && userParam.isChecked( ) )
158 {
159 bIsValidationEmail = true;
160 }
161
162 return bIsValidationEmail;
163 }
164
165
166
167
168 @Override
169 public boolean isAutoLoginAfterValidationEmail( Plugin plugin )
170 {
171 boolean bIsAutoLogin = false;
172 ReferenceItem userParam = findByKey( PARAMETER_AUTO_LOGIN_AFTER_VALIDATION_EMAIL, plugin );
173
174 if ( ( userParam != null ) && userParam.isChecked( ) )
175 {
176 bIsAutoLogin = true;
177 }
178
179 return bIsAutoLogin;
180 }
181
182
183
184
185
186
187
188
189 public boolean isJcaptchaEnable( Plugin plugin )
190 {
191 boolean bIsEnable = false;
192 ReferenceItem userParam = findByKey( PARAMETER_ENABLE_JCAPTCHA, plugin );
193
194 if ( ( userParam != null ) && userParam.isChecked( ) && DatabaseService.getService( ).isPluginJcaptchaEnable( ) )
195 {
196 bIsEnable = true;
197 }
198
199 return bIsEnable;
200 }
201
202
203
204
205 @Override
206 public int countUserPasswordHistoryFromDate( Timestamp minDate, int nUserId, Plugin plugin )
207 {
208 return DatabaseUserHome.countUserPasswordHistoryFromDate( minDate, nUserId, plugin );
209 }
210
211
212
213
214 @Override
215 public List<String> selectUserPasswordHistory( int nUserID, Plugin plugin )
216 {
217
218 return Collections.emptyList( );
219 }
220 }