From f0422177d8ee6defd727b9b81abe7190e8854797 Mon Sep 17 00:00:00 2001 From: Katerina Iatropoulou Date: Thu, 8 Mar 2018 12:30:17 +0000 Subject: [PATCH] Emailer to work with ICM mail server --- .../usermanagement/ForgotPasswordServlet.java | 2 +- .../usermanagement/email/EmailSender.java | 70 ------------------- ...ontext-dnetOpenaireUsersService.properties | 7 +- .../webapp/WEB-INF/applicationContext.xml | 3 + src/main/webapp/WEB-INF/log4j.properties | 8 +-- src/main/webapp/WEB-INF/web.xml | 14 ---- 6 files changed, 12 insertions(+), 92 deletions(-) delete mode 100644 src/main/java/eu/dnetlib/openaire/usermanagement/email/EmailSender.java diff --git a/src/main/java/eu/dnetlib/openaire/usermanagement/ForgotPasswordServlet.java b/src/main/java/eu/dnetlib/openaire/usermanagement/ForgotPasswordServlet.java index 6c07fb5..386f820 100644 --- a/src/main/java/eu/dnetlib/openaire/usermanagement/ForgotPasswordServlet.java +++ b/src/main/java/eu/dnetlib/openaire/usermanagement/ForgotPasswordServlet.java @@ -19,7 +19,6 @@ import java.io.IOException; import java.sql.Timestamp; import java.util.Date; import java.util.UUID; - /** * Created by kiatrop on 28/9/2017. */ @@ -102,6 +101,7 @@ public class ForgotPasswordServlet extends HttpServlet { response.sendRedirect("./error.jsp"); } catch (MessagingException e) { + logger.error("Error in sending email", e); request.getSession().setAttribute("message", "Error sending email."); response.sendRedirect("./forgotPassword.jsp"); } diff --git a/src/main/java/eu/dnetlib/openaire/usermanagement/email/EmailSender.java b/src/main/java/eu/dnetlib/openaire/usermanagement/email/EmailSender.java deleted file mode 100644 index 7de744a..0000000 --- a/src/main/java/eu/dnetlib/openaire/usermanagement/email/EmailSender.java +++ /dev/null @@ -1,70 +0,0 @@ -package eu.dnetlib.openaire.usermanagement.email; - -import org.apache.log4j.Logger; - -import javax.mail.*; - -import javax.mail.internet.AddressException; -import javax.mail.internet.InternetAddress; -import javax.mail.internet.MimeMessage; -import java.util.Properties; - -/** - * Created by kiatrop on 9/10/2017. - */ -public class EmailSender { - - private static String username; - private static String password; - private static String host; - private static String port; - private static String from; - - Logger logger = Logger.getLogger(EmailSender.class); - - public void sendEmail(String recipient, String subject, String body) { - - // Get system properties - Properties properties = System.getProperties(); - properties.setProperty("mail.smtp.host", host); - properties.put("mail.smtp.port", port); - properties.put("mail.smtp.auth", "true"); //enable authentication - properties.put("mail.smtp.starttls.enable", "true"); - - Session session = javax.mail.Session.getInstance(properties, - new Authenticator() { - protected PasswordAuthentication getPasswordAuthentication() { - return new PasswordAuthentication(username, password); - } - }); - - try { - // Create a default MimeMessage object. - MimeMessage message = new MimeMessage(session); - - // Set From: header field of the header. - message.setFrom(new InternetAddress(from)); - - // Set To: header field of the header. - message.addRecipient(Message.RecipientType.TO, new InternetAddress(recipient)); - - // Set Subject: header field - message.setSubject(subject); - - // For simple text setText() can be used instead of setContent() - - // Send the actual HTML message, as big as you like - message.setContent(body, "text/html"); - - // Send message - Transport.send(message); - logger.debug("Sent message successfully....\n"); - - } catch (AddressException ae) { - logger.error("Email could not be send.", ae); - - } catch (MessagingException me) { - logger.error("Email could not be send.", me); - } - } -} diff --git a/src/main/resources/eu/dnet/openaire/usermanagement/springContext-dnetOpenaireUsersService.properties b/src/main/resources/eu/dnet/openaire/usermanagement/springContext-dnetOpenaireUsersService.properties index 3034c62..4550594 100644 --- a/src/main/resources/eu/dnet/openaire/usermanagement/springContext-dnetOpenaireUsersService.properties +++ b/src/main/resources/eu/dnet/openaire/usermanagement/springContext-dnetOpenaireUsersService.properties @@ -1,7 +1,8 @@ oidc.secret = U_gLOupYu2trYIOwfxGgZkkZoOHG_zGfaViOUsXcZ7qVQuF1rcJeQYKIDX1TY3z27CIoHaqq9ht2rmAiUmBRYQ oidc.id = 24e83176-1312-4ba3-bc0b-ffeebea1603e oidc.issuer = https://aai.openminted.eu/oidc/ -oidc.home = http://rudie.di.uoa.gr:8080/dnet-openaire-users-1.0.0-SNAPSHOT/openid_connect_login -webbapp.front = http://scoobydoo.di.uoa.gr:5000/reload + +oidc.home = https://beta.services.openaire.eu/uoa-user-management/openid_connect_logi +webbapp.front = https://beta.explore.openaire.eu/ webbapp.front.path = / -webbapp.front.domain = .di.uoa.gr +webbapp.front.domain = .di.uoa.gr \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/applicationContext.xml b/src/main/webapp/WEB-INF/applicationContext.xml index 05ccbce..2410459 100644 --- a/src/main/webapp/WEB-INF/applicationContext.xml +++ b/src/main/webapp/WEB-INF/applicationContext.xml @@ -17,6 +17,9 @@ + + + diff --git a/src/main/webapp/WEB-INF/log4j.properties b/src/main/webapp/WEB-INF/log4j.properties index 45a7db6..082c6df 100644 --- a/src/main/webapp/WEB-INF/log4j.properties +++ b/src/main/webapp/WEB-INF/log4j.properties @@ -1,8 +1,8 @@ -log4j.rootLogger = DEBUG, R +log4j.rootLogger = WARN, R -log4j.logger.eu.dnetlib = DEBUG -log4j.logger.org.mitre.openid = DEBUG -log4j.logger.org.springframework = DEBUG, S +log4j.logger.eu.dnetlib = INFO +log4j.logger.org.mitre.openid = INFO +log4j.logger.org.springframework = INFO, S log4j.additivity.org.springframework = false diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml index 2aa820e..e99de84 100644 --- a/src/main/webapp/WEB-INF/web.xml +++ b/src/main/webapp/WEB-INF/web.xml @@ -1,7 +1,5 @@ - - uoa-user-management contextConfigLocation @@ -59,18 +57,6 @@ /register - - - - - - - - - - - - VerificationCodeServlet Verify code