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.openiddatabase.authentication.business;
35
36 import fr.paris.lutece.portal.service.i18n.I18nService;
37 import fr.paris.lutece.portal.service.mail.MailService;
38 import fr.paris.lutece.portal.service.plugin.Plugin;
39 import fr.paris.lutece.portal.service.template.AppTemplateService;
40 import fr.paris.lutece.portal.service.util.AppPropertiesService;
41 import fr.paris.lutece.util.html.HtmlTemplate;
42
43 import java.util.HashMap;
44 import java.util.Locale;
45
46
47 public class PasswordRecoveryInPlainDAO implements IPasswordRecoveryService
48 {
49 private static final String MARK_USER = "user";
50 private static final String MARK_PASSWORD = "password";
51 private static final String TEMPLATE_EMAIL_BODY = "skin/plugins/mylutece/modules/openiddatabase/email_body.html";
52 private static final String PROPERTY_NOREPLY_EMAIL = "mail.noreply.email";
53 private static final String PROPERTY_EMAIL_OBJECT_PLAIN = "module.mylutece.openiddatabase.email.object.plain";
54
55 public void processOperations( OpenIdDatabaseUser user, Locale locale, Plugin plugin )
56 {
57 HashMap<String, Object> model = new HashMap<String, Object>( );
58 String strSender = AppPropertiesService.getProperty( PROPERTY_NOREPLY_EMAIL );
59 model.put( MARK_USER, user );
60 model.put( MARK_PASSWORD, OpenIdDatabaseUserHome.findPasswordByPrimaryKey( user.getUserId( ), plugin ) );
61 HtmlTemplate template = AppTemplateService.getTemplate( TEMPLATE_EMAIL_BODY, locale, model );
62
63 MailService.sendMailHtml( user.getEmail( ), user.getFirstName( ), strSender, getMailSubject( locale ),
64 template.getHtml( ) );
65 }
66
67 private String getMailSubject( Locale locale )
68 {
69 return I18nService.getLocalizedString( PROPERTY_EMAIL_OBJECT_PLAIN, locale );
70 }
71
72 public int getUserId( String strIdToken, Plugin plugin )
73 {
74
75 return 0;
76 }
77
78 public boolean isExpired( String strIdToken, Plugin plugin )
79 {
80
81 return false;
82 }
83 }