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 @@ ...@@ -318,11 +318,12 @@
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.freemarker</groupId> <groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId> <artifactId>freemarker</artifactId>
<version>2.3.20</version> <version>2.3.23</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.velocity</groupId> <groupId>org.apache.velocity</groupId>
......
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
package nz.net.orcon.kanban.automation.actions; package nz.net.orcon.kanban.automation.actions;
import java.util.Properties;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -31,7 +33,14 @@ public class EmailSenderAction { ...@@ -31,7 +33,14 @@ public class EmailSenderAction {
private static final Logger logger = LoggerFactory.getLogger(EmailSenderAction.class); 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(); SimpleMailMessage mailMessage = new SimpleMailMessage();
JavaMailSenderImpl mailSender = new JavaMailSenderImpl(); JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
mailSender.setHost(host); mailSender.setHost(host);
...@@ -59,5 +68,57 @@ public class EmailSenderAction { ...@@ -59,5 +68,57 @@ public class EmailSenderAction {
mailSender.send(mailMessage); mailSender.send(mailMessage);
logger.info("Email Message has been sent.."); 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 { ...@@ -82,7 +82,8 @@ public class ResourceController {
public @ResponseBody void createResource(@PathVariable String resourceId, public @ResponseBody void createResource(@PathVariable String resourceId,
@RequestBody String value) throws Exception { @RequestBody String value) throws Exception {
logger.info("Saving Resource " + resourceId); logger.info("Saving Resource " + resourceId);
logger.info("Resource Text: " + value);
ObjectContentManager ocm = ocmFactory.getOcm(); ObjectContentManager ocm = ocmFactory.getOcm();
Node node = ocm.getSession().getNode(String.format(URI.RESOURCE_URI, "")); Node node = ocm.getSession().getNode(String.format(URI.RESOURCE_URI, ""));
......
...@@ -108,7 +108,7 @@ ...@@ -108,7 +108,7 @@
<bean id="createVariableAction" class="nz.net.orcon.kanban.automation.actions.CreateVariableAction"/> <bean id="createVariableAction" class="nz.net.orcon.kanban.automation.actions.CreateVariableAction"/>
<!-- <!--
<bean id="bulletinAdvancedEndpoint" <bean id="bulletinAdvancedEndpoint"
class="nz.net.orcon.kanban.automation.actions.BulletinAdvancedSmsEndpoint"> class="nz.net.orcon.kanban.automation.actions.BulletinAdvancedSmsEndpoint">
<property name="user" value="${bulletin.username}" /> <property name="user" value="${bulletin.username}" />
...@@ -118,7 +118,7 @@ ...@@ -118,7 +118,7 @@
<property name="rateCode" value="${bulletin.ratecode}" /> <property name="rateCode" value="${bulletin.ratecode}" />
<property name="base64" ref="stringEncryptor" /> <property name="base64" ref="stringEncryptor" />
</bean> </bean>
--> -->
<bean id="messageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory" /> <bean id="messageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory" />
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
package nz.net.orcon.kanban.automation.actions; package nz.net.orcon.kanban.automation.actions;
import org.junit.Before; import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
public class EmailSenderActionIT { public class EmailSenderActionIT {
...@@ -34,8 +35,22 @@ public class EmailSenderActionIT { ...@@ -34,8 +35,22 @@ public class EmailSenderActionIT {
} }
@Test @Test
@Ignore
public void testSendEmail(){ public void testSendEmail(){
emailSenderAction.sendEmail("subject", "emailBody", "peter.harrison@email.com", null,"gravity@gravity.devcentre.org","gravity@gravity.devcentre.org","mail.server"); 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