Skip to content

Commit

Permalink
Merge pull request #5 from DirectProjectJavaRI/develop
Browse files Browse the repository at this point in the history
Releasing 8.0.0
  • Loading branch information
Greg Meyer authored Aug 3, 2021
2 parents 509cb6a + 86f68a4 commit d90c0eb
Show file tree
Hide file tree
Showing 18 changed files with 320 additions and 309 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@
hs_err_pid*
/.classpath
/.project
/target/
101 changes: 54 additions & 47 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.nhind</groupId>
<artifactId>direct-smtp-mq-gateway</artifactId>
<version>6.0</version>
<version>8.0.0</version>
<packaging>jar</packaging>
<name>DirectProject Java RI Lightweight SMTP Server Gateway Standalone Spring Boot Micro-service Application</name>
<description>DirectProject Java RI Lightweight SMTP Server Gateway Standalone Spring Boot Micro-service Application</description>
Expand All @@ -13,13 +13,14 @@
<connection>scm:git:https://github.com/DirectProject/nhin-d.git</connection>
</scm>
<prerequisites>
<maven>3.0.0</maven>
<maven>3.5.0</maven>
</prerequisites>
<parent>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.9.RELEASE</version>
</parent>
<version>2.5.2</version>
<relativePath />
</parent>
<developers>
<developer>
<name>Greg Meyer</name>
Expand All @@ -30,7 +31,6 @@
</roles>
</developer>
</developers>

<licenses>
<license>
<name>New BSD License</name>
Expand All @@ -39,27 +39,29 @@
</licenses>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<subethasmtp.version>3.1.7</subethasmtp.version>
<commons-net.version>3.8.0</commons-net.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.1.9.RELEASE</version>
<version>2.5.2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>io.pivotal.spring.cloud</groupId>
<artifactId>spring-cloud-services-dependencies</artifactId>
<version>2.1.4.RELEASE</version>
<version>3.3.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-parent</artifactId>
<version>Greenwich.SR3</version>
<version>2020.0.3</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down Expand Up @@ -105,21 +107,37 @@
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-stream-rabbit</artifactId>
</dependency>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<!-- Needed for unit testing function spring cloud streams -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream</artifactId>
<type>test-jar</type>
<scope>test</scope>
<classifier>test-binder</classifier>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>org.nhind</groupId>
<artifactId>direct-common</artifactId>
<version>6.0.1</version>
<version>8.0.0</version>
</dependency>
<dependency>
<groupId>org.subethamail</groupId>
<artifactId>subethasmtp</artifactId>
<version>3.1.7</version>
<version>${subethasmtp.version}</version>
<exclusions>
<exclusion>
<artifactId>mail</artifactId>
Expand All @@ -130,13 +148,8 @@
<dependency>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>
<version>3.6</version>
<version>${commons-net.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-test-support</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down Expand Up @@ -186,27 +199,21 @@
</jvmArguments>
</configuration>
</plugin>
<!-- for releases only
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<configuration>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<additionalJOption>-Xdoclint:none</additionalJOption>
<charset>UTF-8</charset>
<docencoding>UTF-8</docencoding>
<docfilessubdirs>true</docfilessubdirs>
<detectJavaApiLink>true</detectJavaApiLink>
<detectLinks>true</detectLinks>
<source>1.8</source>
<show>public</show>
</configuration>
<executions>
<execution>
<phase>package</phase>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<show>public</show>
</configuration>
</plugin>
<!-- for releases only
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
Expand All @@ -219,6 +226,7 @@
</goals>
</execution>
</executions>
<version>3.0.1</version>
</plugin>
-->
</plugins>
Expand All @@ -228,22 +236,21 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.9</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.0.1</version>
<configuration>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<additionalJOption>-Xdoclint:none</additionalJOption>
<charset>UTF-8</charset>
<docencoding>UTF-8</docencoding>
<docfilessubdirs>true</docfilessubdirs>
<detectJavaApiLink>true</detectJavaApiLink>
<detectLinks>true</detectLinks>
<source>1.8</source>
<show>protected</show>
</configuration>
</plugin>
<show>public</show>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
Expand All @@ -258,11 +265,11 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>3.1.1</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>1.2</version>
<configuration>
<effort>Max</effort>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.nhindirect.smtpmq.gateway.boot;

import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.WebApplicationType;
Expand All @@ -15,9 +14,6 @@
@EnableScheduling
public class SmtpGatewayApplication implements CommandLineRunner
{
@Autowired
protected ConnectionFactory connectionFactory;

@Autowired
protected SMTPServer smtpServer;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,16 @@
import org.apache.commons.io.input.CountingInputStream;
import org.nhindirect.common.mail.SMTPMailMessage;
import org.nhindirect.smtpmq.gateway.streams.SmtpGatewayMessageSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.StringUtils;
import org.subethamail.smtp.MessageHandler;
import org.subethamail.smtp.RejectException;
import org.subethamail.smtp.TooMuchDataException;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class SMTPMessageHandler implements MessageHandler
{
private static final Logger LOGGER = LoggerFactory.getLogger(SMTPMessageHandler.class);

protected SmtpGatewayMessageSource messageSource;
protected GetMessageHeaderStream getMessageHeaderStream;
protected SizeLimitedStreamCreator sizeLimitedStreamCreator;
Expand All @@ -54,15 +53,15 @@ public void from(String from) throws RejectException
{
try
{
if (!StringUtils.isEmpty(from))
if (StringUtils.hasText(from))
{
this.from = new InternetAddress(from);

// handle "<>" scenario
if (StringUtils.isEmpty(this.from.getAddress()))
if (!StringUtils.hasText(this.from.getAddress()))
{
this.from = null;
LOGGER.info("blank address... mailFrom will be null");
log.info("blank address... mailFrom will be null");
}

}
Expand All @@ -86,7 +85,7 @@ public void recipient(String recipient) throws RejectException
catch (AddressException e)
{
String errorMessage = "error parsing recipient address " + recipient;
LOGGER.error(errorMessage, e);
log.error(errorMessage, e);
throw new RejectException(errorMessage);
}

Expand Down Expand Up @@ -131,7 +130,7 @@ protected void updateMessageID() throws MessagingException
* 552 - Requested mail action aborted: exceeded storage allocation
*/
errorMessage += ": " + e.getCause().getMessage();
LOGGER.error(errorMessage, e);
log.error(errorMessage, e);
throw new RejectException(552, errorMessage);
}
else
Expand All @@ -140,7 +139,7 @@ protected void updateMessageID() throws MessagingException
* RFC821:
* Service not available, closing transmission channel [This may be a reply to any command if the service knows it must shut down]
*/
LOGGER.error(errorMessage, e);
log.error(errorMessage, e);
throw new RejectException(421, errorMessage);
}
}
Expand All @@ -152,15 +151,15 @@ protected void updateMessageID() throws MessagingException
messageId = mimeMessage.getMessageID();
messageSource.forwardSMTPMessage(mailMessage);

LOGGER.info("successfully sent message with message id {} ({} bytes)", messageId, countingInputStream.getByteCount());
log.info("successfully sent message with message id {} ({} bytes)", messageId, countingInputStream.getByteCount());
}
catch (Throwable e)
{
/*
* RFC821:
* Transaction failed
*/
LOGGER.error("error sending message with message id " + messageId, e);
log.error("error sending message with message id " + messageId, e);
throw new RejectException(554, "Error sending message: " + e.getMessage());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class SMTPServerBeanConfig
private int maxMessageSize;


@Value("#{'${direct.smtpmqgateway.clientwhitelist.cidr:}'.split(',')}")
@Value("${direct.smtpmqgateway.clientwhitelist.cidr:}")
private List<String> clientWhitelistCidrs;

@Autowired
Expand All @@ -65,7 +65,7 @@ public MessageHandler create(MessageContext ctx)
protected ServerSocket createServerSocket() throws IOException
{
if (clientWhitelistCidrs.isEmpty() ||
(clientWhitelistCidrs.size() == 1 && StringUtils.isEmpty(clientWhitelistCidrs.get(0))))
(clientWhitelistCidrs.size() == 1 && !StringUtils.hasText(clientWhitelistCidrs.get(0))))
return super.createServerSocket();

InetSocketAddress isa;
Expand Down

This file was deleted.

Loading

0 comments on commit d90c0eb

Please sign in to comment.