From f7d58f2a13b23b36d861faa95e66a96fb4bd1dbb Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Wed, 3 Aug 2016 10:33:01 +0500 Subject: - Optimized SSL connection - Added "mail.smtp.ssl.trust" parameter --- src/org/traccar/notification/NotificationMail.java | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'src/org/traccar') diff --git a/src/org/traccar/notification/NotificationMail.java b/src/org/traccar/notification/NotificationMail.java index 944200f2f..bc7f6d4da 100644 --- a/src/org/traccar/notification/NotificationMail.java +++ b/src/org/traccar/notification/NotificationMail.java @@ -48,14 +48,11 @@ public final class NotificationMail { result.put("mail.smtp.port", config.getString("mail.smtp.port", "25")); if (config.getBoolean("mail.smtp.starttls.enable")) { - result.put("mail.smtp.starttls.enable", - config.getBoolean("mail.smtp.starttls.enable")); + result.put("mail.smtp.starttls.enable", config.getBoolean("mail.smtp.starttls.enable")); } else if (config.getBoolean("mail.smtp.ssl.enable")) { - result.put("mail.smtp.socketFactory.port", - result.getProperty("mail.smtp.port")); - result.put("mail.smtp.socketFactory.class", - "javax.net.ssl.SSLSocketFactory"); + result.put("mail.smtp.ssl.enable", config.getBoolean("mail.smtp.ssl.enable")); } + result.put("mail.smtp.ssl.trust", config.getBoolean("mail.smtp.ssl.trust")); result.put("mail.smtp.auth", config.getBoolean("mail.smtp.auth")); result.put("mail.smtp.user", config.getString("mail.smtp.username", null)); @@ -77,12 +74,10 @@ public final class NotificationMail { result.put("mail.smtp.starttls.enable", tls); } else if (object.getAttributes().containsKey("mail.smtp.ssl.enable")) { boolean ssl = Boolean.parseBoolean((String) object.getAttributes().get("mail.smtp.ssl.enable")); - if (ssl) { - result.put("mail.smtp.socketFactory.port", - result.getProperty("mail.smtp.port")); - result.put("mail.smtp.socketFactory.class", - "javax.net.ssl.SSLSocketFactory"); - } + result.put("mail.smtp.ssl.enable", ssl); + } + if (object.getAttributes().containsKey("mail.smtp.ssl.trust")) { + result.put("mail.smtp.ssl.trust", object.getAttributes().get("mail.smtp.ssl.trust")); } boolean auth = Boolean.parseBoolean((String) object.getAttributes().get("mail.smtp.auth")); result.put("mail.smtp.auth", auth); -- cgit v1.2.3 From 2498caf8e965c25e4c177a8a075f37b8937c8be3 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Wed, 3 Aug 2016 12:31:57 +0500 Subject: Fix mail session creating --- src/org/traccar/notification/NotificationMail.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/org/traccar') diff --git a/src/org/traccar/notification/NotificationMail.java b/src/org/traccar/notification/NotificationMail.java index bc7f6d4da..a0b80d2ab 100644 --- a/src/org/traccar/notification/NotificationMail.java +++ b/src/org/traccar/notification/NotificationMail.java @@ -112,7 +112,7 @@ public final class NotificationMail { return; } } - mailSession = Session.getDefaultInstance(mailServerProperties, null); + mailSession = Session.getInstance(mailServerProperties, null); mailMessage = new MimeMessage(mailSession); -- cgit v1.2.3 From c2851143d996e8ae1741adb1b6f20cc7e447f327 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Wed, 3 Aug 2016 22:48:01 +0800 Subject: Fix Tzone frame decoder (fix #2183) --- src/org/traccar/protocol/TzoneProtocol.java | 2 +- test/org/traccar/protocol/TzoneProtocolDecoderTest.java | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'src/org/traccar') diff --git a/src/org/traccar/protocol/TzoneProtocol.java b/src/org/traccar/protocol/TzoneProtocol.java index 2d98e3f79..fcf673a57 100644 --- a/src/org/traccar/protocol/TzoneProtocol.java +++ b/src/org/traccar/protocol/TzoneProtocol.java @@ -34,7 +34,7 @@ public class TzoneProtocol extends BaseProtocol { serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { - pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(256, 2, 2)); + pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(256, 2, 2, 2, 0)); pipeline.addLast("objectDecoder", new TzoneProtocolDecoder(TzoneProtocol.this)); } }); diff --git a/test/org/traccar/protocol/TzoneProtocolDecoderTest.java b/test/org/traccar/protocol/TzoneProtocolDecoderTest.java index 8d60bdfe4..2ae776f36 100644 --- a/test/org/traccar/protocol/TzoneProtocolDecoderTest.java +++ b/test/org/traccar/protocol/TzoneProtocolDecoderTest.java @@ -11,6 +11,12 @@ public class TzoneProtocolDecoderTest extends ProtocolTest { TzoneProtocolDecoder decoder = new TzoneProtocolDecoder(new TzoneProtocol()); + verifyPosition(decoder, binary( + "545a00582424010b022000000860041028904798100803030c2700160a007da96203356669100803030c2700000000000e000004002813730010aa4000000617017100000000000080000000000000000000000000000000007701fe0d0a")); + + verifyPosition(decoder, binary( + "545a00582424010b022000000860041028904798100803030d1a001609007da9620335666a100803030d1900000000000e000004002813730010aa400000063701720000000000008000000000000000000000000000000000787f0c0d0a")); + verifyPosition(decoder, binary( "545a00582424010b021e000008637710239476270f080b0a3228001600000000000000000000000000000000000000000000000401a00822001088c00020183701a6053800000000800000000000000000000000000000000077c9860d0a"), position("1999-11-30 00:00:00.000", false, 0.0, 0.0)); -- cgit v1.2.3 From b6f82f2b3894df234d528a5feb303f81d3620259 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Thu, 4 Aug 2016 06:52:17 +0300 Subject: Fix Gator frame decoder params --- src/org/traccar/protocol/GatorProtocol.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/org/traccar') diff --git a/src/org/traccar/protocol/GatorProtocol.java b/src/org/traccar/protocol/GatorProtocol.java index 3776bcfd3..3d899fa1f 100644 --- a/src/org/traccar/protocol/GatorProtocol.java +++ b/src/org/traccar/protocol/GatorProtocol.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 Anton Tananaev (anton.tananaev@gmail.com) + * Copyright 2015 - 2016 Anton Tananaev (anton.tananaev@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,7 +35,7 @@ public class GatorProtocol extends BaseProtocol { serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { - pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1024, 3, 2, 1, 0)); + pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1024, 3, 2)); pipeline.addLast("objectDecoder", new GatorProtocolDecoder(GatorProtocol.this)); } }); -- cgit v1.2.3 From 870da4a100bedf1c21e43d6ab708de5c6a023c94 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Thu, 4 Aug 2016 10:45:26 +0500 Subject: Fix NullPointer exception without 'mail.smtp.username' in config. --- src/org/traccar/notification/NotificationMail.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'src/org/traccar') diff --git a/src/org/traccar/notification/NotificationMail.java b/src/org/traccar/notification/NotificationMail.java index a0b80d2ab..f9d42968f 100644 --- a/src/org/traccar/notification/NotificationMail.java +++ b/src/org/traccar/notification/NotificationMail.java @@ -55,9 +55,19 @@ public final class NotificationMail { result.put("mail.smtp.ssl.trust", config.getBoolean("mail.smtp.ssl.trust")); result.put("mail.smtp.auth", config.getBoolean("mail.smtp.auth")); - result.put("mail.smtp.user", config.getString("mail.smtp.username", null)); - result.put("mail.smtp.password", config.getString("mail.smtp.password", null)); - result.put("mail.smtp.from", config.getString("mail.smtp.from", null)); + + String username = config.getString("mail.smtp.username"); + if (username != null) { + result.put("mail.smtp.user", username); + } + String password = config.getString("mail.smtp.password"); + if (password != null) { + result.put("mail.smtp.password", password); + } + String from = config.getString("mail.smtp.from"); + if (from != null) { + result.put("mail.smtp.from", from); + } } return result; } -- cgit v1.2.3