diff --git a/core/src/main/java/com/localeat/core/commons/EmailService.java b/core/src/main/java/com/localeat/core/commons/EmailService.java new file mode 100644 index 0000000..a76c5d5 --- /dev/null +++ b/core/src/main/java/com/localeat/core/commons/EmailService.java @@ -0,0 +1,38 @@ +package com.localeat.core.commons; + +import com.localeat.core.config.email.EmailConfig; +import com.localeat.core.config.security.LocalEatRSAKey; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; + +import javax.mail.*; +import javax.mail.internet.MimeMessage; + +@Controller +public class EmailController { + + private static final Logger LOGGER = LoggerFactory.getLogger(EmailController.class); + + @Autowired + EmailConfig emailConfig; + + public void sendMail(String recipient, String subject, String body) { + Session session = Session.getInstance(emailConfig.getProperties(), new SimpleAuthenticator()); + + try { + MimeMessage msg = new MimeMessage(session); + msg.setFrom("la.viande.en.direct@gmail.com"); + msg.setRecipients(Message.RecipientType.TO, recipient); + msg.setSubject(subject); + msg.setText(body, "UTF-8", "html"); + Transport.send(msg, emailConfig.getUserName(), emailConfig.getPassword()); + } catch (MessagingException mex) { + LOGGER.error("send mail failed", mex); + } + } + + private class SimpleAuthenticator extends Authenticator { + } +} diff --git a/core/src/main/java/com/localeat/commons/GenericBuilder.java b/core/src/main/java/com/localeat/core/commons/GenericBuilder.java similarity index 100% rename from core/src/main/java/com/localeat/commons/GenericBuilder.java rename to core/src/main/java/com/localeat/core/commons/GenericBuilder.java diff --git a/core/src/main/java/com/localeat/core/config/email/EmailConfig.java b/core/src/main/java/com/localeat/core/config/email/EmailConfig.java new file mode 100644 index 0000000..51b3e0c --- /dev/null +++ b/core/src/main/java/com/localeat/core/config/email/EmailConfig.java @@ -0,0 +1,64 @@ +package com.localeat.core.config.email; + +import org.springframework.boot.context.properties.ConfigurationProperties; + +import java.util.Properties; + +@ConfigurationProperties("localeat.smtp") +public class EmailProperties { + private boolean authentication; + private boolean startTls; + private String host; + private String port; + private String sslTrust; + + public boolean isAuthentication() { + return authentication; + } + + public void setAuthentication(boolean authentication) { + this.authentication = authentication; + } + + public boolean isStartTls() { + return startTls; + } + + public void setStartTls(boolean startTls) { + this.startTls = startTls; + } + + public String getHost() { + return host; + } + + public void setHost(String host) { + this.host = host; + } + + public String getPort() { + return port; + } + + public void setPort(String port) { + this.port = port; + } + + public String getSslTrust() { + return sslTrust; + } + + public void setSslTrust(String sslTrust) { + this.sslTrust = sslTrust; + } + + public Properties getProperties() { + var properties = new Properties(); + properties.put("mail.smtp.auth", authentication); + properties.put("mail.smtp.starttls.enable", startTls); + properties.put("mail.smtp.host", host); + properties.put("mail.smtp.port", port); + properties.put("mail.smtp.ssl.trust", sslTrust); + return properties; + } +} diff --git a/core/src/main/java/com/localeat/core/domains/actor/BreederRepository.java b/core/src/main/java/com/localeat/core/domains/actor/BreederRepository.java new file mode 100644 index 0000000..654f73e --- /dev/null +++ b/core/src/main/java/com/localeat/core/domains/actor/BreederRepository.java @@ -0,0 +1,4 @@ +package com.localeat.core.domains.actor; + +public interface BreederRepository { +} diff --git a/core/src/main/java/com/localeat/core/domains/order/OrderNotificationService.java b/core/src/main/java/com/localeat/core/domains/order/OrderNotificationService.java new file mode 100644 index 0000000..1596095 --- /dev/null +++ b/core/src/main/java/com/localeat/core/domains/order/OrderNotificationService.java @@ -0,0 +1,4 @@ +package com.localeat.core.domains.order; + +public class OrderNotificationService { +} diff --git a/core/src/main/java/com/localeat/core/domains/security/PasswordRenewalController.java b/core/src/main/java/com/localeat/core/domains/security/PasswordRenewalController.java new file mode 100644 index 0000000..5e8872b --- /dev/null +++ b/core/src/main/java/com/localeat/core/domains/security/PasswordRenewalController.java @@ -0,0 +1,4 @@ +package com.localeat.core.domains.security; + +public class PasswordRenewalController { +} diff --git a/core/src/test/java/com/localeat/core/commons/TestEmailController.java b/core/src/test/java/com/localeat/core/commons/TestEmailController.java new file mode 100644 index 0000000..01c8259 --- /dev/null +++ b/core/src/test/java/com/localeat/core/commons/TestEmailController.java @@ -0,0 +1,4 @@ +package com.localeat.core.commons; + +public class TestEmailController { +} diff --git a/core/src/test/java/com/localeat/core/domains/order/TestOrderNotificationService.java b/core/src/test/java/com/localeat/core/domains/order/TestOrderNotificationService.java new file mode 100644 index 0000000..32b8a2a --- /dev/null +++ b/core/src/test/java/com/localeat/core/domains/order/TestOrderNotificationService.java @@ -0,0 +1,4 @@ +package com.localeat.core.domains.order; + +public class TestOrderNotificationService { +} diff --git a/core/src/test/java/com/localeat/core/domains/security/TestPasswordRenewalController.java b/core/src/test/java/com/localeat/core/domains/security/TestPasswordRenewalController.java new file mode 100644 index 0000000..724cf98 --- /dev/null +++ b/core/src/test/java/com/localeat/core/domains/security/TestPasswordRenewalController.java @@ -0,0 +1,4 @@ +package com.localeat.core.domains.security; + +public class TestPasswordRenewalController { +}