Commit e7677e5f authored by Peter Harrison's avatar Peter Harrison

Added extra detail when there is a null pointer in a Execution.

Added Secure Email Option
Added Security to Board Controller.
parent 67798215
......@@ -318,11 +318,12 @@
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.20</version>
</dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.23</version>
</dependency>
<dependency>
<groupId>org.apache.velocity</groupId>
......
......@@ -21,6 +21,8 @@
package nz.net.orcon.kanban.automation.actions;
import java.util.Properties;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -31,7 +33,14 @@ public class EmailSenderAction {
private static final Logger logger = LoggerFactory.getLogger(EmailSenderAction.class);
public void sendEmail(String subject, String emailBody, String to, String bcc, String from, String replyTo,String host){
public void sendEmail(String subject,
String emailBody,
String to,
String bcc,
String from,
String replyTo,
String host){
SimpleMailMessage mailMessage = new SimpleMailMessage();
JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
mailSender.setHost(host);
......@@ -59,5 +68,57 @@ public class EmailSenderAction {
mailSender.send(mailMessage);
logger.info("Email Message has been sent..");
}
public void sendSecureEmail(String subject,
String emailBody,
String to,
String bcc,
String from,
String replyTo,
String host,
String password){
SimpleMailMessage mailMessage = new SimpleMailMessage();
JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
mailSender.setHost(host);
mailSender.setPort(587);
mailSender.setProtocol("smtp");
Properties props = new Properties();
props.put("mail.smtp.starttls.enable","true");
props.put("mail.smtp.auth", "true");
mailSender.setJavaMailProperties(props);
if(StringUtils.isNotBlank(to)){
mailMessage.setTo(to);
}
if(StringUtils.isNotBlank(bcc)){
mailMessage.setBcc(bcc);
}
if(StringUtils.isNotBlank(from)){
mailMessage.setFrom(from);
mailSender.setUsername(from);
}
if(StringUtils.isNotBlank(password)){
mailSender.setPassword(password);
}
if(StringUtils.isNotBlank(replyTo)){
mailMessage.setReplyTo(replyTo);
}
if(StringUtils.isNotBlank(subject)){
mailMessage.setSubject(subject);
}
mailMessage.setText(emailBody);
mailSender.send(mailMessage);
logger.info("Secure Email Message has been sent..");
}
}
......@@ -82,7 +82,8 @@ public class ResourceController {
public @ResponseBody void createResource(@PathVariable String resourceId,
@RequestBody String value) throws Exception {
logger.info("Saving Resource " + resourceId);
logger.info("Saving Resource " + resourceId);
logger.info("Resource Text: " + value);
ObjectContentManager ocm = ocmFactory.getOcm();
Node node = ocm.getSession().getNode(String.format(URI.RESOURCE_URI, ""));
......
......@@ -108,7 +108,7 @@
<bean id="createVariableAction" class="nz.net.orcon.kanban.automation.actions.CreateVariableAction"/>
<!--
<!--
<bean id="bulletinAdvancedEndpoint"
class="nz.net.orcon.kanban.automation.actions.BulletinAdvancedSmsEndpoint">
<property name="user" value="${bulletin.username}" />
......@@ -118,7 +118,7 @@
<property name="rateCode" value="${bulletin.ratecode}" />
<property name="base64" ref="stringEncryptor" />
</bean>
-->
-->
<bean id="messageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory" />
......
......@@ -22,6 +22,7 @@
package nz.net.orcon.kanban.automation.actions;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
public class EmailSenderActionIT {
......@@ -34,8 +35,22 @@ public class EmailSenderActionIT {
}
@Test
@Ignore
public void testSendEmail(){
emailSenderAction.sendEmail("subject", "emailBody", "peter.harrison@email.com", null,"gravity@gravity.devcentre.org","gravity@gravity.devcentre.org","mail.server");
}
@Test
public void testSendSecureEmail(){
emailSenderAction.sendSecureEmail("Test Email",
"Welcome to the Twilight Zone",
"cheetah100@gmail.com",
null,
"cheetah100@devcentre.org",
"cheetah100@devcentre.org",
"mail.devcentre.org",
"turf7219");
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment