From c92a4f6baca6f4a7457667fff75c826f715c657e Mon Sep 17 00:00:00 2001
From: Jens Eliasson <jens.eliasson@gmail.com>
Date: Wed, 12 May 2021 15:01:11 +0200
Subject: [PATCH 01/53] started the TimeManager system

---
 .../eu/arrowhead/common/CommonConstants.java  |   8 +-
 .../java/eu/arrowhead/common/Defaults.java    |   1 +
 .../eu/arrowhead/common/core/CoreSystem.java  |   4 +-
 .../common/core/CoreSystemService.java        |   3 +
 .../shared/TimeManagerTimeResponseDTO.java    |  21 +++
 pom.xml                                       |   1 +
 scripts/create_arrowhead_tables.sql           |   2 +
 scripts/create_empty_arrowhead_db.sql         |   5 +
 scripts/start_coresystems.bat                 |   4 +
 scripts/start_coresystems.sh                  |   4 +
 scripts/stop_coresystems.bat                  |   2 +
 scripts/stop_coresystems.sh                   |   2 +
 scripts/timemanager_privileges.sql            |   9 ++
 timemanager/documentation/Readme.txt          |   6 +
 timemanager/pom.xml                           | 135 ++++++++++++++++++
 .../src/deb/arrowhead-timemanager.service     |  14 ++
 timemanager/src/deb/control/config            |  20 +++
 timemanager/src/deb/control/control           |  10 ++
 timemanager/src/deb/control/postinst          |  95 ++++++++++++
 timemanager/src/deb/control/postrm            |  55 +++++++
 timemanager/src/deb/control/preinst           |  35 +++++
 timemanager/src/deb/control/prerm             |  45 ++++++
 .../TimeManagerApplicationInitListener.java   |  37 +++++
 .../timemanager/TimeManagerController.java    | 126 ++++++++++++++++
 .../core/timemanager/TimeManagerMain.java     |  40 ++++++
 .../service/TimeManagerDBService.java         |  76 ++++++++++
 .../TimemanagerAccessControlFilter.java       |  78 ++++++++++
 .../security/TimemanagerSecurityConfig.java   |  24 ++++
 .../core/timemanager/service/TimeService.java |  57 ++++++++
 .../swagger/TimemanagerSwaggerConfig.java     |  41 ++++++
 ...itional-spring-configuration-metadata.json |  27 ++++
 .../src/main/resources/application.properties |  60 ++++++++
 .../resources/certificates/truststore.p12     | Bin 0 -> 1162 bytes
 timemanager/src/main/resources/log4j2.xml     |  46 ++++++
 .../main/resources/swagger/swagger-ui.html    |  75 ++++++++++
 .../StandaloneModeInTimeManagerTests.java     |   9 ++
 .../TimeManagerControllerSystemTest.java      |  87 +++++++++++
 .../timemanager/TimeManagerTestContext.java   |  32 +++++
 38 files changed, 1294 insertions(+), 2 deletions(-)
 create mode 100644 core-common/src/main/java/eu/arrowhead/common/dto/shared/TimeManagerTimeResponseDTO.java
 create mode 100644 scripts/timemanager_privileges.sql
 create mode 100644 timemanager/documentation/Readme.txt
 create mode 100644 timemanager/pom.xml
 create mode 100644 timemanager/src/deb/arrowhead-timemanager.service
 create mode 100644 timemanager/src/deb/control/config
 create mode 100644 timemanager/src/deb/control/control
 create mode 100644 timemanager/src/deb/control/postinst
 create mode 100644 timemanager/src/deb/control/postrm
 create mode 100644 timemanager/src/deb/control/preinst
 create mode 100644 timemanager/src/deb/control/prerm
 create mode 100644 timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeManagerApplicationInitListener.java
 create mode 100644 timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeManagerController.java
 create mode 100644 timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeManagerMain.java
 create mode 100644 timemanager/src/main/java/eu/arrowhead/core/timemanager/database/service/TimeManagerDBService.java
 create mode 100644 timemanager/src/main/java/eu/arrowhead/core/timemanager/security/TimemanagerAccessControlFilter.java
 create mode 100644 timemanager/src/main/java/eu/arrowhead/core/timemanager/security/TimemanagerSecurityConfig.java
 create mode 100644 timemanager/src/main/java/eu/arrowhead/core/timemanager/service/TimeService.java
 create mode 100644 timemanager/src/main/java/eu/arrowhead/core/timemanager/swagger/TimemanagerSwaggerConfig.java
 create mode 100644 timemanager/src/main/resources/META-INF/additional-spring-configuration-metadata.json
 create mode 100644 timemanager/src/main/resources/application.properties
 create mode 100644 timemanager/src/main/resources/certificates/truststore.p12
 create mode 100644 timemanager/src/main/resources/log4j2.xml
 create mode 100644 timemanager/src/main/resources/swagger/swagger-ui.html
 create mode 100644 timemanager/src/test/java/eu/arrowhead/core/timemanager/StandaloneModeInTimeManagerTests.java
 create mode 100644 timemanager/src/test/java/eu/arrowhead/core/timemanager/TimeManagerControllerSystemTest.java
 create mode 100644 timemanager/src/test/java/eu/arrowhead/core/timemanager/TimeManagerTestContext.java

diff --git a/core-common/src/main/java/eu/arrowhead/common/CommonConstants.java b/core-common/src/main/java/eu/arrowhead/common/CommonConstants.java
index fe5d07155..0a9230118 100644
--- a/core-common/src/main/java/eu/arrowhead/common/CommonConstants.java
+++ b/core-common/src/main/java/eu/arrowhead/common/CommonConstants.java
@@ -33,6 +33,7 @@ public class CommonConstants {
 	public static final String CORE_SYSTEM_CHOREOGRAPHER = "Choreographer";
 	public static final String CORE_SYSTEM_EVENT_HANDLER = "Event Handler";
 	public static final String CORE_SYSTEM_DATAMANAGER  = "DataManager";
+	public static final String CORE_SYSTEM_TIMEMANAGER  = "TimeManager";
 	public static final String CORE_SYSTEM_GATEKEEPER = "Gatekeeper";
 	public static final String CORE_SYSTEM_GATEWAY = "Gateway";
 	public static final String CORE_SYSTEM_ORCHESTRATOR = "Orchestrator";
@@ -76,6 +77,8 @@ public class CommonConstants {
 	public static final String CORE_SERVICE_DATAMANAGER_PROXY = "proxy";
 	public static final String CORE_SERVICE_DATAMANAGER_HISTORIAN = "historian";
 
+	public static final String CORE_SERVICE_TIMEMANAGER_TIME = "time";
+
 	public static final String CORE_SERVICE_CHOREOGRAPHER_PROCESS = "choreographer-service";
 
 	public static final String CORE_SERVICE_CERTIFICATE_AUTHORITY_SIGN = "ca-sign";
@@ -255,6 +258,9 @@ public class CommonConstants {
 	public static final String OP_DATAMANAGER_PROXY = "/proxy";
 	public static final String OP_DATAMANAGER_HISTORIAN = "/historian";
 
+	public static final String TIMEMANAGER_URI = "/timemanager";
+	public static final String OP_TIMEMANAGER_TIME = "/time";
+
     public static final String TRANSLATOR_URI = "/translator";
     public static final String OP_TRANSLATOR_FIWARE_URI = "/v2";
     public static final String OP_TRANSLATOR_PLUGIN_URI = "/plugin";
@@ -273,7 +279,7 @@ public class CommonConstants {
 	
 	public static final List<CoreSystemService> PUBLIC_CORE_SYSTEM_SERVICES = List.of(CoreSystemService.ORCHESTRATION_SERVICE, CoreSystemService.AUTH_PUBLIC_KEY_SERVICE,
   			  																		  CoreSystemService.EVENT_PUBLISH_SERVICE, CoreSystemService.EVENT_SUBSCRIBE_SERVICE, CoreSystemService.EVENT_UNSUBSCRIBE_SERVICE, 
-																					  CoreSystemService.PROXY_SERVICE, CoreSystemService.HISTORIAN_SERVICE, CoreSystemService.CHOREOGRAPHER_SERVICE, CoreSystemService.TRANSLATOR_SERVICE);
+																					  CoreSystemService.PROXY_SERVICE, CoreSystemService.TIME_SERVICE, CoreSystemService.HISTORIAN_SERVICE, CoreSystemService.CHOREOGRAPHER_SERVICE, CoreSystemService.TRANSLATOR_SERVICE);
 	
 	public static final String HTTP_CLIENT_CONNECTION_TIMEOUT = "http.client.connection.timeout";
 	public static final String $HTTP_CLIENT_CONNECTION_TIMEOUT_WD = "${" + HTTP_CLIENT_CONNECTION_TIMEOUT + ":" + Defaults.DEFAULT_CONNECTION_TIMEOUT + "}";
diff --git a/core-common/src/main/java/eu/arrowhead/common/Defaults.java b/core-common/src/main/java/eu/arrowhead/common/Defaults.java
index 01a3a25da..50cd74b41 100644
--- a/core-common/src/main/java/eu/arrowhead/common/Defaults.java
+++ b/core-common/src/main/java/eu/arrowhead/common/Defaults.java
@@ -37,6 +37,7 @@ public class Defaults {
 	public static final int DEFAULT_GATEWAY_PORT = 8453;
 	public static final int DEFAULT_EVENT_HANDLER_PORT = 8455;
 	public static final int DEFAULT_DATAMANAGER_PORT = 8461;
+	public static final int DEFAULT_TIMEMANAGER_PORT = 8463;
 	public static final int DEFAULT_CHOREOGRAPHER_PORT = 8457;
 	public static final int DEFAULT_CERTIFICATE_AUTHORITY_PORT = 8448;
 	public static final int DEFAULT_TRANSLATOR_PORT = 8462;
diff --git a/core-common/src/main/java/eu/arrowhead/common/core/CoreSystem.java b/core-common/src/main/java/eu/arrowhead/common/core/CoreSystem.java
index 3e8751a05..d8a2512fa 100644
--- a/core-common/src/main/java/eu/arrowhead/common/core/CoreSystem.java
+++ b/core-common/src/main/java/eu/arrowhead/common/core/CoreSystem.java
@@ -70,7 +70,9 @@ public enum CoreSystem {
 															   CoreSystemService.EVENT_UNSUBSCRIBE_SERVICE,
 															   CoreSystemService.EVENT_PUBLISH_AUTH_UPDATE_SERVICE)),
 
-        DATAMANAGER(Defaults.DEFAULT_DATAMANAGER_PORT, List.of(CoreSystemService.PROXY_SERVICE, CoreSystemService.HISTORIAN_SERVICE)),
+    DATAMANAGER(Defaults.DEFAULT_DATAMANAGER_PORT, List.of(CoreSystemService.PROXY_SERVICE, CoreSystemService.HISTORIAN_SERVICE)),
+
+	TIMEMANAGER(Defaults.DEFAULT_TIMEMANAGER_PORT, List.of(CoreSystemService.TIME_SERVICE)),
 	
 	GATEWAY(Defaults.DEFAULT_GATEWAY_PORT, List.of(CoreSystemService.GATEWAY_PUBLIC_KEY_SERVICE,
 												   CoreSystemService.GATEWAY_PROVIDER_SERVICE,
diff --git a/core-common/src/main/java/eu/arrowhead/common/core/CoreSystemService.java b/core-common/src/main/java/eu/arrowhead/common/core/CoreSystemService.java
index 276995195..d238f6b71 100644
--- a/core-common/src/main/java/eu/arrowhead/common/core/CoreSystemService.java
+++ b/core-common/src/main/java/eu/arrowhead/common/core/CoreSystemService.java
@@ -63,6 +63,9 @@ public enum CoreSystemService {
 	PROXY_SERVICE(CommonConstants.CORE_SERVICE_DATAMANAGER_PROXY, CommonConstants.DATAMANAGER_URI + CommonConstants.OP_DATAMANAGER_PROXY),
 	HISTORIAN_SERVICE(CommonConstants.CORE_SERVICE_DATAMANAGER_HISTORIAN, CommonConstants.DATAMANAGER_URI + CommonConstants.OP_DATAMANAGER_HISTORIAN),
 
+	// TimeManager services
+	TIME_SERVICE(CommonConstants.CORE_SERVICE_TIMEMANAGER_TIME, CommonConstants.TIMEMANAGER_URI + CommonConstants.OP_TIMEMANAGER_TIME),
+
 	// Translator services
 	TRANSLATOR_SERVICE(CommonConstants.CORE_SERVICE_TRANSLATOR, CommonConstants.TRANSLATOR_URI),
 	TRANSLATOR_FIWARE_SERVICE(CommonConstants.CORE_SERVICE_TRANSLATOR_FIWARE, CommonConstants.TRANSLATOR_URI + CommonConstants.OP_TRANSLATOR_FIWARE_URI),
diff --git a/core-common/src/main/java/eu/arrowhead/common/dto/shared/TimeManagerTimeResponseDTO.java b/core-common/src/main/java/eu/arrowhead/common/dto/shared/TimeManagerTimeResponseDTO.java
new file mode 100644
index 000000000..0406430c1
--- /dev/null
+++ b/core-common/src/main/java/eu/arrowhead/common/dto/shared/TimeManagerTimeResponseDTO.java
@@ -0,0 +1,21 @@
+package eu.arrowhead.common.dto.shared;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+public class TimeManagerTimeResponseDTO implements Serializable {
+
+        //=================================================================================================
+        // members
+        
+        private static final long serialVersionUID = 1248856742138137282L;
+        
+                
+        //=================================================================================================
+        // methods
+        
+        //-------------------------------------------------------------------------------------------------
+        public TimeManagerTimeResponseDTO() {}
+	
+}
diff --git a/pom.xml b/pom.xml
index 9953a89d4..7d102eccc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -30,6 +30,7 @@
 	    <module>orchestrator</module>
 	    <module>eventhandler</module>
 	    <module>datamanager</module>
+		<module>timemanager</module>
 	    <module>relay-library</module>
 	    <module>gatekeeper</module>
 	    <module>gateway</module>
diff --git a/scripts/create_arrowhead_tables.sql b/scripts/create_arrowhead_tables.sql
index 77c859f21..4df17bc11 100644
--- a/scripts/create_arrowhead_tables.sql
+++ b/scripts/create_arrowhead_tables.sql
@@ -351,6 +351,8 @@ CREATE TABLE IF NOT EXISTS `dmhist_entries` (
   CONSTRAINT `message_id_fk` FOREIGN KEY(`mid`) REFERENCES `dmhist_messages`(`id`) ON DELETE CASCADE
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
+-- TimeManager
+
 -- Choreographer
 
 CREATE TABLE IF NOT EXISTS `choreographer_plan` (
diff --git a/scripts/create_empty_arrowhead_db.sql b/scripts/create_empty_arrowhead_db.sql
index 9d62952b3..ff6d6edb2 100644
--- a/scripts/create_empty_arrowhead_db.sql
+++ b/scripts/create_empty_arrowhead_db.sql
@@ -47,6 +47,11 @@ CREATE USER IF NOT EXISTS 'datamanager'@'localhost' IDENTIFIED BY 'gRLjXbqu0YwYh
 CREATE USER IF NOT EXISTS 'datamanager'@'%' IDENTIFIED BY 'gRLjXbqu0YwYhfK';
 source datamanager_privileges.sql
 
+-- TimeManager
+CREATE USER IF NOT EXISTS 'timemanager'@'localhost' IDENTIFIED BY 'xyp2XEAu5Tbc41g';
+CREATE USER IF NOT EXISTS 'timemanager'@'%' IDENTIFIED BY 'xyp2XEAu5Tbc41g';
+source timemanager_privileges.sql
+
 -- Choreographer
 CREATE USER IF NOT EXISTS 'choreographer'@'localhost' IDENTIFIED BY 'Qa5yx4oBp4Y9RLX';
 CREATE USER IF NOT EXISTS 'choreographer'@'%' IDENTIFIED BY 'Qa5yx4oBp4Y9RLX';
diff --git a/scripts/start_coresystems.bat b/scripts/start_coresystems.bat
index 6a1206a57..5d2bd5372 100644
--- a/scripts/start_coresystems.bat
+++ b/scripts/start_coresystems.bat
@@ -28,6 +28,10 @@ cd ..\..\datamanager\target
 START "" /B "cmd /c javaw -jar arrowhead-datamanager-4.1.3.jar > sout_datamanager.log 2>&1"
 echo DataManager started
 
+cd ..\..\timemanager\target
+START "" /B "cmd /c javaw -jar arrowhead-timemanager-4.1.3.jar > sout_timemanager.log 2>&1"
+echo TimeManager started
+
 cd ..\..\gatekeeper\target
 START "" /B "cmd /c javaw -jar arrowhead-gatekeeper-4.2.0.jar > sout_gk.log 2>&1"
 echo Gatekeeper started
diff --git a/scripts/start_coresystems.sh b/scripts/start_coresystems.sh
index 1bdfe42c3..f4bcd55d4 100644
--- a/scripts/start_coresystems.sh
+++ b/scripts/start_coresystems.sh
@@ -28,6 +28,10 @@ cd ../../datamanager/target
 nohup java -jar $(find . -maxdepth 1 -name arrowhead-datamanager-\*.jar | sort | tail -n1) &> sout_datamanager.log &
 echo DataManager started
 
+cd ../../timemanager/target
+nohup java -jar $(find . -maxdepth 1 -name arrowhead-timemanager-\*.jar | sort | tail -n1) &> sout_timemanager.log &
+echo TimeManager started
+
 cd ../../gatekeeper/target
 nohup java -jar $(find . -maxdepth 1 -name arrowhead-gatekeeper-\*.jar | sort | tail -n1) &> sout_gk.log &
 echo Gatekeeper started
diff --git a/scripts/stop_coresystems.bat b/scripts/stop_coresystems.bat
index e1a1e5c2b..28e5d20a7 100644
--- a/scripts/stop_coresystems.bat
+++ b/scripts/stop_coresystems.bat
@@ -9,6 +9,7 @@ FOR /F "tokens=1" %%p in ('"jps -v | find "orchestrator""') DO taskkill /pid %%p
 FOR /F "tokens=1" %%p in ('"jps -v | find "gatekeeper""') DO taskkill /pid %%p > NUL 2>&1
 FOR /F "tokens=1" %%p in ('"jps -v | find "eventhandler""') DO taskkill /pid %%p > NUL 2>&1
 FOR /F "tokens=1" %%p in ('"jps -v | find "datamanager""') DO taskkill /pid %%p > NUL 2>&1
+FOR /F "tokens=1" %%p in ('"jps -v | find "timemanager""') DO taskkill /pid %%p > NUL 2>&1
 FOR /F "tokens=1" %%p in ('"jps -v | find "gateway""') DO taskkill /pid %%p > NUL 2>&1
 FOR /F "tokens=1" %%p in ('"jps -v | find "authorization""') DO taskkill /pid %%p > NUL 2>&1
 FOR /F "tokens=1" %%p in ('"jps -v | find "certificate""') DO taskkill /pid %%p > NUL 2>&1
@@ -28,6 +29,7 @@ IF "%STILL_THERE%"=="""" (
   FOR /F "tokens=1" %%p in ('"jps -v | find "gatekeeper""') DO taskkill /F /pid %%p
   FOR /F "tokens=1" %%p in ('"jps -v | find "eventhandler""') DO taskkill /F /pid %%p
   FOR /F "tokens=1" %%p in ('"jps -v | find "datamanager""') DO taskkill /F /pid %%p
+  FOR /F "tokens=1" %%p in ('"jps -v | find "timemanager""') DO taskkill /F /pid %%p
   FOR /F "tokens=1" %%p in ('"jps -v | find "gateway""') DO taskkill /F /pid %%p
   FOR /F "tokens=1" %%p in ('"jps -v | find "authorization""') DO taskkill /F /pid %%p
   FOR /F "tokens=1" %%p in ('"jps -v | find "certificate""') DO taskkill /F /pid %%p
diff --git a/scripts/stop_coresystems.sh b/scripts/stop_coresystems.sh
index 56716be19..6822e01aa 100644
--- a/scripts/stop_coresystems.sh
+++ b/scripts/stop_coresystems.sh
@@ -7,6 +7,7 @@ pkill -f gatekeeper
 pkill -f authorization
 pkill -f eventhandler
 pkill -f datamanager
+pkill -f timemanager
 pkill -f gateway
 pkill -f certificate-authority
 sleep 5s
@@ -21,6 +22,7 @@ then
   kill -KILL $(ps aux | grep 'authorization' | awk '{print $2}')
   kill -KILL $(ps aux | grep 'eventhandler' | awk '{print $2}')
   kill -KILL $(ps aux | grep 'datamanager' | awk '{print $2}')
+  kill -KILL $(ps aux | grep 'timemanager' | awk '{print $2}')
   kill -KILL $(ps aux | grep 'gateway' | awk '{print $2}')
   kill -KILL $(ps aux | grep 'certificate-authority' | awk '{print $2}')
   kill -KILL $(ps aux | grep 'serviceregistry' | awk '{print $2}')
diff --git a/scripts/timemanager_privileges.sql b/scripts/timemanager_privileges.sql
new file mode 100644
index 000000000..aadf90563
--- /dev/null
+++ b/scripts/timemanager_privileges.sql
@@ -0,0 +1,9 @@
+USE `arrowhead`;
+
+REVOKE ALL, GRANT OPTION FROM 'timemanager'@'localhost';
+
+GRANT ALL PRIVILEGES ON `arrowhead`.`logs` TO 'timemanager'@'localhost';
+
+GRANT ALL PRIVILEGES ON `arrowhead`.`logs` TO 'timemanager'@'%';
+
+FLUSH PRIVILEGES;
diff --git a/timemanager/documentation/Readme.txt b/timemanager/documentation/Readme.txt
new file mode 100644
index 000000000..f87ad5f98
--- /dev/null
+++ b/timemanager/documentation/Readme.txt
@@ -0,0 +1,6 @@
+File list:
+
+Arrowhead TimeManager SysD.pdf - TimeManager System design 
+Arrowhead Time Service IDD.pdf - Time Service Interface design description
+Arrowhead Time Service SD.pdf - Time Service description
+Readme.txt - This file
diff --git a/timemanager/pom.xml b/timemanager/pom.xml
new file mode 100644
index 000000000..a12fa5937
--- /dev/null
+++ b/timemanager/pom.xml
@@ -0,0 +1,135 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+  	<parent>
+    	<groupId>eu.arrowhead</groupId>
+    	<artifactId>core</artifactId>
+    	<version>${revision}</version>
+  	</parent>
+  	
+  	<artifactId>arrowhead-timemanager</artifactId>
+  	<packaging>jar</packaging>
+	<name>Arrowhead TimeManager</name>
+  	<description>Arrowhead TimeManager core service</description>
+  	
+  	<dependencies>
+	    <dependency>
+	      	<groupId>eu.arrowhead</groupId>
+	      	<artifactId>arrowhead-core-common</artifactId>
+	      	<version>${revision}</version>
+	    </dependency>
+  	</dependencies>
+  	
+  	<build>
+	 	<plugins>
+	   		<plugin>
+	 			<artifactId>maven-resources-plugin</artifactId>
+	        	<version>${mvn.resources.version}</version>
+	        	<executions>
+	          		<execution>
+	            		<id>copy-resources</id>
+	            		<!-- here the phase you need -->
+	            		<phase>validate</phase>
+		            	<goals>
+		              		<goal>copy-resources</goal>
+		            	</goals>
+		            	<configuration>
+		              		<outputDirectory>${basedir}/target</outputDirectory>
+		              		<resources>
+		                		<resource>
+		                  			<directory>src/main/resources</directory>
+		                  			<includes>
+		                  				<include>application.properties</include>
+		                  				<include>log4j2.xml</include>
+		                  			</includes>
+		                		</resource>
+		              		</resources>
+		            	</configuration>
+	          		</execution>
+	        	</executions>
+	      	</plugin>
+	      	
+	      	<plugin>
+				<artifactId>jdeb</artifactId>
+				<groupId>org.vafer</groupId>
+				<version>1.8</version>
+				<executions>
+					<execution>
+						<phase>package</phase>
+						<goals>
+							<goal>jdeb</goal>
+						</goals>
+						<configuration>
+							<snapshotExpand>true</snapshotExpand>
+							<snapshotTemplate>[YYMMddHHmm].${git.commit.id.abbrev}</snapshotTemplate>
+							<deb>target/${project.artifactId}_${revision}.deb</deb>
+							<verbose>true</verbose>
+							<controlDir>${basedir}/src/deb/control</controlDir>
+							<dataSet>
+				                <data>
+		                  			<type>file</type>
+		                  			<src>${project.build.directory}/${project.build.finalName}.jar</src>
+		                  			<mapper>
+		                    			<type>perm</type>
+		                    			<prefix>/usr/share/arrowhead/timemanager</prefix>
+		                    			<filemode>755</filemode>
+		                  			</mapper>
+	                			</data>
+	                			
+	                			<data>
+		                  			<type>link</type>
+		                  			<linkName>/usr/share/arrowhead/timemanager/${project.artifactId}.jar</linkName>
+		                  			<linkTarget>/usr/share/arrowhead/timemanager/${project.build.finalName}.jar</linkTarget>
+	                			</data>
+	                			
+	                			<data>
+	                				<type>file</type>
+	                				<src>${project.build.directory}/log4j2.xml</src>
+	                				<mapper>
+	                					<type>perm</type>
+	                					<prefix>/etc/arrowhead/systems/timemanager</prefix>
+	                					<filemode>644</filemode>
+	                				</mapper>
+	                			</data>
+	                			
+	                			<data>
+	                				<type>file</type>
+	                				<src>${project.build.directory}/application.properties</src>
+	                				<mapper>
+	                					<type>perm</type>
+	                					<prefix>/etc/arrowhead/systems/timemanager</prefix>
+	                					<filemode>644</filemode>
+	                				</mapper>
+	                			</data>
+	                			
+	                			<data>
+	                				<type>link</type>
+	                				<linkName>/usr/share/arrowhead/timemanager/application.properties</linkName>
+	                				<linkTarget>/etc/arrowhead/systems/timemanager/application.properties</linkTarget>
+	                			</data>
+	                			
+	                			<data>
+	                				<type>file</type>
+	                				<src>${project.basedir}/src/deb/arrowhead-timemanager.service</src>
+	                				<mapper>
+	                					<type>perm</type>
+	                					<prefix>/etc/systemd/system</prefix>
+	                					<filemode>644</filemode>
+	                				</mapper>
+	                			</data>
+	                			
+	                			<data>
+	                				<type>file</type>
+	                				<src>${project.basedir}/../scripts/timemanager_privileges.sql</src>
+	                				<mapper>
+	                					<type>perm</type>
+	                					<prefix>/usr/share/arrowhead/conf</prefix>
+	                				</mapper>
+	                			</data>
+	         		     	</dataSet>
+	            		</configuration>
+          			</execution>
+        		</executions>
+      		</plugin>
+	 	</plugins>
+	</build>
+</project>
diff --git a/timemanager/src/deb/arrowhead-timemanager.service b/timemanager/src/deb/arrowhead-timemanager.service
new file mode 100644
index 000000000..884d05775
--- /dev/null
+++ b/timemanager/src/deb/arrowhead-timemanager.service
@@ -0,0 +1,14 @@
+[Unit]
+Description=arrowhead-timemanager
+After=network.target mysql.target
+
+[Service]
+WorkingDirectory=/etc/arrowhead/systems/timemanager
+ExecStart=/usr/bin/java -Dlog4j.configurationFile=file:/etc/arrowhead/systems/timemanager/log4j2.xml -jar /usr/share/arrowhead/timemanager/arrowhead-timemanager.jar
+TimeoutStopSec=5
+Type=simple
+User=arrowhead
+Group=arrowhead
+
+[Install]
+WantedBy=default.target
diff --git a/timemanager/src/deb/control/config b/timemanager/src/deb/control/config
new file mode 100644
index 000000000..1fc73f0e4
--- /dev/null
+++ b/timemanager/src/deb/control/config
@@ -0,0 +1,20 @@
+#!/bin/bash -e
+
+. /usr/share/debconf/confmodule
+
+if logname 2>/dev/null; then
+  USER=$(logname)
+  HOME=$(eval echo "~$USER")
+else
+  USER="root"
+  HOME="/root"
+fi
+
+# Get installation type
+db_input high arrowhead-core-common/db_host || true
+db_input high arrowhead-core-common/mysql_password_timemanager || true
+db_input high arrowhead-core-common/sr_host || true
+
+# Run dialogs
+db_go || true
+
diff --git a/timemanager/src/deb/control/control b/timemanager/src/deb/control/control
new file mode 100644
index 000000000..eba172e14
--- /dev/null
+++ b/timemanager/src/deb/control/control
@@ -0,0 +1,10 @@
+Package: arrowhead-timemanager
+Version: [[version]]
+Section: contrib/java
+Priority: optional
+Architecture: all
+Maintainer: Jens Eliasson <jens.eliasson@thingwave.eu>
+Homepage: http://www.arrowhead.eu
+Description: Arrowhead TimeManager System
+Distribution: development
+Depends: java-runtime-headless, virtual-mysql-server, arrowhead-core-common
diff --git a/timemanager/src/deb/control/postinst b/timemanager/src/deb/control/postinst
new file mode 100644
index 000000000..d4d6413a6
--- /dev/null
+++ b/timemanager/src/deb/control/postinst
@@ -0,0 +1,95 @@
+#!/bin/bash
+# postinst script for arrowhead-timemanager
+#
+# see: dh_installdeb(1)
+
+set -e
+
+. /usr/share/debconf/confmodule
+
+SYSTEM_NAME="timemanager"
+PKG_NAME="arrowhead-timemanager"
+
+# summary of how this script can be called:
+#        * <postinst> `configure' <most-recently-configured-version>
+#        * <old-postinst> `abort-upgrade' <new version>
+#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
+#          <new-version>
+#        * <postinst> `abort-remove'
+#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
+#          <failed-install-package> <version> `removing'
+#          <conflicting-package> <version>
+# for details, see https://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+
+case "$1" in
+  configure)
+    . /usr/share/arrowhead/conf/ahconf.sh
+    SYSTEM_DIR="${AH_SYSTEMS_DIR}/${SYSTEM_NAME}"
+
+    db_get arrowhead-core-common/mysql_password_timemanager; system_passwd=$RET || true
+    db_unregister arrowhead-core-common/mysql_password_timemanager
+
+    # Generate password (if required)
+    if [ -z "${system_passwd}" ]; then
+      system_passwd="$(openssl rand -base64 12)"
+    fi  
+
+    echo "Configuring MySQL database..." >&2
+    ah_db_tables_and_user ${SYSTEM_NAME} ${SYSTEM_NAME}_privileges.sql ${system_passwd}
+
+    if [ ! -d "${SYSTEM_DIR}" ]; then
+      mkdir -p ${SYSTEM_DIR}
+    fi
+
+    ah_cert_signed_system ${SYSTEM_NAME}
+
+    # modify log config and application.properties
+
+    ah_transform_log_file ${SYSTEM_DIR}
+
+    db_get arrowhead-core-common/sr_host: sr_host=$RET || true
+
+    if [ -z ${sr_host} ]; then
+      sr_host=${OWN_IP}
+    fi
+
+    db_get arrowhead-core-common/db_host; db_host=$RET || true
+
+    mv ${SYSTEM_DIR}/application.properties ${SYSTEM_DIR}/application.properties.orig
+    cat ${SYSTEM_DIR}/application.properties.orig | \
+      sed -r -e "\#^.*spring\.datasource\.url=#s#.*\$#spring.datasource.url=jdbc:mysql://"${db_host}":3306/arrowhead?serverTimezone=Europe/Budapest#"  \
+      -e "\#^.*spring\.datasource\.password=#s#.*\$#spring.datasource.password=${system_passwd}#" \
+      -e "\#^.*server\.address=#s#.*\$#server.address=${OWN_IP}#" \
+      -e "\#^.*sr_address=#s#.*\$#sr_address=${sr_host}#" \
+      -e "\#^.*server\.ssl\.key-store=#s#.*\$#server.ssl.key-store=file:${SYSTEM_DIR}/${SYSTEM_NAME}.p12#" \
+      -e "\#^.*server\.ssl\.key-store-password=#s#.*\$#server.ssl.key-store-password=${AH_PASS_CERT}#" \
+      -e "\#^.*server\.ssl\.key-password=#s#.*\$#server.ssl.key-password=${AH_PASS_CERT}#" \
+      -e "\#^.*server\.ssl\.trust-store=#s#.*\$#server.ssl.trust-store=file:${AH_CONF_DIR}/truststore.p12#" \
+      -e "\#^.*server\.ssl\.trust-store-password=#s#.*\$#server.ssl.trust-store-password=${AH_PASS_CERT}#" > ${SYSTEM_DIR}/application.properties
+
+    rm ${SYSTEM_DIR}/application.properties.orig
+    chown arrowhead:arrowhead ${SYSTEM_DIR}/application.properties
+    chmod 640 ${SYSTEM_DIR}/application.properties
+
+    echo "Starting ${PKG_NAME}..." >&2
+    systemctl daemon-reload
+    systemctl enable ${PKG_NAME}.service
+    systemctl start ${PKG_NAME}.service
+    ;;
+
+   abort-upgrade|abort-remove|abort-deconfigure)
+    ;;
+
+  *)
+    echo "postinst called with unknown argument \`$1'" >&2
+    exit 1
+    ;;
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
diff --git a/timemanager/src/deb/control/postrm b/timemanager/src/deb/control/postrm
new file mode 100644
index 000000000..8cc4b3481
--- /dev/null
+++ b/timemanager/src/deb/control/postrm
@@ -0,0 +1,55 @@
+#!/bin/bash
+# postrm script for arrowhead-timemanager
+#
+# see: dh_installdeb(1)
+
+set -e
+
+. /usr/share/debconf/confmodule
+
+SYSTEM_NAME="timemanager"
+
+# summary of how this script can be called:
+#        * <postrm> `remove'
+#        * <postrm> `purge'
+#        * <old-postrm> `upgrade' <new-version>
+#        * <new-postrm> `failed-upgrade' <old-version>
+#        * <new-postrm> `abort-install'
+#        * <new-postrm> `abort-install' <old-version>
+#        * <new-postrm> `abort-upgrade' <old-version>
+#        * <disappearer's-postrm> `disappear' <overwriter>
+#          <overwriter-version>
+# for details, see https://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+
+
+case "$1" in
+  purge)
+    AH_CONF_DIR="/etc/arrowhead"
+    AH_SYSTEMS_DIR="${AH_CONF_DIR}/systems"
+    SYSTEM_DIR="${AH_SYSTEMS_DIR}/${SYSTEM_NAME}"
+
+    rm -f \
+      /var/log/arrowhead/${SYSTEM_NAME}*.log \
+      ${SYSTEM_DIR}/log4j2.xml \
+      ${SYSTEM_DIR}/application.properties \
+      ${SYSTEM_DIR}/${SYSTEM_NAME}.p12 \
+
+    rmdir ${SYSTEM_DIR} 2>/dev/null || true
+    db_purge
+    ;;
+  remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
+    ;;
+
+  *)
+    echo "postrm called with unknown argument \`$1'" >&2
+    exit 1
+    ;;
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
diff --git a/timemanager/src/deb/control/preinst b/timemanager/src/deb/control/preinst
new file mode 100644
index 000000000..9eacdd1fa
--- /dev/null
+++ b/timemanager/src/deb/control/preinst
@@ -0,0 +1,35 @@
+#!/bin/bash
+# preinst script for arrowhead-timemanager
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+#        * <new-preinst> `install'
+#        * <new-preinst> `install' <old-version>
+#        * <new-preinst> `upgrade' <old-version>
+#        * <old-preinst> `abort-upgrade' <new-version>
+# for details, see https://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+
+
+case "$1" in
+  install|upgrade)
+    ;;
+
+  abort-upgrade)
+    ;;
+
+  *)
+    echo "preinst called with unknown argument \`$1'" >&2
+    exit 1
+    ;;
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
diff --git a/timemanager/src/deb/control/prerm b/timemanager/src/deb/control/prerm
new file mode 100644
index 000000000..1e3a090c1
--- /dev/null
+++ b/timemanager/src/deb/control/prerm
@@ -0,0 +1,45 @@
+#!/bin/bash
+# prerm script for arrowhead-timemanager
+#
+# see: dh_installdeb(1)
+
+set -e
+
+PKG_NAME="arrowhead-timemanager"
+
+# summary of how this script can be called:
+#        * <prerm> `remove'
+#        * <old-prerm> `upgrade' <new-version>
+#        * <new-prerm> `failed-upgrade' <old-version>
+#        * <conflictor's-prerm> `remove' `in-favour' <package> <new-version>
+#        * <deconfigured's-prerm> `deconfigure' `in-favour'
+#          <package-being-installed> <version> `removing'
+#          <conflicting-package> <version>
+# for details, see https://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+
+
+case "$1" in
+  remove)
+    systemctl stop ${PKG_NAME}.service
+    systemctl disable ${PKG_NAME}.service
+    ;;
+
+  upgrade|deconfigure)
+    ;;
+
+  failed-upgrade)
+    ;;
+
+  *)
+    echo "prerm called with unknown argument \`$1'" >&2
+    exit 1
+    ;;
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
diff --git a/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeManagerApplicationInitListener.java b/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeManagerApplicationInitListener.java
new file mode 100644
index 000000000..bbccbac9b
--- /dev/null
+++ b/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeManagerApplicationInitListener.java
@@ -0,0 +1,37 @@
+/********************************************************************************
+ * Copyright (c) 2021 {Lulea University of Technology}
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0 
+ *
+ * Contributors: 
+ *   {Lulea University of Technology} - implementation
+ *   Arrowhead Consortia - conceptualization 
+ ********************************************************************************/
+package eu.arrowhead.core.timemanager;
+
+import eu.arrowhead.common.ApplicationInitListener;
+import eu.arrowhead.common.core.CoreSystemService;
+import org.springframework.context.event.ContextRefreshedEvent;
+import org.springframework.stereotype.Component;
+
+import java.util.Base64;
+
+@Component
+public class TimeManagerApplicationInitListener extends ApplicationInitListener {
+
+    //=================================================================================================
+    // members
+
+    //-------------------------------------------------------------------------------------------------
+    @Override
+    protected void customInit(final ContextRefreshedEvent event) {
+        if (sslProperties.isSslEnabled()) {
+            logger.debug("AuthInfo: {}", Base64.getEncoder().encodeToString(publicKey.getEncoded()));
+        }
+    }
+
+}
diff --git a/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeManagerController.java b/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeManagerController.java
new file mode 100644
index 000000000..2f4081ebc
--- /dev/null
+++ b/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeManagerController.java
@@ -0,0 +1,126 @@
+/********************************************************************************
+ * Copyright (c) 2021 {Lulea University of Technology}
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0 
+ *
+ * Contributors: 
+ *   {Lulea University of Technology} - implementation
+ *   Arrowhead Consortia - conceptualization 
+ ********************************************************************************/
+package eu.arrowhead.core.timeamanager;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Vector;
+import java.util.Iterator;
+
+import org.apache.http.HttpStatus;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.MediaType;
+import org.springframework.http.RequestEntity;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.CrossOrigin;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestHeader;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.server.ResponseStatusException;
+import org.springframework.util.MultiValueMap;
+import org.springframework.util.Assert;
+
+import eu.arrowhead.common.CommonConstants;
+import eu.arrowhead.common.CoreCommonConstants;
+import eu.arrowhead.common.CoreDefaults;
+import eu.arrowhead.common.CoreUtilities;
+import eu.arrowhead.common.CoreUtilities.ValidatedPageParams;
+import eu.arrowhead.common.Defaults;
+import eu.arrowhead.common.Utilities;
+//import eu.arrowhead.common.dto.shared.TimeManagerTimeRequestDTO;
+import eu.arrowhead.common.dto.shared.TimeManagerTimeResponseDTO;
+import eu.arrowhead.common.exception.ArrowheadException;
+import eu.arrowhead.common.exception.BadPayloadException;
+import eu.arrowhead.common.exception.DataNotFoundException;
+import eu.arrowhead.common.exception.InvalidParameterException;
+import eu.arrowhead.core.timemanager.database.service.TimeManagerDBService;
+import eu.arrowhead.core.timemanager.service.TimeService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
+
+
+@Api(tags = { CoreCommonConstants.SWAGGER_TAG_ALL })
+//@CrossOrigin(maxAge = Defaults.CORS_MAX_AGE, allowCredentials = Defaults.CORS_ALLOW_CREDENTIALS, 
+//allowedHeaders = { HttpHeaders.ORIGIN, HttpHeaders.CONTENT_TYPE, HttpHeaders.ACCEPT, HttpHeaders.AUTHORIZATION }
+//)
+@RestController
+@RequestMapping(CommonConstants.TIMEMANAGER_URI)
+public class TimeManagerController {
+	
+	//=================================================================================================
+	// members
+	
+	private static final String OP_NOT_VALID_ERROR_MESSAGE = " Illegal operation. ";
+	private static final String NOT_FOUND_ERROR_MESSAGE = " Resource not found. ";
+	
+	private final Logger logger = LogManager.getLogger(TimeManagerController.class);
+
+	@Autowired
+	private TimeService timeService;
+
+	@Autowired
+	private TimeManagerDBService timeManagerDBService;
+	
+	//=================================================================================================
+	// methods
+	
+	//-------------------------------------------------------------------------------------------------
+	@ApiOperation(value = "Return an echo message with the purpose of testing the core service availability", response = String.class, tags = { CoreCommonConstants.SWAGGER_TAG_CLIENT })
+	@ApiResponses (value = {
+			@ApiResponse(code = HttpStatus.SC_OK, message = CoreCommonConstants.SWAGGER_HTTP_200_MESSAGE),
+			@ApiResponse(code = HttpStatus.SC_UNAUTHORIZED, message = CoreCommonConstants.SWAGGER_HTTP_401_MESSAGE)
+	})
+	@GetMapping(path = CommonConstants.ECHO_URI)
+	@ResponseBody public String echoService() {
+		return "Got it!";
+	}
+	
+	//-------------------------------------------------------------------------------------------------
+	@ApiOperation(value = "Interface to the Time service", response = TimeManagerTimeResponseDTO.class, tags = { CoreCommonConstants.SWAGGER_TAG_CLIENT })
+	@ApiResponses (value = {
+			@ApiResponse(code = HttpStatus.SC_OK, message = CoreCommonConstants.SWAGGER_HTTP_200_MESSAGE),
+			@ApiResponse(code = HttpStatus.SC_UNAUTHORIZED, message = CoreCommonConstants.SWAGGER_HTTP_401_MESSAGE),
+			@ApiResponse(code = HttpStatus.SC_INTERNAL_SERVER_ERROR, message = CoreCommonConstants.SWAGGER_HTTP_500_MESSAGE)
+	})
+	@GetMapping(path= CommonConstants.OP_TIMEMANAGER_TIME, produces = MediaType.APPLICATION_JSON_VALUE)
+	@ResponseBody public TimeManagerTimeResponseDTO timeGet(
+			) {
+		logger.debug("timeGet");
+
+        TimeManagerTimeResponseDTO resp = null;
+		return resp;
+	}
+
+	
+	//=================================================================================================
+	// assistant methods
+	
+	
+	//=================================================================================================
+
+}
diff --git a/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeManagerMain.java b/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeManagerMain.java
new file mode 100644
index 000000000..cfdf728fb
--- /dev/null
+++ b/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeManagerMain.java
@@ -0,0 +1,40 @@
+/********************************************************************************
+ * Copyright (c) 2021 {Lulea University of Technology}
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0 
+ *
+ * Contributors: 
+ *   {Lulea University of Technology} - implementation
+ *   Arrowhead Consortia - conceptualization 
+ ********************************************************************************/
+package eu.arrowhead.core.timemanager;
+
+import eu.arrowhead.common.CommonConstants;
+import eu.arrowhead.common.CoreCommonConstants;
+import eu.arrowhead.common.database.repository.RefreshableRepositoryImpl;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.autoconfigure.domain.EntityScan;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
+
+@SpringBootApplication(scanBasePackages = CommonConstants.BASE_PACKAGE)
+@EntityScan(CoreCommonConstants.DATABASE_ENTITY_PACKAGE)
+@EnableJpaRepositories(basePackages = CoreCommonConstants.DATABASE_REPOSITORY_PACKAGE, repositoryBaseClass = RefreshableRepositoryImpl.class)
+@EnableSwagger2
+public class TimeManagerMain
+{
+
+    //=================================================================================================
+    // methods
+
+    //-------------------------------------------------------------------------------------------------
+    public static void main(final String[] args) {
+        SpringApplication.run(TimeManagerMain.class, args);
+    }
+}
diff --git a/timemanager/src/main/java/eu/arrowhead/core/timemanager/database/service/TimeManagerDBService.java b/timemanager/src/main/java/eu/arrowhead/core/timemanager/database/service/TimeManagerDBService.java
new file mode 100644
index 000000000..e86e77118
--- /dev/null
+++ b/timemanager/src/main/java/eu/arrowhead/core/timemanager/database/service/TimeManagerDBService.java
@@ -0,0 +1,76 @@
+/********************************************************************************
+ * Copyright (c) 2021 {Lulea University of Technology}
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0 
+ *
+ * Contributors: 
+ *   {Lulea University of Technology} - implementation
+ *   Arrowhead Consortia - conceptualization 
+ ********************************************************************************/
+package eu.arrowhead.core.timemanager.database.service;
+
+import java.util.Optional;
+import java.util.List;
+import java.util.ArrayList; 
+import java.util.Iterator; 
+import java.util.Vector;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.stereotype.Service;
+
+import eu.arrowhead.common.CommonConstants;
+import eu.arrowhead.common.CoreCommonConstants;
+import eu.arrowhead.common.Utilities;
+import eu.arrowhead.common.dto.internal.DTOConverter;
+import eu.arrowhead.common.exception.ArrowheadException;
+import eu.arrowhead.common.exception.InvalidParameterException;
+
+import java.sql.DriverManager;
+import java.sql.Connection;
+import java.sql.Statement;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.Array;
+import java.sql.SQLException;
+
+
+@Service
+public class TimeManagerDBService {
+	//=================================================================================================
+	// members
+
+    public static final int MAX_ALLOWED_TIME_DIFF  = 1000; //milliseconds
+	
+	@Value("${spring.datasource.url}")
+	private String url;
+	@Value("${spring.datasource.username}")
+	private String user;
+	@Value("${spring.datasource.password}")
+	private String password;
+
+	private static final Logger logger = LogManager.getLogger(TimeManagerDBService.class);
+	
+	//=================================================================================================
+	// methods
+
+	//-------------------------------------------------------------------------------------------------
+	private Connection getConnection() throws SQLException {
+	  return DriverManager.getConnection(url, user, password);
+	}
+
+
+	//-------------------------------------------------------------------------------------------------
+	private void closeConnection(final Connection conn) throws SQLException {
+	  conn.close();
+	}
+
+}
diff --git a/timemanager/src/main/java/eu/arrowhead/core/timemanager/security/TimemanagerAccessControlFilter.java b/timemanager/src/main/java/eu/arrowhead/core/timemanager/security/TimemanagerAccessControlFilter.java
new file mode 100644
index 000000000..cc2bcf7cd
--- /dev/null
+++ b/timemanager/src/main/java/eu/arrowhead/core/timemanager/security/TimemanagerAccessControlFilter.java
@@ -0,0 +1,78 @@
+/********************************************************************************
+ * Copyright (c) 2021 {Lulea University of Technology}
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0 
+ *
+ * Contributors: 
+ *   {Lulea University of Technology} - implementation
+ *   Arrowhead Consortia - conceptualization 
+ ********************************************************************************/
+package eu.arrowhead.core.timemanager.security;
+
+import eu.arrowhead.common.CommonConstants;
+import eu.arrowhead.common.CoreCommonConstants;
+import eu.arrowhead.common.SecurityUtilities;
+import eu.arrowhead.common.dto.shared.CertificateType;
+import eu.arrowhead.common.security.CoreSystemAccessControlFilter;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.stereotype.Component;
+
+import org.springframework.http.HttpStatus;
+import org.springframework.stereotype.Component;
+
+import eu.arrowhead.common.Utilities;
+import eu.arrowhead.common.exception.AuthException;
+
+import java.util.Map;
+
+@Component
+@ConditionalOnProperty(name = CommonConstants.SERVER_SSL_ENABLED, matchIfMissing = true) 
+public class TimemanagerAccessControlFilter extends CoreSystemAccessControlFilter {
+	
+	//=================================================================================================
+        // members
+        
+	//=================================================================================================
+	// assistant methods
+
+	//-------------------------------------------------------------------------------------------------
+	@Override
+	protected void checkClientAuthorized(final String clientCN, final String method, final String requestTarget, final String requestJSON, final Map<String,String[]> queryParams) {
+		super.checkClientAuthorized(clientCN, method, requestTarget, requestJSON, queryParams);
+
+		final String cloudCN = getServerCloudCN();
+
+		if (requestTarget.endsWith(CommonConstants.ECHO_URI)) {
+          // Everybody in the local cloud can test the server => no further check is necessary
+          return;
+		} 
+
+        //checkIfRequesterSystemNameisEqualsWithClientNameFromCN(requestTargetSystemName, clientCN);
+
+	}
+
+	//-------------------------------------------------------------------------------------------------
+        private void checkIfRequesterSystemNameisEqualsWithClientNameFromCN(final String requesterSystemName, final String clientCN) {
+                final String clientNameFromCN = getClientNameFromCN(clientCN);
+                
+                if (Utilities.isEmpty(requesterSystemName) || Utilities.isEmpty(clientNameFromCN)) {
+                        log.debug("Requester system name and client name from certificate do not match!");
+                        throw new AuthException("Requester system name or client name from certificate is null or blank!", HttpStatus.UNAUTHORIZED.value());
+                }
+                
+                if (!requesterSystemName.equalsIgnoreCase(clientNameFromCN) && !requesterSystemName.replaceAll("_", "").equalsIgnoreCase(clientNameFromCN)) {
+                        log.debug("Requester system name and client name from certificate do not match!");
+                        throw new AuthException("Requester system name(" + requesterSystemName + ") and client name from certificate (" + clientNameFromCN + ") do not match!", HttpStatus.UNAUTHORIZED.value());
+                }
+        }
+        
+        //-------------------------------------------------------------------------------------------------
+        private String getClientNameFromCN(final String clientCN) {
+                return clientCN.split("\\.", 2)[0];
+        }
+}
diff --git a/timemanager/src/main/java/eu/arrowhead/core/timemanager/security/TimemanagerSecurityConfig.java b/timemanager/src/main/java/eu/arrowhead/core/timemanager/security/TimemanagerSecurityConfig.java
new file mode 100644
index 000000000..fda7740c1
--- /dev/null
+++ b/timemanager/src/main/java/eu/arrowhead/core/timemanager/security/TimemanagerSecurityConfig.java
@@ -0,0 +1,24 @@
+/********************************************************************************
+ * Copyright (c) 2021 {Lulea University of Technology}
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0 
+ *
+ * Contributors: 
+ *   {Lulea University of Technology} - implementation
+ *   Arrowhead Consortia - conceptualization 
+ ********************************************************************************/
+package eu.arrowhead.core.timemanager.security;
+
+import eu.arrowhead.common.security.DefaultSecurityConfig;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
+
+@Configuration
+@EnableWebSecurity
+public class TimemanagerSecurityConfig extends DefaultSecurityConfig {
+
+}
diff --git a/timemanager/src/main/java/eu/arrowhead/core/timemanager/service/TimeService.java b/timemanager/src/main/java/eu/arrowhead/core/timemanager/service/TimeService.java
new file mode 100644
index 000000000..504aa7d27
--- /dev/null
+++ b/timemanager/src/main/java/eu/arrowhead/core/timemanager/service/TimeService.java
@@ -0,0 +1,57 @@
+/********************************************************************************
+ * Copyright (c) 2021 {Lulea University of Technology}
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0 
+ *
+ * Contributors: 
+ *   {Lulea University of Technology} - implementation
+ *   Arrowhead Consortia - conceptualization 
+ ********************************************************************************/
+package eu.arrowhead.core.timemanager.service;
+
+import javax.annotation.Resource;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+import eu.arrowhead.common.CommonConstants;
+import eu.arrowhead.common.CoreCommonConstants;
+import eu.arrowhead.common.Utilities;
+import eu.arrowhead.common.dto.internal.DTOConverter;
+import eu.arrowhead.common.exception.InvalidParameterException;
+import eu.arrowhead.core.timemanager.database.service.TimeManagerDBService;
+
+import java.util.List;
+import java.util.ArrayList; 
+import java.util.Iterator; 
+import java.util.Vector;
+
+
+@Service
+public class TimeService {
+
+    //=================================================================================================
+    // members
+    //
+
+    private final Logger logger = LogManager.getLogger(TimeService.class);
+
+    //=================================================================================================
+    // methods
+
+    //-------------------------------------------------------------------------------------------------
+    public TimeService() {
+
+    }
+
+    //=================================================================================================
+    // assistant methods
+
+}
diff --git a/timemanager/src/main/java/eu/arrowhead/core/timemanager/swagger/TimemanagerSwaggerConfig.java b/timemanager/src/main/java/eu/arrowhead/core/timemanager/swagger/TimemanagerSwaggerConfig.java
new file mode 100644
index 000000000..8640846e6
--- /dev/null
+++ b/timemanager/src/main/java/eu/arrowhead/core/timemanager/swagger/TimemanagerSwaggerConfig.java
@@ -0,0 +1,41 @@
+/********************************************************************************
+ * Copyright (c) 2021 {Lulea University of Technology}
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0 
+ *
+ * Contributors: 
+ *   {Lulea University of Technology} - implementation
+ *   Arrowhead Consortia - conceptualization 
+ ********************************************************************************/
+package eu.arrowhead.core.timemanager.swagger;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import eu.arrowhead.common.CommonConstants;
+import eu.arrowhead.common.swagger.DefaultSwaggerConfig;
+import springfox.documentation.spring.web.plugins.Docket;
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
+
+@EnableSwagger2
+@Configuration
+public class TimemanagerSwaggerConfig extends DefaultSwaggerConfig {
+	
+	//=================================================================================================
+	// methods
+
+	//-------------------------------------------------------------------------------------------------
+	public TimemanagerSwaggerConfig() {
+		super(CommonConstants.CORE_SYSTEM_TIMEMANAGER);
+	}
+	
+	//-------------------------------------------------------------------------------------------------
+	@Bean
+	public Docket customizeSwagger() {
+		return configureSwaggerForCoreSystem(this.getClass().getPackageName());
+	}
+}
diff --git a/timemanager/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/timemanager/src/main/resources/META-INF/additional-spring-configuration-metadata.json
new file mode 100644
index 000000000..20f805510
--- /dev/null
+++ b/timemanager/src/main/resources/META-INF/additional-spring-configuration-metadata.json
@@ -0,0 +1,27 @@
+{"properties": [
+  {
+    "name": "sr_address",
+    "type": "java.lang.String",
+    "description": "A description for 'sr_address'"
+  },
+  {
+    "name": "sr_port",
+    "type": "java.lang.Integer",
+    "description": "A description for 'sr_port'"
+  },
+  {
+    "name": "disable.hostname.verifier",
+    "type": "java.lang.Boolean",
+    "description": "A description for 'disable.hostname.verifier'"
+  },
+  {
+    "name": "log_all_request_and_response",
+    "type": "java.lang.Boolean",
+    "description": "A description for 'log_all_request_and_response'"
+  },
+  {
+    "name": "core_system_name",
+    "type": "java.lang.String",
+    "description": "A description for 'core_system_name'"
+  }
+]}
\ No newline at end of file
diff --git a/timemanager/src/main/resources/application.properties b/timemanager/src/main/resources/application.properties
new file mode 100644
index 000000000..1e244af40
--- /dev/null
+++ b/timemanager/src/main/resources/application.properties
@@ -0,0 +1,60 @@
+############################################
+###       APPLICATION PARAMETERS         ###
+############################################
+
+# Database connection (mandatory)
+# Change the server timezone if neccessary
+spring.datasource.url=jdbc:mysql://127.0.0.1:3306/arrowhead?serverTimezone=Europe/Budapest  
+spring.datasource.username=timemanager
+spring.datasource.password=xyp2XEAu5Tbc41g
+spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
+
+spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect
+# use true only for debugging
+spring.jpa.show-sql=false  
+spring.jpa.properties.hibernate.format_sql=true
+spring.jpa.hibernate.ddl-auto=none
+
+# Parameters of TimeManager web-server
+server.address=0.0.0.0
+server.port=8463
+domain.name=127.0.0.1
+domain.port=8463
+
+############################################
+###       CUSTOM PARAMETERS              ###
+############################################
+
+# Name of the core system
+core_system_name=TIMEMANAGER
+
+# Show all request/response in debug log
+log_all_request_and_response=false
+
+# Service Registry web-server parameters (to register the TimeManager services)
+sr_address=127.0.0.1
+sr_port=8443
+
+
+############################################
+###           SECURE MODE                ###
+############################################
+
+# configure secure mode
+
+# Set this to false to disable https mode
+server.ssl.enabled=true
+
+server.ssl.key-store-type=PKCS12
+server.ssl.key-store=classpath:certificates/timemanager.p12
+server.ssl.key-store-password=123456
+server.ssl.key-alias=timemanager
+server.ssl.key-password=123456
+server.ssl.client-auth=need
+server.ssl.trust-store-type=PKCS12
+server.ssl.trust-store=classpath:certificates/truststore.p12
+server.ssl.trust-store-password=123456
+
+#If true, http client does not check whether the hostname is match one of the server's SAN in its certificate
+#Just for testing, DO NOT USE this feature in production environment 
+disable.hostname.verifier=false
diff --git a/timemanager/src/main/resources/certificates/truststore.p12 b/timemanager/src/main/resources/certificates/truststore.p12
new file mode 100644
index 0000000000000000000000000000000000000000..57c1c5f43254b23364a333cb17dab29d31af634e
GIT binary patch
diff --git a/timemanager/src/main/resources/log4j2.xml b/timemanager/src/main/resources/log4j2.xml
new file mode 100644
index 000000000..4072dc607
--- /dev/null
+++ b/timemanager/src/main/resources/log4j2.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Configuration status="WARN" monitorInterval="30">
+    <Properties>
+        <Property name="LOG_PATTERN">
+            %d{yyyy-MM-dd HH:mm:ss.SSS} %5p ${hostName} --- [%15.15t] %-40.40c{1.} : %m%n%ex
+        </Property>
+		<Property name="JDBC_LEVEL">INFO</Property>
+		<Property name="CONSOLE_FILE_LEVEL">INFO</Property>
+		<Property name="LOG_DIR">.</Property>
+    </Properties>
+    <Appenders>
+        <Console name="ConsoleAppender" target="SYSTEM_OUT" follow="true">
+            <PatternLayout pattern="${LOG_PATTERN}"/>
+        </Console>
+		<RollingFile name="FileAppender" fileName="${LOG_DIR}/timemanager.log" filePattern="${LOG_DIR}/timemanager-%d{yyyy-MM-dd}-%i.log">
+	    	<PatternLayout>
+	        	<Pattern>${LOG_PATTERN}</Pattern>
+	    	</PatternLayout>
+	    	<Policies>
+	        	<SizeBasedTriggeringPolicy size="100MB" />
+	    	</Policies>
+	    	<DefaultRolloverStrategy max="10" />
+		</RollingFile>
+		<JDBC name="MySQLDatabase" tableName="logs">
+         	<ConnectionFactory class="eu.arrowhead.common.log4j2.JDBCConnectionFactoryForLog4J2" method="getConnection" />
+         	<Column name="log_id" pattern="%u" />
+         	<Column name="entry_date" isEventTimestamp="true" />
+         	<Column name="logger" pattern="%logger" />
+         	<Column name="log_level" pattern="%level" />
+         	<Column name="message" pattern="%m" />
+         	<Column name="exception" pattern="%throwable " />
+			<ThresholdFilter level="${JDBC_LEVEL}" onMatch="ACCEPT" onMismatch="DENY"/>
+      	</JDBC>
+    </Appenders>
+    <Loggers>
+		<Root level="WARN">
+            <AppenderRef ref="ConsoleAppender" /> <!-- comment out this one in production environment -->
+            <AppenderRef ref="FileAppender" />
+        </Root>
+		<AsyncLogger name="eu.arrowhead" level="${JDBC_LEVEL}" additivity="true">
+            <AppenderRef ref="MySQLDatabase" />			
+    	</AsyncLogger>
+		<Logger name="eu.arrowhead.common" level="${CONSOLE_FILE_LEVEL}" additivity="true"></Logger>
+		<Logger name="eu.arrowhead.core" level="${CONSOLE_FILE_LEVEL}" additivity="true"></Logger>		
+    </Loggers>
+</Configuration>
diff --git a/timemanager/src/main/resources/swagger/swagger-ui.html b/timemanager/src/main/resources/swagger/swagger-ui.html
new file mode 100644
index 000000000..cc658fbd2
--- /dev/null
+++ b/timemanager/src/main/resources/swagger/swagger-ui.html
@@ -0,0 +1,75 @@
+<!-- HTML for static distribution bundle build -->
+<!DOCTYPE html>
+<html lang="en">
+<head>
+  <meta charset="UTF-8">
+  <title>Timemanager</title>
+  <link rel="stylesheet" type="text/css" href="webjars/springfox-swagger-ui/springfox.css?v=2.9.2" >
+  <link rel="stylesheet" type="text/css" href="webjars/springfox-swagger-ui/swagger-ui.css?v=2.9.2" >
+  <link rel="icon" type="image/png" href="webjars/springfox-swagger-ui/favicon-32x32.png?v=2.9.2" sizes="32x32" />
+  <link rel="icon" type="image/png" href="webjars/springfox-swagger-ui/favicon-16x16.png?v=2.9.2" sizes="16x16" />
+  <style>
+    html
+    {
+      box-sizing: border-box;
+      overflow: -moz-scrollbars-vertical;
+      overflow-y: scroll;
+    }
+    *,
+    *:before,
+    *:after
+    {
+      box-sizing: inherit;
+    }
+
+    body {
+      margin:0;
+      background: #fafafa;
+    }
+  </style>
+</head>
+
+<body>
+
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="position:absolute;width:0;height:0">
+  <defs>
+    <symbol viewBox="0 0 20 20" id="unlocked">
+      <path d="M15.8 8H14V5.6C14 2.703 12.665 1 10 1 7.334 1 6 2.703 6 5.6V6h2v-.801C8 3.754 8.797 3 10 3c1.203 0 2 .754 2 2.199V8H4c-.553 0-1 .646-1 1.199V17c0 .549.428 1.139.951 1.307l1.197.387C5.672 18.861 6.55 19 7.1 19h5.8c.549 0 1.428-.139 1.951-.307l1.196-.387c.524-.167.953-.757.953-1.306V9.199C17 8.646 16.352 8 15.8 8z"></path>
+    </symbol>
+
+    <symbol viewBox="0 0 20 20" id="locked">
+      <path d="M15.8 8H14V5.6C14 2.703 12.665 1 10 1 7.334 1 6 2.703 6 5.6V8H4c-.553 0-1 .646-1 1.199V17c0 .549.428 1.139.951 1.307l1.197.387C5.672 18.861 6.55 19 7.1 19h5.8c.549 0 1.428-.139 1.951-.307l1.196-.387c.524-.167.953-.757.953-1.306V9.199C17 8.646 16.352 8 15.8 8zM12 8H8V5.199C8 3.754 8.797 3 10 3c1.203 0 2 .754 2 2.199V8z"/>
+    </symbol>
+
+    <symbol viewBox="0 0 20 20" id="close">
+      <path d="M14.348 14.849c-.469.469-1.229.469-1.697 0L10 11.819l-2.651 3.029c-.469.469-1.229.469-1.697 0-.469-.469-.469-1.229 0-1.697l2.758-3.15-2.759-3.152c-.469-.469-.469-1.228 0-1.697.469-.469 1.228-.469 1.697 0L10 8.183l2.651-3.031c.469-.469 1.228-.469 1.697 0 .469.469.469 1.229 0 1.697l-2.758 3.152 2.758 3.15c.469.469.469 1.229 0 1.698z"/>
+    </symbol>
+
+    <symbol viewBox="0 0 20 20" id="large-arrow">
+      <path d="M13.25 10L6.109 2.58c-.268-.27-.268-.707 0-.979.268-.27.701-.27.969 0l7.83 7.908c.268.271.268.709 0 .979l-7.83 7.908c-.268.271-.701.27-.969 0-.268-.269-.268-.707 0-.979L13.25 10z"/>
+    </symbol>
+
+    <symbol viewBox="0 0 20 20" id="large-arrow-down">
+      <path d="M17.418 6.109c.272-.268.709-.268.979 0s.271.701 0 .969l-7.908 7.83c-.27.268-.707.268-.979 0l-7.908-7.83c-.27-.268-.27-.701 0-.969.271-.268.709-.268.979 0L10 13.25l7.418-7.141z"/>
+    </symbol>
+
+
+    <symbol viewBox="0 0 24 24" id="jump-to">
+      <path d="M19 7v4H5.83l3.58-3.59L8 6l-6 6 6 6 1.41-1.41L5.83 13H21V7z"/>
+    </symbol>
+
+    <symbol viewBox="0 0 24 24" id="expand">
+      <path d="M10 18h4v-2h-4v2zM3 6v2h18V6H3zm3 7h12v-2H6v2z"/>
+    </symbol>
+
+  </defs>
+</svg>
+
+<div id="swagger-ui"></div>
+
+<script src="webjars/springfox-swagger-ui/swagger-ui-bundle.js?v=2.9.2"> </script>
+<script src="webjars/springfox-swagger-ui/swagger-ui-standalone-preset.js?v=2.9.2"> </script>
+<script src="webjars/springfox-swagger-ui/springfox.js?v=2.9.2"> </script>
+</body>
+
+</html>
diff --git a/timemanager/src/test/java/eu/arrowhead/core/timemanager/StandaloneModeInTimeManagerTests.java b/timemanager/src/test/java/eu/arrowhead/core/timemanager/StandaloneModeInTimeManagerTests.java
new file mode 100644
index 000000000..768199a6d
--- /dev/null
+++ b/timemanager/src/test/java/eu/arrowhead/core/timemanager/StandaloneModeInTimeManagerTests.java
@@ -0,0 +1,9 @@
+package eu.arrowhead.core.timemanager;
+
+import eu.arrowhead.common.testhelper.StandaloneModeInTests;
+import org.springframework.stereotype.Component;
+
+@Component
+public class StandaloneModeInTimeManagerTests extends StandaloneModeInTests {
+
+}
diff --git a/timemanager/src/test/java/eu/arrowhead/core/timemanager/TimeManagerControllerSystemTest.java b/timemanager/src/test/java/eu/arrowhead/core/timemanager/TimeManagerControllerSystemTest.java
new file mode 100644
index 000000000..6b6f52bc3
--- /dev/null
+++ b/timemanager/src/test/java/eu/arrowhead/core/timemanager/TimeManagerControllerSystemTest.java
@@ -0,0 +1,87 @@
+package eu.arrowhead.core.timemanager;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import eu.arrowhead.common.exception.InvalidParameterException;
+import eu.arrowhead.core.timemanager.database.service.TimeManagerDBService;
+
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.mock.mockito.MockBean;
+import org.springframework.http.MediaType;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.web.servlet.MockMvc;
+import org.springframework.test.web.servlet.MvcResult;
+import org.springframework.test.web.servlet.setup.MockMvcBuilders;
+import org.springframework.web.context.WebApplicationContext;
+
+import java.io.IOException;
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.reset;
+import static org.mockito.Mockito.when;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.patch;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest
+@ContextConfiguration(classes = {TimeManagerTestContext.class})
+public class TimeManagerControllerSystemTest {
+
+    //=================================================================================================
+    // test data
+
+    //=================================================================================================
+    // members
+
+    @Autowired
+    private WebApplicationContext wac;
+
+    private MockMvc mockMvc;
+
+    @Autowired
+    private ObjectMapper objectMapper;
+
+    @MockBean(name = "mockTimeManagerDBService")
+    private TimeManagerDBService timeManagerDBService;
+
+    private static final String TIMEMANAGER_ECHO_URI  = "/timemanager/echo";
+    private static final String TIMEMANAGER_TIME_URI  = "/timemanager/time";
+
+    //=================================================================================================
+    // methods
+
+    //-------------------------------------------------------------------------------------------------
+    @Before
+    public void setup() {
+        //reset(timeManagerDBService);
+        //this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build();
+    }
+
+    //=================================================================================================
+    // Tests of Echo service
+
+    @Test
+    public void echoTM() throws Exception {
+        /*final MvcResult response = this.mockMvc.perform(get(TIMEMANAGER_ECHO_URI)
+                                               .accept(MediaType.APPLICATION_JSON))
+                                               .andExpect(status().isOk())
+                                               .andReturn();
+        assertEquals("Got it!", response.getResponse().getContentAsString());*/
+    }
+
+}
diff --git a/timemanager/src/test/java/eu/arrowhead/core/timemanager/TimeManagerTestContext.java b/timemanager/src/test/java/eu/arrowhead/core/timemanager/TimeManagerTestContext.java
new file mode 100644
index 000000000..60946f7c3
--- /dev/null
+++ b/timemanager/src/test/java/eu/arrowhead/core/timemanager/TimeManagerTestContext.java
@@ -0,0 +1,32 @@
+package eu.arrowhead.core.timemanager;
+
+import eu.arrowhead.common.CommonConstants;
+import org.mockito.Mockito;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
+import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration;
+import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.FilterType;
+import org.springframework.context.annotation.Primary;
+
+@Configuration
+@ComponentScan(basePackages = CommonConstants.BASE_PACKAGE,
+        excludeFilters = {
+                @ComponentScan.Filter(type = FilterType.REGEX, pattern = ".*database.*"),
+                @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = TimeManagerMain.class),
+        })
+@SpringBootApplication()
+public class TimeManagerTestContext {
+
+    //=================================================================================================
+    // methods
+
+    public TimeManagerTestContext() {
+    }
+
+    //-------------------------------------------------------------------------------------------------
+
+}

From 60b1dbfdf38145087927e0c9daf6c705aeeb4424 Mon Sep 17 00:00:00 2001
From: Jens Eliasson <jens.eliasson@gmail.com>
Date: Wed, 12 May 2021 16:13:18 +0200
Subject: [PATCH 02/53] addec certificates

---
 certificates/testcloud1/timemanager.p12          | Bin 0 -> 6145 bytes
 certificates/testcloud2/timemanager.p12          | Bin 0 -> 6201 bytes
 .../main/resources/certificates/timemanager.p12  | Bin 0 -> 6201 bytes
 3 files changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 certificates/testcloud1/timemanager.p12
 create mode 100644 certificates/testcloud2/timemanager.p12
 create mode 100644 timemanager/src/main/resources/certificates/timemanager.p12

diff --git a/certificates/testcloud1/timemanager.p12 b/certificates/testcloud1/timemanager.p12
new file mode 100644
index 0000000000000000000000000000000000000000..625b3aa18f4c9f2115087cdc1e434fc679815fe3
GIT binary patch
diff --git a/certificates/testcloud2/timemanager.p12 b/certificates/testcloud2/timemanager.p12
new file mode 100644
index 0000000000000000000000000000000000000000..52456f3a72c91a01328e4904d7559874f9ffa2ec
GIT binary patch
diff --git a/timemanager/src/main/resources/certificates/timemanager.p12 b/timemanager/src/main/resources/certificates/timemanager.p12
new file mode 100644
index 0000000000000000000000000000000000000000..52456f3a72c91a01328e4904d7559874f9ffa2ec
GIT binary patch

From 733794e8bf4c80a87edd3d7faa3a56987fff4e03 Mon Sep 17 00:00:00 2001
From: Jens Eliasson <jens.eliasson@gmail.com>
Date: Sun, 16 May 2021 15:34:16 +0200
Subject: [PATCH 03/53] preparing code skeleton

---
 .../shared/TimeManagerTimeResponseDTO.java    | 62 +++++++++++++++++--
 .../timemanager/TimeManagerController.java    |  2 +-
 .../core/timemanager/service/TimeService.java |  8 +--
 3 files changed, 63 insertions(+), 9 deletions(-)

diff --git a/core-common/src/main/java/eu/arrowhead/common/dto/shared/TimeManagerTimeResponseDTO.java b/core-common/src/main/java/eu/arrowhead/common/dto/shared/TimeManagerTimeResponseDTO.java
index 0406430c1..ab1ce6c10 100644
--- a/core-common/src/main/java/eu/arrowhead/common/dto/shared/TimeManagerTimeResponseDTO.java
+++ b/core-common/src/main/java/eu/arrowhead/common/dto/shared/TimeManagerTimeResponseDTO.java
@@ -1,8 +1,10 @@
 package eu.arrowhead.common.dto.shared;
 
+import java.util.Date;
+import java.util.TimeZone;
 import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
+//import java.util.ArrayList;
+//import java.util.List;
 
 public class TimeManagerTimeResponseDTO implements Serializable {
 
@@ -10,12 +12,64 @@ public class TimeManagerTimeResponseDTO implements Serializable {
         // members
         
         private static final long serialVersionUID = 1248856742138137282L;
-        
+
+        private long epoch;
+        private long epoch_ms;
+        private String tz;
+        private boolean inDaylightTime;
                 
         //=================================================================================================
         // methods
         
         //-------------------------------------------------------------------------------------------------
-        public TimeManagerTimeResponseDTO() {}
+        public TimeManagerTimeResponseDTO() {
+                Date date = new Date();
+                epoch_ms = date.getTime();
+                epoch = epoch_ms / 1000;
+
+                tz = new String("Europe/London");
+                inDaylightTime = TimeZone.getTimeZone(this.tz).inDaylightTime(date);
+        }
+
+        public TimeManagerTimeResponseDTO(final long epoch, final String tz) {
+                Date date = new Date(epoch*1000);
+                this.epoch = epoch;
+                this.epoch_ms = epoch * 1000;
+                this.tz = tz;
+
+                inDaylightTime = TimeZone.getTimeZone(this.tz).inDaylightTime(date);
+        }
+
+        public void setEpoch(long epoch) {
+                this.epoch = epoch;
+        }
+            
+        public long getEpoch() {
+                return epoch;
+        }
+
+        public void setEpoch_ms(long epoch_ms) {
+                this.epoch_ms = epoch_ms;
+        }
+            
+        public long getEpoch_ms() {
+                return epoch_ms;
+        }
+
+        public void setTz(String tz) {
+                this.tz = tz;
+        }
+            
+        public String getTz() {
+                return tz;
+        }
+
+        public void setInDaylightTime(boolean inDaylightTime) {
+                this.inDaylightTime = inDaylightTime;
+        }
+            
+        public boolean getInDaylightTime() {
+                return inDaylightTime;
+        }
 	
 }
diff --git a/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeManagerController.java b/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeManagerController.java
index 2f4081ebc..a6c60e847 100644
--- a/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeManagerController.java
+++ b/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeManagerController.java
@@ -112,7 +112,7 @@ public class TimeManagerController {
 			) {
 		logger.debug("timeGet");
 
-        TimeManagerTimeResponseDTO resp = null;
+        TimeManagerTimeResponseDTO resp = new TimeManagerTimeResponseDTO();
 		return resp;
 	}
 
diff --git a/timemanager/src/main/java/eu/arrowhead/core/timemanager/service/TimeService.java b/timemanager/src/main/java/eu/arrowhead/core/timemanager/service/TimeService.java
index 504aa7d27..dc668dcdb 100644
--- a/timemanager/src/main/java/eu/arrowhead/core/timemanager/service/TimeService.java
+++ b/timemanager/src/main/java/eu/arrowhead/core/timemanager/service/TimeService.java
@@ -28,10 +28,10 @@
 import eu.arrowhead.common.exception.InvalidParameterException;
 import eu.arrowhead.core.timemanager.database.service.TimeManagerDBService;
 
-import java.util.List;
-import java.util.ArrayList; 
-import java.util.Iterator; 
-import java.util.Vector;
+//import java.util.List;
+//import java.util.ArrayList; 
+//import java.util.Iterator; 
+//import java.util.Vector;
 
 
 @Service

From 863438f409f56fb157685a3cd6dc0b3654746ad5 Mon Sep 17 00:00:00 2001
From: Jens Eliasson <jens.eliasson@gmail.com>
Date: Tue, 6 Jul 2021 23:20:05 +0200
Subject: [PATCH 04/53] websocket support start

---
 pom.xml | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/pom.xml b/pom.xml
index 7d102eccc..18675ff2c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -30,17 +30,17 @@
 	    <module>orchestrator</module>
 	    <module>eventhandler</module>
 	    <module>datamanager</module>
-		<module>timemanager</module>
+	    <module>timemanager</module>
 	    <module>relay-library</module>
 	    <module>gatekeeper</module>
 	    <module>gateway</module>
 	    <module>choreographer</module>
-		<module>systemregistry</module>
-		<module>deviceregistry</module>
-		<module>onboarding</module>
+	    <module>systemregistry</module>
+	    <module>deviceregistry</module>
+	    <module>onboarding</module>
 	    <module>deb-installer</module>
 	    <module>docker-all</module>
-		<module>translator</module>
+	    <module>translator</module>
   	</modules>
   	
 	<properties>
@@ -114,6 +114,10 @@
 			<groupId>org.springframework.boot</groupId>
 			<artifactId>spring-boot-starter-web</artifactId>
 		</dependency>
+		<dependency>
+                        <groupId>org.springframework.boot</groupId>
+                        <artifactId>spring-boot-starter-websocket</artifactId>
+                </dependency>
 		<dependency>
 		    <groupId>org.springframework.boot</groupId>
     		<artifactId>spring-boot-configuration-processor</artifactId>

From 156f300fd95a1e5731caabe494861dcf4ea6e6ce Mon Sep 17 00:00:00 2001
From: Jens Eliasson <jens.eliasson@gmail.com>
Date: Sun, 11 Jul 2021 20:34:46 +0200
Subject: [PATCH 05/53] merged with development

---
 .../src/main/java/eu/arrowhead/common/CommonConstants.java    | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/core-common/src/main/java/eu/arrowhead/common/CommonConstants.java b/core-common/src/main/java/eu/arrowhead/common/CommonConstants.java
index 7ab576709..d023e5a25 100644
--- a/core-common/src/main/java/eu/arrowhead/common/CommonConstants.java
+++ b/core-common/src/main/java/eu/arrowhead/common/CommonConstants.java
@@ -78,12 +78,10 @@ public class CommonConstants {
 	public static final String CORE_SERVICE_DATAMANAGER_PROXY = "proxy";
 	public static final String CORE_SERVICE_DATAMANAGER_HISTORIAN = "historian";
 
-<<<<<<< HEAD
 	public static final String CORE_SERVICE_TIMEMANAGER_TIME = "time";
-=======
+	
 	public static final String CORE_SERVICE_CONFIGURATION_CONF = "conf";
 	public static final String CORE_SERVICE_CONFIGURATION_RAWCONF = "confraw";
->>>>>>> development
 
 	public static final String CORE_SERVICE_CHOREOGRAPHER_PROCESS = "choreographer-service";
 

From 830ebc549ef35bb4a08ca71aba140fba112f01a0 Mon Sep 17 00:00:00 2001
From: Jens Eliasson <jens.eliasson@gmail.com>
Date: Sun, 11 Jul 2021 21:00:25 +0200
Subject: [PATCH 06/53] basic functionality is operational!

---
 .../dto/shared/TimeManagerTimeResponseDTO.java       |  9 +++++----
 .../core/timemanager/TimeManagerController.java      | 12 +++++++-----
 .../src/main/resources/application.properties        |  1 +
 3 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/core-common/src/main/java/eu/arrowhead/common/dto/shared/TimeManagerTimeResponseDTO.java b/core-common/src/main/java/eu/arrowhead/common/dto/shared/TimeManagerTimeResponseDTO.java
index ab1ce6c10..89cb76f14 100644
--- a/core-common/src/main/java/eu/arrowhead/common/dto/shared/TimeManagerTimeResponseDTO.java
+++ b/core-common/src/main/java/eu/arrowhead/common/dto/shared/TimeManagerTimeResponseDTO.java
@@ -3,11 +3,11 @@
 import java.util.Date;
 import java.util.TimeZone;
 import java.io.Serializable;
-//import java.util.ArrayList;
-//import java.util.List;
+
 
 public class TimeManagerTimeResponseDTO implements Serializable {
 
+
         //=================================================================================================
         // members
         
@@ -22,12 +22,13 @@ public class TimeManagerTimeResponseDTO implements Serializable {
         // methods
         
         //-------------------------------------------------------------------------------------------------
-        public TimeManagerTimeResponseDTO() {
+        public TimeManagerTimeResponseDTO(final String tz) {
+                this.tz = tz;
+                
                 Date date = new Date();
                 epoch_ms = date.getTime();
                 epoch = epoch_ms / 1000;
 
-                tz = new String("Europe/London");
                 inDaylightTime = TimeZone.getTimeZone(this.tz).inDaylightTime(date);
         }
 
diff --git a/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeManagerController.java b/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeManagerController.java
index a6c60e847..6ccb83a6f 100644
--- a/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeManagerController.java
+++ b/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeManagerController.java
@@ -71,16 +71,18 @@
 @RestController
 @RequestMapping(CommonConstants.TIMEMANAGER_URI)
 public class TimeManagerController {
-	
+	private final Logger logger = LogManager.getLogger(TimeManagerController.class);
+
+	@Value("${serverTimezone}")
+    private String serverTimeZone;
+
 	//=================================================================================================
 	// members
 	
 	private static final String OP_NOT_VALID_ERROR_MESSAGE = " Illegal operation. ";
 	private static final String NOT_FOUND_ERROR_MESSAGE = " Resource not found. ";
 	
-	private final Logger logger = LogManager.getLogger(TimeManagerController.class);
-
-	@Autowired
+	@Autowired 
 	private TimeService timeService;
 
 	@Autowired
@@ -112,7 +114,7 @@ public class TimeManagerController {
 			) {
 		logger.debug("timeGet");
 
-        TimeManagerTimeResponseDTO resp = new TimeManagerTimeResponseDTO();
+        TimeManagerTimeResponseDTO resp = new TimeManagerTimeResponseDTO(serverTimeZone);
 		return resp;
 	}
 
diff --git a/timemanager/src/main/resources/application.properties b/timemanager/src/main/resources/application.properties
index 1e244af40..8e3795dfd 100644
--- a/timemanager/src/main/resources/application.properties
+++ b/timemanager/src/main/resources/application.properties
@@ -35,6 +35,7 @@ log_all_request_and_response=false
 sr_address=127.0.0.1
 sr_port=8443
 
+serverTimezone=Europe/Budapest
 
 ############################################
 ###           SECURE MODE                ###

From c58f7ad40ccc74723488f5fbe48b03846c64bac6 Mon Sep 17 00:00:00 2001
From: Jens Eliasson <jens.eliasson@gmail.com>
Date: Sun, 11 Jul 2021 22:47:07 +0200
Subject: [PATCH 07/53] added paho maven dependency

---
 pom.xml | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/pom.xml b/pom.xml
index 9633dcd84..dad0fa3b1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -207,6 +207,12 @@
       		<version>2.8.6</version>
 	</dependency>
 
+	<dependency>
+		<groupId>org.eclipse.paho</groupId>
+		<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
+		<version>1.2.0</version>
+	</dependency>
+
 		<dependency>
 			<groupId>org.springframework.boot</groupId>
 			<artifactId>spring-boot-starter-test</artifactId>

From a72b802ed8f971d8d4d51d18dd14bf2cb4b9f4dd Mon Sep 17 00:00:00 2001
From: Jens Eliasson <jens.eliasson@gmail.com>
Date: Mon, 12 Jul 2021 08:30:03 +0200
Subject: [PATCH 08/53] added SSL methods for MQTT

---
 .../java/eu/arrowhead/common/SslUtil.java     | 118 ++++++++++++++++++
 pom.xml                                       |   3 +-
 2 files changed, 120 insertions(+), 1 deletion(-)
 create mode 100644 core-common/src/main/java/eu/arrowhead/common/SslUtil.java

diff --git a/core-common/src/main/java/eu/arrowhead/common/SslUtil.java b/core-common/src/main/java/eu/arrowhead/common/SslUtil.java
new file mode 100644
index 000000000..2d7f9ea6f
--- /dev/null
+++ b/core-common/src/main/java/eu/arrowhead/common/SslUtil.java
@@ -0,0 +1,118 @@
+/********************************************************************************
+ * Copyright (c) 2019 AITIA
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ *   AITIA - implementation
+ *   Arrowhead Consortia - conceptualization
+ ********************************************************************************/
+
+package eu.arrowhead.common;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.core.io.Resource;
+import org.springframework.stereotype.Component;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.nio.file.Files;
+import java.nio.file.InvalidPathException;
+import java.nio.file.Paths;
+import java.security.KeyManagementException;
+import java.security.KeyPair;
+import java.security.KeyStore;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.Security;
+import java.security.UnrecoverableKeyException;
+import java.security.cert.CertificateException;
+ 
+import javax.net.ssl.KeyManagerFactory;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLSocketFactory;
+import javax.net.ssl.TrustManagerFactory;
+ 
+import org.bouncycastle.cert.X509CertificateHolder;
+import org.bouncycastle.cert.jcajce.JcaX509CertificateConverter;
+import org.bouncycastle.jce.provider.BouncyCastleProvider;
+import org.bouncycastle.openssl.PEMDecryptorProvider;
+import org.bouncycastle.openssl.PEMEncryptedKeyPair;
+import org.bouncycastle.openssl.PEMKeyPair;
+import org.bouncycastle.openssl.PEMParser;
+import org.bouncycastle.openssl.jcajce.JcaPEMKeyConverter;
+import org.bouncycastle.openssl.jcajce.JcePEMDecryptorProviderBuilder;
+ 
+@Component
+public class SslUtil
+{
+    private final Logger logger = LogManager.getLogger(SslUtil.class);
+
+    //=================================================================================================
+	// methods
+
+	//-------------------------------------------------------------------------------------------------
+
+    public static SSLSocketFactory getSslSocketFactory(final String caCrtFile, final String crtFile, final String keyFile, final String password)
+              throws
+                     InvalidPathException, IOException, KeyStoreException, NoSuchAlgorithmException, CertificateException,
+                     UnrecoverableKeyException, KeyManagementException, Exception {
+              Security.addProvider(new BouncyCastleProvider());
+             
+              // load CA certificate
+              PEMParser parser = new PEMParser(new InputStreamReader(new ByteArrayInputStream(Files.readAllBytes(Paths.get(caCrtFile)))));
+              X509CertificateHolder caCert = (X509CertificateHolder) parser.readObject();
+              parser.close();
+
+              // load client certificate
+              parser = new PEMParser(new InputStreamReader(new ByteArrayInputStream(Files.readAllBytes(Paths.get(crtFile)))));
+              X509CertificateHolder cert = (X509CertificateHolder) parser.readObject();
+              parser.close();
+
+              // load client private key
+              parser = new PEMParser(new InputStreamReader(new ByteArrayInputStream(Files.readAllBytes(Paths.get(keyFile)))));
+              Object obj = parser.readObject();
+              KeyPair key = null;
+              JcaPEMKeyConverter converter = new JcaPEMKeyConverter().setProvider("BC");
+              if (obj instanceof PEMEncryptedKeyPair) {
+                     PEMDecryptorProvider decProv = new JcePEMDecryptorProviderBuilder().build(password.toCharArray());
+                     converter = new JcaPEMKeyConverter().setProvider("BC");
+                     key = converter.getKeyPair(((PEMEncryptedKeyPair) obj).decryptKeyPair(decProv));
+              } else {
+                     key = converter.getKeyPair((PEMKeyPair) obj);
+              }
+              parser.close();
+            
+              JcaX509CertificateConverter certConverter = new JcaX509CertificateConverter();
+              certConverter.setProvider("BC");
+
+              // CA certificate is used to authenticate server
+              KeyStore caKs = KeyStore.getInstance(KeyStore.getDefaultType());
+              caKs.load(null, null);
+              caKs.setCertificateEntry("ca-certificate", certConverter.getCertificate(caCert));
+              TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
+              tmf.init(caKs);
+
+              // Client key and certificates are sent to server so it can authenticate us
+              KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
+              ks.load(null, null);
+              ks.setCertificateEntry("certificate", certConverter.getCertificate(cert));
+              ks.setKeyEntry("private-key", key.getPrivate(), password.toCharArray(), new java.security.cert.Certificate[]{certConverter.getCertificate(cert)});
+              KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
+              kmf.init(ks, password.toCharArray());
+
+              // Finally, create SSL socket factory
+              SSLContext context = SSLContext.getInstance("TLSv1.3");
+              context.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
+
+              return context.getSocketFactory();
+       }
+}
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index dad0fa3b1..d1cee7d48 100644
--- a/pom.xml
+++ b/pom.xml
@@ -65,6 +65,7 @@
   		<activemq.client.version>5.15.9</activemq.client.version>
 		<bouncy.castle.version>1.64</bouncy.castle.version>
   		<jna.version>5.5.0</jna.version>
+		<paho.version>1.2.0</paho.version>
 		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
 	</properties>
 
@@ -210,7 +211,7 @@
 	<dependency>
 		<groupId>org.eclipse.paho</groupId>
 		<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
-		<version>1.2.0</version>
+		<version>${paho.version}</version>
 	</dependency>
 
 		<dependency>

From cffd7ec61a342313299aee8a8b1d89d96237e95c Mon Sep 17 00:00:00 2001
From: Jens Eliasson <jens.eliasson@gmail.com>
Date: Mon, 12 Jul 2021 09:02:50 +0200
Subject: [PATCH 09/53] created skeleton

---
 .../protocols/mqtt/MqttTimeManager.java       | 62 +++++++++++++++++++
 1 file changed, 62 insertions(+)
 create mode 100644 timemanager/src/main/java/eu/arrowhead/core/timemanager/protocols/mqtt/MqttTimeManager.java

diff --git a/timemanager/src/main/java/eu/arrowhead/core/timemanager/protocols/mqtt/MqttTimeManager.java b/timemanager/src/main/java/eu/arrowhead/core/timemanager/protocols/mqtt/MqttTimeManager.java
new file mode 100644
index 000000000..febd21cfb
--- /dev/null
+++ b/timemanager/src/main/java/eu/arrowhead/core/timemanager/protocols/mqtt/MqttTimeManager.java
@@ -0,0 +1,62 @@
+package eu.arrowhead.core.timemanager.protocols.mqtt;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import javax.annotation.PostConstruct;
+
+import eu.arrowhead.common.CommonConstants;
+import eu.arrowhead.common.CoreDefaults;
+import eu.arrowhead.common.CoreCommonConstants;
+import eu.arrowhead.common.CoreUtilities;
+import eu.arrowhead.common.Utilities;
+import eu.arrowhead.common.SslUtil;
+
+import org.springframework.stereotype.Component;
+
+import org.eclipse.paho.client.mqttv3.MqttClient;
+import org.eclipse.paho.client.mqttv3.MqttCallback;
+import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken;
+import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
+import org.eclipse.paho.client.mqttv3.MqttException;
+import org.eclipse.paho.client.mqttv3.MqttMessage;
+import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLSocketFactory;
+
+@Component
+public class MqttTimeManager implements MqttCallback, Runnable {
+
+    // =================================================================================================
+    // members
+    private final Logger logger = LogManager.getLogger(MqttTimeManager.class);
+
+
+    // =================================================================================================
+    // methods
+    // -------------------------------------------------------------------------------------------------
+    @PostConstruct
+    public void init() {
+    }
+
+    @Override
+    public void run() {
+    
+    }
+
+    @Override
+    public void connectionLost(Throwable cause) {
+    
+    
+    }
+  
+    @Override
+    public void messageArrived(String topic, MqttMessage message) {
+    
+    }
+
+    @Override
+    public void deliveryComplete(IMqttDeliveryToken token) {
+
+    }
+}
\ No newline at end of file

From 8caa2924a8124812654c4b74c67cec7322da91d6 Mon Sep 17 00:00:00 2001
From: Jens Eliasson <jens.eliasson@gmail.com>
Date: Mon, 12 Jul 2021 10:09:03 +0200
Subject: [PATCH 10/53] merged

---
 .../eu/arrowhead/common/CommonConstants.java   | 10 +---------
 .../arrowhead/common/CoreCommonConstants.java  | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/core-common/src/main/java/eu/arrowhead/common/CommonConstants.java b/core-common/src/main/java/eu/arrowhead/common/CommonConstants.java
index 29c214bd0..453094b5a 100644
--- a/core-common/src/main/java/eu/arrowhead/common/CommonConstants.java
+++ b/core-common/src/main/java/eu/arrowhead/common/CommonConstants.java
@@ -286,17 +286,9 @@ public class CommonConstants {
 	
 	public static final List<CoreSystemService> PUBLIC_CORE_SYSTEM_SERVICES = List.of(CoreSystemService.ORCHESTRATION_SERVICE, CoreSystemService.AUTH_PUBLIC_KEY_SERVICE,
   			  																		  CoreSystemService.EVENT_PUBLISH_SERVICE, CoreSystemService.EVENT_SUBSCRIBE_SERVICE, CoreSystemService.EVENT_UNSUBSCRIBE_SERVICE, 
-<<<<<<< HEAD
-<<<<<<< HEAD
-																					  CoreSystemService.PROXY_SERVICE, CoreSystemService.TIME_SERVICE, CoreSystemService.HISTORIAN_SERVICE, CoreSystemService.CHOREOGRAPHER_SERVICE, CoreSystemService.TRANSLATOR_SERVICE);
-=======
-																					  CoreSystemService.PROXY_SERVICE, CoreSystemService.HISTORIAN_SERVICE, CoreSystemService.CHOREOGRAPHER_SERVICE, CoreSystemService.TRANSLATOR_SERVICE,
-	       																			  CoreSystemService.CONFIGURATION_SERVICE, CoreSystemService.CONFIGURATION_RAW_SERVICE);
->>>>>>> 83340328b963097e7b5778725f5bab8da8050e6f
-=======
 																					  CoreSystemService.PROXY_SERVICE, CoreSystemService.HISTORIAN_SERVICE, CoreSystemService.CHOREOGRAPHER_SERVICE, CoreSystemService.TRANSLATOR_SERVICE,
 	       																			  CoreSystemService.CONFIGURATION_SERVICE, CoreSystemService.CONFIGURATION_RAW_SERVICE, CoreSystemService.TIME_SERVICE);
->>>>>>> cffd7ec61a342313299aee8a8b1d89d96237e95c
+
 	
 	public static final String HTTP_CLIENT_CONNECTION_TIMEOUT = "http.client.connection.timeout";
 	public static final String $HTTP_CLIENT_CONNECTION_TIMEOUT_WD = "${" + HTTP_CLIENT_CONNECTION_TIMEOUT + ":" + Defaults.DEFAULT_CONNECTION_TIMEOUT + "}";
diff --git a/core-common/src/main/java/eu/arrowhead/common/CoreCommonConstants.java b/core-common/src/main/java/eu/arrowhead/common/CoreCommonConstants.java
index 5370c8999..3aedc23b0 100644
--- a/core-common/src/main/java/eu/arrowhead/common/CoreCommonConstants.java
+++ b/core-common/src/main/java/eu/arrowhead/common/CoreCommonConstants.java
@@ -241,6 +241,24 @@ public class CoreCommonConstants {
     public static final String FIWARE_SERVER_PORT = "fiware.server.port";
     public static final String $FIWARE_SERVER_PORT = "${" + FIWARE_SERVER_PORT + ":0}";
 
+	// MQTT 
+	public static final String MQTT_BROKER_ENABLED = "mqtt.broker.enabled";
+	public static final String $MQTT_BROKER_ENABLED = "${" + MQTT_BROKER_ENABLED + ":false}";
+	public static final String MQTT_BROKER_ADDRESS = "mqtt.broker.address";
+	public static final String $MQTT_BROKER_ADDRESS = "${" + MQTT_BROKER_ADDRESS + ":0.0.0.0}";
+	public static final String MQTT_BROKER_PORT = "mqtt.broker.port";
+	public static final String $MQTT_BROKER_PORT = "${" + MQTT_BROKER_PORT + ":0}";
+	public static final String MQTT_BROKER_USERNAME = "mqtt.broker.username";
+	public static final String $MQTT_BROKER_USERNAME = "${" + MQTT_BROKER_USERNAME + ":}";
+	public static final String MQTT_BROKER_PASSWORD = "mqtt.broker.password";
+	public static final String $MQTT_BROKER_PASSWORD = "${" + MQTT_BROKER_PASSWORD + ":}";
+	public static final String MQTT_BROKER_CAFILE = "mqtt.broker.cafile";
+	public static final String $MQTT_BROKER_CAFILE = "${" + MQTT_BROKER_CAFILE + ":}";
+	public static final String MQTT_BROKER_CERTFILE = "mqtt.broker.certfile";
+	public static final String $MQTT_BROKER_CERTFILE = "${" + MQTT_BROKER_CERTFILE + ":}";
+	public static final String MQTT_BROKER_KEYFILE = "mqtt.broker.keyfile";
+	public static final String $MQTT_BROKER_KEYFILE = "${" + MQTT_BROKER_KEYFILE + ":}";
+
     //=================================================================================================
 	// assistant methods
 

From ab213bc2de5d21a74ab6aca3745b7badc8ef695c Mon Sep 17 00:00:00 2001
From: Jens Eliasson <jens.eliasson@gmail.com>
Date: Mon, 12 Jul 2021 11:04:48 +0200
Subject: [PATCH 11/53] MQTT removed

---
 .../protocols/mqtt/MqttTimeManager.java       | 62 -------------------
 1 file changed, 62 deletions(-)
 delete mode 100644 timemanager/src/main/java/eu/arrowhead/core/timemanager/protocols/mqtt/MqttTimeManager.java

diff --git a/timemanager/src/main/java/eu/arrowhead/core/timemanager/protocols/mqtt/MqttTimeManager.java b/timemanager/src/main/java/eu/arrowhead/core/timemanager/protocols/mqtt/MqttTimeManager.java
deleted file mode 100644
index febd21cfb..000000000
--- a/timemanager/src/main/java/eu/arrowhead/core/timemanager/protocols/mqtt/MqttTimeManager.java
+++ /dev/null
@@ -1,62 +0,0 @@
-package eu.arrowhead.core.timemanager.protocols.mqtt;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-
-import javax.annotation.PostConstruct;
-
-import eu.arrowhead.common.CommonConstants;
-import eu.arrowhead.common.CoreDefaults;
-import eu.arrowhead.common.CoreCommonConstants;
-import eu.arrowhead.common.CoreUtilities;
-import eu.arrowhead.common.Utilities;
-import eu.arrowhead.common.SslUtil;
-
-import org.springframework.stereotype.Component;
-
-import org.eclipse.paho.client.mqttv3.MqttClient;
-import org.eclipse.paho.client.mqttv3.MqttCallback;
-import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken;
-import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
-import org.eclipse.paho.client.mqttv3.MqttException;
-import org.eclipse.paho.client.mqttv3.MqttMessage;
-import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLSocketFactory;
-
-@Component
-public class MqttTimeManager implements MqttCallback, Runnable {
-
-    // =================================================================================================
-    // members
-    private final Logger logger = LogManager.getLogger(MqttTimeManager.class);
-
-
-    // =================================================================================================
-    // methods
-    // -------------------------------------------------------------------------------------------------
-    @PostConstruct
-    public void init() {
-    }
-
-    @Override
-    public void run() {
-    
-    }
-
-    @Override
-    public void connectionLost(Throwable cause) {
-    
-    
-    }
-  
-    @Override
-    public void messageArrived(String topic, MqttMessage message) {
-    
-    }
-
-    @Override
-    public void deliveryComplete(IMqttDeliveryToken token) {
-
-    }
-}
\ No newline at end of file

From d78f4e3867bfd740618ba70efeeca924dc912350 Mon Sep 17 00:00:00 2001
From: Jens Eliasson <jens.eliasson@gmail.com>
Date: Mon, 12 Jul 2021 11:40:53 +0200
Subject: [PATCH 12/53] utests

---
 .../core/timemanager/TimeManagerControllerSystemTest.java | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/timemanager/src/test/java/eu/arrowhead/core/timemanager/TimeManagerControllerSystemTest.java b/timemanager/src/test/java/eu/arrowhead/core/timemanager/TimeManagerControllerSystemTest.java
index 6b6f52bc3..1d9c79f04 100644
--- a/timemanager/src/test/java/eu/arrowhead/core/timemanager/TimeManagerControllerSystemTest.java
+++ b/timemanager/src/test/java/eu/arrowhead/core/timemanager/TimeManagerControllerSystemTest.java
@@ -68,8 +68,8 @@ public class TimeManagerControllerSystemTest {
     //-------------------------------------------------------------------------------------------------
     @Before
     public void setup() {
-        //reset(timeManagerDBService);
-        //this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build();
+        reset(timeManagerDBService);
+        this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build();
     }
 
     //=================================================================================================
@@ -77,11 +77,11 @@ public void setup() {
 
     @Test
     public void echoTM() throws Exception {
-        /*final MvcResult response = this.mockMvc.perform(get(TIMEMANAGER_ECHO_URI)
+        final MvcResult response = this.mockMvc.perform(get(TIMEMANAGER_ECHO_URI)
                                                .accept(MediaType.APPLICATION_JSON))
                                                .andExpect(status().isOk())
                                                .andReturn();
-        assertEquals("Got it!", response.getResponse().getContentAsString());*/
+        assertEquals("Got it!", response.getResponse().getContentAsString());
     }
 
 }

From 5ff280369e91f427ec2dc9c7b1e7408b1344ebf9 Mon Sep 17 00:00:00 2001
From: Jens Eliasson <jens.eliasson@gmail.com>
Date: Mon, 12 Jul 2021 14:49:05 +0200
Subject: [PATCH 13/53] WS now works

---
 timemanager/src/main/resources/application.properties | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/timemanager/src/main/resources/application.properties b/timemanager/src/main/resources/application.properties
index 8e3795dfd..5dfe81495 100644
--- a/timemanager/src/main/resources/application.properties
+++ b/timemanager/src/main/resources/application.properties
@@ -21,6 +21,9 @@ server.port=8463
 domain.name=127.0.0.1
 domain.port=8463
 
+# Websockets
+websockets.enabled=true
+
 ############################################
 ###       CUSTOM PARAMETERS              ###
 ############################################

From 6ec18b53b3f4b0aa63de0427e743fa313e2dd280 Mon Sep 17 00:00:00 2001
From: Jens Eliasson <jens.eliasson@gmail.com>
Date: Mon, 12 Jul 2021 14:49:27 +0200
Subject: [PATCH 14/53] WS now works

---
 .../core/timemanager/TimeManagerWSConfig.java | 108 ++++++++++++++++++
 .../core/timemanager/TimeWSHandler.java       |  89 +++++++++++++++
 2 files changed, 197 insertions(+)
 create mode 100644 timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeManagerWSConfig.java
 create mode 100644 timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeWSHandler.java

diff --git a/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeManagerWSConfig.java b/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeManagerWSConfig.java
new file mode 100644
index 000000000..81148b966
--- /dev/null
+++ b/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeManagerWSConfig.java
@@ -0,0 +1,108 @@
+/********************************************************************************
+ * Copyright (c) 2021 {Lulea University of Technology}
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0 
+ *
+ * Contributors: 
+ *   {Lulea University of Technology} - implementation
+ *   Arrowhead Consortia - conceptualization 
+ ********************************************************************************/
+package eu.arrowhead.core.timemanager;
+
+import java.util.Map;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import eu.arrowhead.common.SecurityUtilities;
+import eu.arrowhead.common.CommonConstants;
+import eu.arrowhead.core.timemanager.TimeWSHandler;
+//import eu.arrowhead.core.datamanager.security.DatamanagerACLFilter;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Bean;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.web.socket.config.annotation.EnableWebSocket;
+import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
+import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;
+import org.springframework.http.server.ServerHttpRequest;
+import org.springframework.http.server.ServerHttpResponse;
+import org.springframework.http.server.ServletServerHttpRequest;
+import javax.servlet.http.HttpServletRequest;
+import org.springframework.web.socket.WebSocketHandler;
+import org.springframework.web.socket.server.HandshakeInterceptor;
+
+ 
+@Configuration
+@EnableWebSocket
+public class TimeManagerWSConfig implements WebSocketConfigurer {
+ 
+    private final Logger logger = LogManager.getLogger(TimeManagerWSConfig.class);
+
+    @Value("${server.ssl.enabled}")
+    private boolean sslEnabled;
+
+    @Value("${websockets.enabled}")
+    private boolean websocketsEnabled;
+
+    @Autowired
+    TimeWSHandler timeWSHandler;
+
+    //@Autowired
+    //DatamanagerACLFilter dmACLFilter;
+
+    @Override
+    public void registerWebSocketHandlers(WebSocketHandlerRegistry webSocketHandlerRegistry) {
+	    if (websocketsEnabled) {
+            logger.info("WebSocket support enabled");
+            webSocketHandlerRegistry.addHandler(timeWSHandler, CommonConstants.TIMEMANAGER_URI + CommonConstants.OP_TIMEMANAGER_TIME + "/ws").addInterceptors(auctionInterceptor());
+	    } else {
+            logger.info("WebSocket support disabled");
+        }
+    }
+
+    @Bean
+    public HandshakeInterceptor auctionInterceptor() {
+        return new HandshakeInterceptor() {
+            public boolean beforeHandshake(ServerHttpRequest request, ServerHttpResponse response, 
+                WebSocketHandler wsHandler, Map<String, Object> attributes) throws Exception {
+
+                String path = request.getURI().getPath();
+                final String serviceId = path.substring(path.lastIndexOf('/') + 1);
+		        path = path.substring(0, path.lastIndexOf('/'));
+                final String systemId = path.substring(path.lastIndexOf('/') + 1);
+                String CN = null;
+
+                // if running in secure mode, check authorization (ACL)
+                if(sslEnabled) {  
+                    if (request instanceof org.springframework.http.server.ServletServerHttpRequest) {
+                        CN = SecurityUtilities.getCertificateCNFromServerRequest((ServletServerHttpRequest)request);
+                        if(CN == null) {
+                            logger.info("No valid client certificate found");
+                            return false;
+                        }
+                        attributes.put("CN", CN);
+                    } else {
+                        return false;
+                    }
+                }
+
+                // Add to the websocket session
+                attributes.put("systemId", systemId);
+                attributes.put("serviceId", serviceId);
+                
+                return true;
+            }
+
+            public void afterHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler, Exception exception) {
+                // tbd
+            }
+
+        };
+    }
+}
+
diff --git a/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeWSHandler.java b/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeWSHandler.java
new file mode 100644
index 000000000..137bc355a
--- /dev/null
+++ b/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeWSHandler.java
@@ -0,0 +1,89 @@
+/********************************************************************************
+ * Copyright (c) 2021 {Lulea University of Technology}
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0 
+ *
+ * Contributors: 
+ *   {Lulea University of Technology} - implementation
+ *   Arrowhead Consortia - conceptualization 
+ ********************************************************************************/
+package eu.arrowhead.core.timemanager;
+ 
+import java.io.IOException;
+import java.util.List;
+import java.util.Vector;
+import java.util.Map;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+import org.springframework.web.socket.CloseStatus;
+import org.springframework.web.socket.TextMessage;
+import org.springframework.web.socket.WebSocketSession;
+import org.springframework.web.socket.handler.TextWebSocketHandler;
+
+import eu.arrowhead.common.CommonConstants;
+//import eu.arrowhead.core.timemanager.security.TimemanagerACLFilter;
+import eu.arrowhead.common.Utilities;
+import eu.arrowhead.common.dto.shared.TimeManagerTimeResponseDTO;
+
+import com.google.gson.*;
+import com.google.gson.reflect.TypeToken;
+
+@Component
+@EnableScheduling
+public class TimeWSHandler extends TextWebSocketHandler {
+ 
+    private final Logger logger = LogManager.getLogger(TimeWSHandler.class);
+    //private Gson gson = new Gson();
+    
+    private final List<WebSocketSession> sessions = new CopyOnWriteArrayList<>();
+ 
+    @Value("${server.ssl.enabled}")
+    private boolean sslEnabled;
+
+    @Value("${serverTimezone}")
+    private String serverTimeZone;
+
+    //@Autowired
+    //TimemanagerACLFilter dataManagerACLFilter;
+
+    //=================================================================================================
+    // methods
+
+    @Override
+    public void afterConnectionEstablished(WebSocketSession session) throws Exception {
+        sessions.add(session);
+        super.afterConnectionEstablished(session);
+    }
+ 
+    @Override
+    public void afterConnectionClosed(WebSocketSession session, CloseStatus status) throws Exception {
+        sessions.remove(session);
+        super.afterConnectionClosed(session, status);
+    }
+ 
+    @Scheduled(fixedDelay = 1000 * 30, initialDelay = 1000)
+    public void sendOutTimeMessages() {
+        sessions.forEach(webSocketSession -> {
+            try {
+                TimeManagerTimeResponseDTO response = new TimeManagerTimeResponseDTO(serverTimeZone);
+                TextMessage msg = new TextMessage(Utilities.toJson(response).getBytes("UTF-8"));
+                webSocketSession.sendMessage(msg);
+            } catch (IOException e) {
+                logger.error("Error occurred.", e);
+            }
+        });
+        
+    }
+}
+

From 337a80ef367d1ff282fcaf66c30a2cd49b2fb088 Mon Sep 17 00:00:00 2001
From: Jens Eliasson <jens.eliasson@gmail.com>
Date: Tue, 13 Jul 2021 12:52:15 +0200
Subject: [PATCH 15/53] added support for NTP

---
 pom.xml                                       | 23 +++--
 .../core/timemanager/TimeManagerWSConfig.java |  2 +-
 .../service/TimeManagerDriver.java            | 87 +++++++++++++++++++
 .../src/main/resources/application.properties |  1 +
 4 files changed, 104 insertions(+), 9 deletions(-)
 create mode 100644 timemanager/src/main/java/eu/arrowhead/core/timemanager/service/TimeManagerDriver.java

diff --git a/pom.xml b/pom.xml
index d1cee7d48..16e821d44 100644
--- a/pom.xml
+++ b/pom.xml
@@ -201,29 +201,36 @@
 		</dependency>
 -->
 		
-	<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
-	<dependency>
+		<dependency>
       		<groupId>com.google.code.gson</groupId>
       		<artifactId>gson</artifactId>
       		<version>2.8.6</version>
-	</dependency>
+		</dependency>
 
-	<dependency>
-		<groupId>org.eclipse.paho</groupId>
-		<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
-		<version>${paho.version}</version>
-	</dependency>
+		<dependency>
+			<groupId>org.eclipse.paho</groupId>
+			<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
+			<version>${paho.version}</version>
+		</dependency>
+
+		<dependency>
+			<groupId>commons-net</groupId>
+			<artifactId>commons-net</artifactId>
+			<version>3.8.0</version>
+		</dependency>
 
 		<dependency>
 			<groupId>org.springframework.boot</groupId>
 			<artifactId>spring-boot-starter-test</artifactId>
 			<scope>test</scope>
 		</dependency>
+
 		<dependency>
 			<groupId>org.springframework.security</groupId>
 			<artifactId>spring-security-test</artifactId>
 			<scope>test</scope>
 		</dependency>
+
 	</dependencies>
 
 	<build>
diff --git a/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeManagerWSConfig.java b/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeManagerWSConfig.java
index 81148b966..fa6d4bfd8 100644
--- a/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeManagerWSConfig.java
+++ b/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeManagerWSConfig.java
@@ -53,7 +53,7 @@ public class TimeManagerWSConfig implements WebSocketConfigurer {
     TimeWSHandler timeWSHandler;
 
     //@Autowired
-    //DatamanagerACLFilter dmACLFilter;
+    //TimemanagerACLFilter timeACLFilter;
 
     @Override
     public void registerWebSocketHandlers(WebSocketHandlerRegistry webSocketHandlerRegistry) {
diff --git a/timemanager/src/main/java/eu/arrowhead/core/timemanager/service/TimeManagerDriver.java b/timemanager/src/main/java/eu/arrowhead/core/timemanager/service/TimeManagerDriver.java
new file mode 100644
index 000000000..bdc0aa9b6
--- /dev/null
+++ b/timemanager/src/main/java/eu/arrowhead/core/timemanager/service/TimeManagerDriver.java
@@ -0,0 +1,87 @@
+package eu.arrowhead.core.timemanager.service;
+
+import java.util.Vector;
+import java.util.Iterator;
+
+import javax.annotation.Resource;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.ResponseEntity;
+import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+import org.springframework.util.Assert;
+import org.springframework.web.util.UriComponents;
+
+import eu.arrowhead.common.CommonConstants;
+import eu.arrowhead.common.CoreCommonConstants;
+import eu.arrowhead.common.Utilities;
+import eu.arrowhead.common.core.CoreSystemService;
+import eu.arrowhead.common.exception.ArrowheadException;
+import eu.arrowhead.common.exception.BadPayloadException;
+import eu.arrowhead.common.exception.InvalidParameterException;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.SocketException;
+import org.apache.commons.net.ntp.NTPUDPClient;
+import org.apache.commons.net.ntp.TimeInfo;
+
+
+@Component
+@EnableScheduling
+public class TimeManagerDriver {
+
+	//=================================================================================================
+	// members
+	private static final Logger logger = LogManager.getLogger(TimeManagerDriver.class);
+
+	@Value("${ntp.server.list}")
+    private String serverList;
+
+	//=================================================================================================
+	// methods
+
+	@Scheduled(fixedDelay = 1000 * 60, initialDelay = 1000 * 5)
+    public void checkExternalTimeServer() {
+		logger.info("Checking external time!");
+	
+		final NTPUDPClient client = new NTPUDPClient();
+	
+		client.setDefaultTimeout(10000);
+		try {
+		  client.open();
+		  //for (final String arg : args) {
+			System.out.println();
+			try {
+			  // Ntp pool or server
+			  final InetAddress hostAddr = InetAddress.getByName("pool.ntp.org");
+			  System.out.println("> " + hostAddr.getHostName() + "/" + hostAddr.getHostAddress());
+			  
+			  // Get time from server
+			  final TimeInfo info = client.getTime(hostAddr);
+			  info.computeDetails(); // compute offset/delay if not already done
+			 
+			  // For printing
+			  final Long offsetMillis = info.getOffset();
+			  final Long delayMillis = info.getDelay();
+			  final String delay = delayMillis == null ? "n/a" : delayMillis.toString();
+			  final String offset = offsetMillis == null ? "n/a" : offsetMillis.toString();
+			  System.out.println(" Roundtrip delay(ms)=" + delay + ", clock offset(ms)=" + offset); // offset in ms
+			} catch (final IOException ioe) {
+			  ioe.printStackTrace();
+			}
+		  //}
+		} catch (final SocketException e) {
+		  e.printStackTrace();
+		}
+	
+		client.close();
+	  }
+	//=================================================================================================
+
+}
diff --git a/timemanager/src/main/resources/application.properties b/timemanager/src/main/resources/application.properties
index 5dfe81495..929bb3998 100644
--- a/timemanager/src/main/resources/application.properties
+++ b/timemanager/src/main/resources/application.properties
@@ -39,6 +39,7 @@ sr_address=127.0.0.1
 sr_port=8443
 
 serverTimezone=Europe/Budapest
+ntp.server.list=pool.ntp.org
 
 ############################################
 ###           SECURE MODE                ###

From b711b561e2ecb33fecc90c775c782f4072c5654d Mon Sep 17 00:00:00 2001
From: Jens Eliasson <jens.eliasson@gmail.com>
Date: Fri, 16 Jul 2021 10:33:57 +0200
Subject: [PATCH 16/53] NTP client works

---
 .../shared/TimeManagerTimeResponseDTO.java    | 74 +++++++++++--------
 .../timemanager/TimeManagerController.java    |  8 +-
 .../core/timemanager/TimeManagerWSConfig.java |  5 ++
 .../service/TimeManagerDriver.java            | 48 +++++++++---
 4 files changed, 90 insertions(+), 45 deletions(-)

diff --git a/core-common/src/main/java/eu/arrowhead/common/dto/shared/TimeManagerTimeResponseDTO.java b/core-common/src/main/java/eu/arrowhead/common/dto/shared/TimeManagerTimeResponseDTO.java
index 89cb76f14..cee5f9d1a 100644
--- a/core-common/src/main/java/eu/arrowhead/common/dto/shared/TimeManagerTimeResponseDTO.java
+++ b/core-common/src/main/java/eu/arrowhead/common/dto/shared/TimeManagerTimeResponseDTO.java
@@ -1,3 +1,17 @@
+/********************************************************************************
+ * Copyright (c) 2021 Lulea University of Technology
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ *   Lulea University of Technology - implementation
+ *   Arrowhead Consortia - conceptualization
+ ********************************************************************************/
+
 package eu.arrowhead.common.dto.shared;
 
 import java.util.Date;
@@ -11,12 +25,13 @@ public class TimeManagerTimeResponseDTO implements Serializable {
         //=================================================================================================
         // members
         
-        private static final long serialVersionUID = 1248856742138137282L;
+        private static final long serialVersionUID = 1648756742138137282L;
 
         private long epoch;
         private long epoch_ms;
         private String tz;
         private boolean inDaylightTime;
+        private boolean trusted;
                 
         //=================================================================================================
         // methods
@@ -30,47 +45,42 @@ public TimeManagerTimeResponseDTO(final String tz) {
                 epoch = epoch_ms / 1000;
 
                 inDaylightTime = TimeZone.getTimeZone(this.tz).inDaylightTime(date);
+                trusted = false;
         }
 
-        public TimeManagerTimeResponseDTO(final long epoch, final String tz) {
-                Date date = new Date(epoch*1000);
-                this.epoch = epoch;
-                this.epoch_ms = epoch * 1000;
+        public TimeManagerTimeResponseDTO(final String tz, final boolean trusted) {
                 this.tz = tz;
+                
+                Date date = new Date();
+                epoch_ms = date.getTime();
+                epoch = epoch_ms / 1000;
 
                 inDaylightTime = TimeZone.getTimeZone(this.tz).inDaylightTime(date);
+                this.trusted = trusted;
         }
 
-        public void setEpoch(long epoch) {
+        //-------------------------------------------------------------------------------------------------
+        public TimeManagerTimeResponseDTO(final long epoch, final String tz, final boolean trusted) {
+                Date date = new Date(epoch*1000);
                 this.epoch = epoch;
-        }
-            
-        public long getEpoch() {
-                return epoch;
-        }
+                this.epoch_ms = epoch * 1000;
+                this.tz = tz;
 
-        public void setEpoch_ms(long epoch_ms) {
-                this.epoch_ms = epoch_ms;
-        }
-            
-        public long getEpoch_ms() {
-                return epoch_ms;
+                inDaylightTime = TimeZone.getTimeZone(this.tz).inDaylightTime(date);
+                this.trusted = trusted;
         }
 
-        public void setTz(String tz) {
-                this.tz = tz;
-        }
-            
-        public String getTz() {
-                return tz;
-        }
+        //-------------------------------------------------------------------------------------------------
+        public long getEpoch() { return epoch; }
+        public long getEpoch_ms() { return epoch_ms; }
+        public String getTz() { return tz; }
+        public boolean getInDaylightTime() { return inDaylightTime; }
+        public boolean getTrusted() {return trusted; }
 
-        public void setInDaylightTime(boolean inDaylightTime) {
-                this.inDaylightTime = inDaylightTime;
-        }
-            
-        public boolean getInDaylightTime() {
-                return inDaylightTime;
-        }
-	
+        //-------------------------------------------------------------------------------------------------
+        public void setEpoch(long epoch) { this.epoch = epoch; }
+        public void setEpoch_ms(long epoch_ms) { this.epoch_ms = epoch_ms; }
+        public void setTz(String tz) { this.tz = tz; }
+        public void setInDaylightTime(boolean inDaylightTime) { this.inDaylightTime = inDaylightTime; }
+        public void setTrusted(boolean trusted) { this.trusted = trusted; }
 }
diff --git a/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeManagerController.java b/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeManagerController.java
index 6ccb83a6f..2f30e7f30 100644
--- a/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeManagerController.java
+++ b/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeManagerController.java
@@ -57,6 +57,7 @@
 import eu.arrowhead.common.exception.DataNotFoundException;
 import eu.arrowhead.common.exception.InvalidParameterException;
 import eu.arrowhead.core.timemanager.database.service.TimeManagerDBService;
+import eu.arrowhead.core.timemanager.service.TimeManagerDriver;
 import eu.arrowhead.core.timemanager.service.TimeService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -86,7 +87,10 @@ public class TimeManagerController {
 	private TimeService timeService;
 
 	@Autowired
-	private TimeManagerDBService timeManagerDBService;
+	private TimeManagerDriver timeManagerDriver;
+
+	//@Autowired
+	//private TimeManagerDBService timeManagerDBService;
 	
 	//=================================================================================================
 	// methods
@@ -114,7 +118,7 @@ public class TimeManagerController {
 			) {
 		logger.debug("timeGet");
 
-        TimeManagerTimeResponseDTO resp = new TimeManagerTimeResponseDTO(serverTimeZone);
+        TimeManagerTimeResponseDTO resp = new TimeManagerTimeResponseDTO(serverTimeZone, timeManagerDriver.isTimeTrusted());
 		return resp;
 	}
 
diff --git a/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeManagerWSConfig.java b/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeManagerWSConfig.java
index fa6d4bfd8..615b293a4 100644
--- a/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeManagerWSConfig.java
+++ b/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeManagerWSConfig.java
@@ -21,6 +21,8 @@
 import eu.arrowhead.common.SecurityUtilities;
 import eu.arrowhead.common.CommonConstants;
 import eu.arrowhead.core.timemanager.TimeWSHandler;
+import eu.arrowhead.core.timemanager.service.TimeManagerDriver;
+
 //import eu.arrowhead.core.datamanager.security.DatamanagerACLFilter;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.context.annotation.Bean;
@@ -52,6 +54,9 @@ public class TimeManagerWSConfig implements WebSocketConfigurer {
     @Autowired
     TimeWSHandler timeWSHandler;
 
+    @Autowired
+    TimeManagerDriver timeManagerDriver;
+    
     //@Autowired
     //TimemanagerACLFilter timeACLFilter;
 
diff --git a/timemanager/src/main/java/eu/arrowhead/core/timemanager/service/TimeManagerDriver.java b/timemanager/src/main/java/eu/arrowhead/core/timemanager/service/TimeManagerDriver.java
index bdc0aa9b6..eca62dac5 100644
--- a/timemanager/src/main/java/eu/arrowhead/core/timemanager/service/TimeManagerDriver.java
+++ b/timemanager/src/main/java/eu/arrowhead/core/timemanager/service/TimeManagerDriver.java
@@ -1,7 +1,8 @@
 package eu.arrowhead.core.timemanager.service;
 
-import java.util.Vector;
-import java.util.Iterator;
+//import java.util.Vector;
+//import java.util.Iterator;
+import java.util.concurrent.atomic.AtomicBoolean;
 
 import javax.annotation.Resource;
 
@@ -38,40 +39,65 @@ public class TimeManagerDriver {
 
 	//=================================================================================================
 	// members
-	private static final Logger logger = LogManager.getLogger(TimeManagerDriver.class);
+	private final Logger logger = LogManager.getLogger(TimeManagerDriver.class);
 
 	@Value("${ntp.server.list}")
     private String serverList;
 
+	@Value("${time.offsetThreshold}")
+	private long timeOffsetThreshold =  5000; 
+
+	private AtomicBoolean isTimeTrusted = new AtomicBoolean(true);
+
 	//=================================================================================================
 	// methods
 
-	@Scheduled(fixedDelay = 1000 * 60, initialDelay = 1000 * 5)
+	//-------------------------------------------------------------------------------------------------
+	public boolean isTimeTrusted() {
+		return isTimeTrusted.get();
+	}
+
+	//-------------------------------------------------------------------------------------------------
+	@Scheduled(fixedDelay = 1000 * 60, initialDelay = 1000 * 1)
     public void checkExternalTimeServer() {
 		logger.info("Checking external time!");
 	
 		final NTPUDPClient client = new NTPUDPClient();
 	
 		client.setDefaultTimeout(10000);
+
 		try {
 		  client.open();
 		  //for (final String arg : args) {
 			System.out.println();
 			try {
-			  // Ntp pool or server
-			  final InetAddress hostAddr = InetAddress.getByName("pool.ntp.org");
-			  System.out.println("> " + hostAddr.getHostName() + "/" + hostAddr.getHostAddress());
+			  final InetAddress hostAddr = InetAddress.getByName(serverList);
+			  //logger.debug("> " + hostAddr.getHostName() + "/" + hostAddr.getHostAddress());
 			  
 			  // Get time from server
 			  final TimeInfo info = client.getTime(hostAddr);
 			  info.computeDetails(); // compute offset/delay if not already done
 			 
-			  // For printing
 			  final Long offsetMillis = info.getOffset();
 			  final Long delayMillis = info.getDelay();
-			  final String delay = delayMillis == null ? "n/a" : delayMillis.toString();
-			  final String offset = offsetMillis == null ? "n/a" : offsetMillis.toString();
-			  System.out.println(" Roundtrip delay(ms)=" + delay + ", clock offset(ms)=" + offset); // offset in ms
+			  //final long delay = delayMillis == null ? "n/a" : delayMillis.toString();
+			  //final Long offset = offsetMillis == null ? "n/a" : offsetMillis.toString();
+			  final long offset = offsetMillis.longValue();
+			  logger.debug(" Roundtrip delay(ms)=" + delayMillis + ", clock offset(ms)=" + delayMillis); // offset in ms
+
+			  if (offsetMillis == null) {
+				isTimeTrusted.set(false);
+				logger.debug("Coulnd't get a response, something is wrong!");
+				return;
+			  }
+
+			  if (offset < timeOffsetThreshold) {
+				  isTimeTrusted.set(true);
+			  } else {
+				  isTimeTrusted.set(false);
+				  logger.info("Time offset to large, something is wrong!");
+			  }
+
 			} catch (final IOException ioe) {
 			  ioe.printStackTrace();
 			}

From 85a04440be485c99fb38b9196b37a81aad52dde7 Mon Sep 17 00:00:00 2001
From: Jens Eliasson <jens.eliasson@gmail.com>
Date: Fri, 16 Jul 2021 10:51:43 +0200
Subject: [PATCH 17/53] added support for tests

---
 .../dto/shared/TimeManagerTimeResponseDTO.java      |  9 +++++++++
 .../src/main/resources/application.properties       |  1 +
 .../TimeManagerControllerSystemTest.java            | 13 ++++++++++++-
 3 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/core-common/src/main/java/eu/arrowhead/common/dto/shared/TimeManagerTimeResponseDTO.java b/core-common/src/main/java/eu/arrowhead/common/dto/shared/TimeManagerTimeResponseDTO.java
index cee5f9d1a..003686d6a 100644
--- a/core-common/src/main/java/eu/arrowhead/common/dto/shared/TimeManagerTimeResponseDTO.java
+++ b/core-common/src/main/java/eu/arrowhead/common/dto/shared/TimeManagerTimeResponseDTO.java
@@ -70,6 +70,15 @@ public TimeManagerTimeResponseDTO(final long epoch, final String tz, final boole
                 this.trusted = trusted;
         }
 
+        //-------------------------------------------------------------------------------------------------
+        public TimeManagerTimeResponseDTO(final long epoch, final long epoch_ms, final String tz, final boolean inDaylightTime, final boolean trusted) {
+                this.epoch = epoch;
+                this.epoch_ms = epoch_ms;
+                this.tz = tz;
+                this.inDaylightTime = inDaylightTime;
+                this.trusted = trusted;
+        }
+
         //-------------------------------------------------------------------------------------------------
         public long getEpoch() { return epoch; }
         public long getEpoch_ms() { return epoch_ms; }
diff --git a/timemanager/src/main/resources/application.properties b/timemanager/src/main/resources/application.properties
index 929bb3998..39789e4ec 100644
--- a/timemanager/src/main/resources/application.properties
+++ b/timemanager/src/main/resources/application.properties
@@ -40,6 +40,7 @@ sr_port=8443
 
 serverTimezone=Europe/Budapest
 ntp.server.list=pool.ntp.org
+time.offsetThreshold=5000
 
 ############################################
 ###           SECURE MODE                ###
diff --git a/timemanager/src/test/java/eu/arrowhead/core/timemanager/TimeManagerControllerSystemTest.java b/timemanager/src/test/java/eu/arrowhead/core/timemanager/TimeManagerControllerSystemTest.java
index 1d9c79f04..2b1ff53b3 100644
--- a/timemanager/src/test/java/eu/arrowhead/core/timemanager/TimeManagerControllerSystemTest.java
+++ b/timemanager/src/test/java/eu/arrowhead/core/timemanager/TimeManagerControllerSystemTest.java
@@ -3,7 +3,7 @@
 import com.fasterxml.jackson.databind.ObjectMapper;
 import eu.arrowhead.common.exception.InvalidParameterException;
 import eu.arrowhead.core.timemanager.database.service.TimeManagerDBService;
-
+import eu.arrowhead.common.dto.shared.TimeManagerTimeResponseDTO;
 
 import org.junit.Before;
 import org.junit.Test;
@@ -23,6 +23,7 @@
 import java.util.List;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.anyString;
 import static org.mockito.ArgumentMatchers.anyInt;
@@ -84,4 +85,14 @@ public void echoTM() throws Exception {
         assertEquals("Got it!", response.getResponse().getContentAsString());
     }
 
+    @Test
+    public void testTime() throws Exception {
+        final MvcResult response = this.mockMvc.perform(get(TIMEMANAGER_TIME_URI)
+                                               .accept(MediaType.APPLICATION_JSON))
+                                               .andExpect(status().isOk())
+                                               .andReturn();
+        final TimeManagerTimeResponseDTO responseBody = objectMapper.readValue(response.getResponse().getContentAsString(), TimeManagerTimeResponseDTO.class);
+        assertNotEquals(0, responseBody.getEpoch());
+    }
+
 }

From 6851a97b5d6161d1092616fc89caba3f17a551d1 Mon Sep 17 00:00:00 2001
From: Jens Eliasson <jens.eliasson@gmail.com>
Date: Fri, 16 Jul 2021 11:01:24 +0200
Subject: [PATCH 18/53] additional tests added

---
 .../common/dto/shared/TimeManagerTimeResponseDTO.java         | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/core-common/src/main/java/eu/arrowhead/common/dto/shared/TimeManagerTimeResponseDTO.java b/core-common/src/main/java/eu/arrowhead/common/dto/shared/TimeManagerTimeResponseDTO.java
index 003686d6a..97a827245 100644
--- a/core-common/src/main/java/eu/arrowhead/common/dto/shared/TimeManagerTimeResponseDTO.java
+++ b/core-common/src/main/java/eu/arrowhead/common/dto/shared/TimeManagerTimeResponseDTO.java
@@ -36,6 +36,10 @@ public class TimeManagerTimeResponseDTO implements Serializable {
         //=================================================================================================
         // methods
         
+        //-------------------------------------------------------------------------------------------------
+        public TimeManagerTimeResponseDTO() {
+        }
+        
         //-------------------------------------------------------------------------------------------------
         public TimeManagerTimeResponseDTO(final String tz) {
                 this.tz = tz;

From 87b8dac5aa9b9dc9608c74d1ecc0fb9a670adb6d Mon Sep 17 00:00:00 2001
From: Jens Eliasson <jens.eliasson@gmail.com>
Date: Fri, 16 Jul 2021 11:08:36 +0200
Subject: [PATCH 19/53] code cleanup

---
 .../shared/TimeManagerTimeResponseDTO.java    |  3 +--
 .../timemanager/TimeManagerController.java    |  1 -
 .../service/TimeManagerDriver.java            | 26 ++++++++++++-------
 3 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/core-common/src/main/java/eu/arrowhead/common/dto/shared/TimeManagerTimeResponseDTO.java b/core-common/src/main/java/eu/arrowhead/common/dto/shared/TimeManagerTimeResponseDTO.java
index 97a827245..929d7554d 100644
--- a/core-common/src/main/java/eu/arrowhead/common/dto/shared/TimeManagerTimeResponseDTO.java
+++ b/core-common/src/main/java/eu/arrowhead/common/dto/shared/TimeManagerTimeResponseDTO.java
@@ -21,7 +21,6 @@
 
 public class TimeManagerTimeResponseDTO implements Serializable {
 
-
         //=================================================================================================
         // members
         
@@ -39,7 +38,7 @@ public class TimeManagerTimeResponseDTO implements Serializable {
         //-------------------------------------------------------------------------------------------------
         public TimeManagerTimeResponseDTO() {
         }
-        
+
         //-------------------------------------------------------------------------------------------------
         public TimeManagerTimeResponseDTO(final String tz) {
                 this.tz = tz;
diff --git a/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeManagerController.java b/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeManagerController.java
index 2f30e7f30..17842fe36 100644
--- a/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeManagerController.java
+++ b/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeManagerController.java
@@ -50,7 +50,6 @@
 import eu.arrowhead.common.CoreUtilities.ValidatedPageParams;
 import eu.arrowhead.common.Defaults;
 import eu.arrowhead.common.Utilities;
-//import eu.arrowhead.common.dto.shared.TimeManagerTimeRequestDTO;
 import eu.arrowhead.common.dto.shared.TimeManagerTimeResponseDTO;
 import eu.arrowhead.common.exception.ArrowheadException;
 import eu.arrowhead.common.exception.BadPayloadException;
diff --git a/timemanager/src/main/java/eu/arrowhead/core/timemanager/service/TimeManagerDriver.java b/timemanager/src/main/java/eu/arrowhead/core/timemanager/service/TimeManagerDriver.java
index eca62dac5..e9623eb4a 100644
--- a/timemanager/src/main/java/eu/arrowhead/core/timemanager/service/TimeManagerDriver.java
+++ b/timemanager/src/main/java/eu/arrowhead/core/timemanager/service/TimeManagerDriver.java
@@ -1,9 +1,20 @@
+/********************************************************************************
+ * Copyright (c) 2021 {Lulea University of Technology}
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0 
+ *
+ * Contributors: 
+ *   {Lulea University of Technology} - implementation
+ *   Arrowhead Consortia - conceptualization 
+ ********************************************************************************/
+
 package eu.arrowhead.core.timemanager.service;
 
-//import java.util.Vector;
-//import java.util.Iterator;
 import java.util.concurrent.atomic.AtomicBoolean;
-
 import javax.annotation.Resource;
 
 import org.apache.logging.log4j.LogManager;
@@ -45,7 +56,7 @@ public class TimeManagerDriver {
     private String serverList;
 
 	@Value("${time.offsetThreshold}")
-	private long timeOffsetThreshold =  5000; 
+	private long timeOffsetThreshold; 
 
 	private AtomicBoolean isTimeTrusted = new AtomicBoolean(true);
 
@@ -72,11 +83,8 @@ public void checkExternalTimeServer() {
 			System.out.println();
 			try {
 			  final InetAddress hostAddr = InetAddress.getByName(serverList);
-			  //logger.debug("> " + hostAddr.getHostName() + "/" + hostAddr.getHostAddress());
-			  
-			  // Get time from server
 			  final TimeInfo info = client.getTime(hostAddr);
-			  info.computeDetails(); // compute offset/delay if not already done
+			  info.computeDetails();
 			 
 			  final Long offsetMillis = info.getOffset();
 			  final Long delayMillis = info.getDelay();
@@ -94,8 +102,8 @@ public void checkExternalTimeServer() {
 			  if (offset < timeOffsetThreshold) {
 				  isTimeTrusted.set(true);
 			  } else {
-				  isTimeTrusted.set(false);
 				  logger.info("Time offset to large, something is wrong!");
+				  isTimeTrusted.set(false);
 			  }
 
 			} catch (final IOException ioe) {

From 6d25738047dd82ed80ebebc8d2cbbd8d373590d1 Mon Sep 17 00:00:00 2001
From: Jens Eliasson <jens.eliasson@gmail.com>
Date: Fri, 16 Jul 2021 11:29:15 +0200
Subject: [PATCH 20/53] namechange of DST member

---
 .../dto/shared/TimeManagerTimeResponseDTO.java   | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/core-common/src/main/java/eu/arrowhead/common/dto/shared/TimeManagerTimeResponseDTO.java b/core-common/src/main/java/eu/arrowhead/common/dto/shared/TimeManagerTimeResponseDTO.java
index 929d7554d..af12aa811 100644
--- a/core-common/src/main/java/eu/arrowhead/common/dto/shared/TimeManagerTimeResponseDTO.java
+++ b/core-common/src/main/java/eu/arrowhead/common/dto/shared/TimeManagerTimeResponseDTO.java
@@ -29,7 +29,7 @@ public class TimeManagerTimeResponseDTO implements Serializable {
         private long epoch;
         private long epoch_ms;
         private String tz;
-        private boolean inDaylightTime;
+        private boolean dst;
         private boolean trusted;
                 
         //=================================================================================================
@@ -47,7 +47,7 @@ public TimeManagerTimeResponseDTO(final String tz) {
                 epoch_ms = date.getTime();
                 epoch = epoch_ms / 1000;
 
-                inDaylightTime = TimeZone.getTimeZone(this.tz).inDaylightTime(date);
+                dst = TimeZone.getTimeZone(this.tz).inDaylightTime(date);
                 trusted = false;
         }
 
@@ -58,7 +58,7 @@ public TimeManagerTimeResponseDTO(final String tz, final boolean trusted) {
                 epoch_ms = date.getTime();
                 epoch = epoch_ms / 1000;
 
-                inDaylightTime = TimeZone.getTimeZone(this.tz).inDaylightTime(date);
+                dst = TimeZone.getTimeZone(this.tz).inDaylightTime(date);
                 this.trusted = trusted;
         }
 
@@ -69,16 +69,16 @@ public TimeManagerTimeResponseDTO(final long epoch, final String tz, final boole
                 this.epoch_ms = epoch * 1000;
                 this.tz = tz;
 
-                inDaylightTime = TimeZone.getTimeZone(this.tz).inDaylightTime(date);
+                this.dst = TimeZone.getTimeZone(this.tz).inDaylightTime(date);
                 this.trusted = trusted;
         }
 
         //-------------------------------------------------------------------------------------------------
-        public TimeManagerTimeResponseDTO(final long epoch, final long epoch_ms, final String tz, final boolean inDaylightTime, final boolean trusted) {
+        public TimeManagerTimeResponseDTO(final long epoch, final long epoch_ms, final String tz, final boolean dst, final boolean trusted) {
                 this.epoch = epoch;
                 this.epoch_ms = epoch_ms;
                 this.tz = tz;
-                this.inDaylightTime = inDaylightTime;
+                this.dst = dst;
                 this.trusted = trusted;
         }
 
@@ -86,13 +86,13 @@ public TimeManagerTimeResponseDTO(final long epoch, final long epoch_ms, final S
         public long getEpoch() { return epoch; }
         public long getEpoch_ms() { return epoch_ms; }
         public String getTz() { return tz; }
-        public boolean getInDaylightTime() { return inDaylightTime; }
+        public boolean getDst() { return dst; }
         public boolean getTrusted() {return trusted; }
 
         //-------------------------------------------------------------------------------------------------
         public void setEpoch(long epoch) { this.epoch = epoch; }
         public void setEpoch_ms(long epoch_ms) { this.epoch_ms = epoch_ms; }
         public void setTz(String tz) { this.tz = tz; }
-        public void setInDaylightTime(boolean inDaylightTime) { this.inDaylightTime = inDaylightTime; }
+        public void setDst(boolean dst) { this.dst = dst; }
         public void setTrusted(boolean trusted) { this.trusted = trusted; }
 }

From 5dacc6f7e26c5c9b4d0ef5d04cd956e74d9312c7 Mon Sep 17 00:00:00 2001
From: Jens Eliasson <jens.eliasson@gmail.com>
Date: Fri, 16 Jul 2021 11:53:40 +0200
Subject: [PATCH 21/53] final code cleanup

---
 .../core/timemanager/TimeManagerController.java        |  2 +-
 .../eu/arrowhead/core/timemanager/TimeWSHandler.java   |  8 ++++++--
 .../core/timemanager/service/TimeManagerDriver.java    | 10 +++-------
 timemanager/src/main/resources/application.properties  |  4 ++--
 4 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeManagerController.java b/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeManagerController.java
index 17842fe36..27d2daf6c 100644
--- a/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeManagerController.java
+++ b/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeManagerController.java
@@ -73,7 +73,7 @@
 public class TimeManagerController {
 	private final Logger logger = LogManager.getLogger(TimeManagerController.class);
 
-	@Value("${serverTimezone}")
+	@Value("${time.timezone}")
     private String serverTimeZone;
 
 	//=================================================================================================
diff --git a/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeWSHandler.java b/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeWSHandler.java
index 137bc355a..4a05fcd92 100644
--- a/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeWSHandler.java
+++ b/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeWSHandler.java
@@ -35,6 +35,7 @@
 //import eu.arrowhead.core.timemanager.security.TimemanagerACLFilter;
 import eu.arrowhead.common.Utilities;
 import eu.arrowhead.common.dto.shared.TimeManagerTimeResponseDTO;
+import eu.arrowhead.core.timemanager.service.TimeManagerDriver;
 
 import com.google.gson.*;
 import com.google.gson.reflect.TypeToken;
@@ -51,9 +52,12 @@ public class TimeWSHandler extends TextWebSocketHandler {
     @Value("${server.ssl.enabled}")
     private boolean sslEnabled;
 
-    @Value("${serverTimezone}")
+    @Value("${time.timezone}")
     private String serverTimeZone;
 
+    @Autowired
+    TimeManagerDriver timeManagerDriver;
+
     //@Autowired
     //TimemanagerACLFilter dataManagerACLFilter;
 
@@ -76,7 +80,7 @@ public void afterConnectionClosed(WebSocketSession session, CloseStatus status)
     public void sendOutTimeMessages() {
         sessions.forEach(webSocketSession -> {
             try {
-                TimeManagerTimeResponseDTO response = new TimeManagerTimeResponseDTO(serverTimeZone);
+                TimeManagerTimeResponseDTO response = new TimeManagerTimeResponseDTO(serverTimeZone, timeManagerDriver.isTimeTrusted());
                 TextMessage msg = new TextMessage(Utilities.toJson(response).getBytes("UTF-8"));
                 webSocketSession.sendMessage(msg);
             } catch (IOException e) {
diff --git a/timemanager/src/main/java/eu/arrowhead/core/timemanager/service/TimeManagerDriver.java b/timemanager/src/main/java/eu/arrowhead/core/timemanager/service/TimeManagerDriver.java
index e9623eb4a..e71506cef 100644
--- a/timemanager/src/main/java/eu/arrowhead/core/timemanager/service/TimeManagerDriver.java
+++ b/timemanager/src/main/java/eu/arrowhead/core/timemanager/service/TimeManagerDriver.java
@@ -55,7 +55,7 @@ public class TimeManagerDriver {
 	@Value("${ntp.server.list}")
     private String serverList;
 
-	@Value("${time.offsetThreshold}")
+	@Value("${time.offset.threshold}")
 	private long timeOffsetThreshold; 
 
 	private AtomicBoolean isTimeTrusted = new AtomicBoolean(true);
@@ -79,8 +79,7 @@ public void checkExternalTimeServer() {
 
 		try {
 		  client.open();
-		  //for (final String arg : args) {
-			System.out.println();
+		  
 			try {
 			  final InetAddress hostAddr = InetAddress.getByName(serverList);
 			  final TimeInfo info = client.getTime(hostAddr);
@@ -88,8 +87,6 @@ public void checkExternalTimeServer() {
 			 
 			  final Long offsetMillis = info.getOffset();
 			  final Long delayMillis = info.getDelay();
-			  //final long delay = delayMillis == null ? "n/a" : delayMillis.toString();
-			  //final Long offset = offsetMillis == null ? "n/a" : offsetMillis.toString();
 			  final long offset = offsetMillis.longValue();
 			  logger.debug(" Roundtrip delay(ms)=" + delayMillis + ", clock offset(ms)=" + delayMillis); // offset in ms
 
@@ -102,14 +99,13 @@ public void checkExternalTimeServer() {
 			  if (offset < timeOffsetThreshold) {
 				  isTimeTrusted.set(true);
 			  } else {
-				  logger.info("Time offset to large, something is wrong!");
+				  logger.debug("Time offset to large, something is wrong!");
 				  isTimeTrusted.set(false);
 			  }
 
 			} catch (final IOException ioe) {
 			  ioe.printStackTrace();
 			}
-		  //}
 		} catch (final SocketException e) {
 		  e.printStackTrace();
 		}
diff --git a/timemanager/src/main/resources/application.properties b/timemanager/src/main/resources/application.properties
index 39789e4ec..06c74b30f 100644
--- a/timemanager/src/main/resources/application.properties
+++ b/timemanager/src/main/resources/application.properties
@@ -38,9 +38,9 @@ log_all_request_and_response=false
 sr_address=127.0.0.1
 sr_port=8443
 
-serverTimezone=Europe/Budapest
+time.timezone=Europe/Budapest
 ntp.server.list=pool.ntp.org
-time.offsetThreshold=5000
+time.offset.threshold=5000
 
 ############################################
 ###           SECURE MODE                ###

From cbf8fe01aef6966835a72806704a2fed632c12dc Mon Sep 17 00:00:00 2001
From: Jens Eliasson <jens.eliasson@gmail.com>
Date: Tue, 20 Jul 2021 10:54:58 +0200
Subject: [PATCH 22/53] added IDD and SD for the Time service

---
 .../Arrowhead Time Service IDD.pdf             | Bin 0 -> 103982 bytes
 .../Arrowhead Time Service SD.pdf              | Bin 0 -> 86449 bytes
 2 files changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 timemanager/documentation/Arrowhead Time Service IDD.pdf
 create mode 100644 timemanager/documentation/Arrowhead Time Service SD.pdf

diff --git a/timemanager/documentation/Arrowhead Time Service IDD.pdf b/timemanager/documentation/Arrowhead Time Service IDD.pdf
new file mode 100644
index 0000000000000000000000000000000000000000..579ef6a7263eb06c70a119d380189d604740ad46
GIT binary patch
diff --git a/timemanager/documentation/Arrowhead Time Service SD.pdf b/timemanager/documentation/Arrowhead Time Service SD.pdf
new file mode 100644
index 0000000000000000000000000000000000000000..787c27a406194b2a4f321c2336173b0849e4e3c3
GIT binary patch

From 54c0ce9f9a2df07ddafde56112d643d157155653 Mon Sep 17 00:00:00 2001
From: Jens Eliasson <jens.eliasson@gmail.com>
Date: Tue, 20 Jul 2021 13:32:57 +0200
Subject: [PATCH 23/53] added SySD for the Time service

---
 .../Arrowhead TimeManager SysD.pdf             | Bin 0 -> 117596 bytes
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 timemanager/documentation/Arrowhead TimeManager SysD.pdf

diff --git a/timemanager/documentation/Arrowhead TimeManager SysD.pdf b/timemanager/documentation/Arrowhead TimeManager SysD.pdf
new file mode 100644
index 0000000000000000000000000000000000000000..18bc7311f4070ee9ffde15556375668d0e9790e1
GIT binary patch

From 5f1ee2c2bd10721e8fa8ae65ef0030bccafeb1d8 Mon Sep 17 00:00:00 2001
From: Jens Eliasson <jens.eliasson@gmail.com>
Date: Tue, 20 Jul 2021 19:52:50 +0200
Subject: [PATCH 24/53] code cleanup

---
 .../timemanager/TimeManagerController.java    | 25 +------------------
 .../core/timemanager/TimeWSHandler.java       |  9 -------
 2 files changed, 1 insertion(+), 33 deletions(-)

diff --git a/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeManagerController.java b/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeManagerController.java
index 27d2daf6c..fe83f0833 100644
--- a/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeManagerController.java
+++ b/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeManagerController.java
@@ -23,39 +23,16 @@
 import org.apache.logging.log4j.Logger;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
-import org.springframework.http.HttpHeaders;
+
 import org.springframework.http.MediaType;
-import org.springframework.http.RequestEntity;
-import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.CrossOrigin;
-import org.springframework.web.bind.annotation.DeleteMapping;
 import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.RequestHeader;
-import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.ResponseBody;
 import org.springframework.web.bind.annotation.RestController;
-import org.springframework.web.server.ResponseStatusException;
-import org.springframework.util.MultiValueMap;
-import org.springframework.util.Assert;
 
 import eu.arrowhead.common.CommonConstants;
 import eu.arrowhead.common.CoreCommonConstants;
-import eu.arrowhead.common.CoreDefaults;
-import eu.arrowhead.common.CoreUtilities;
-import eu.arrowhead.common.CoreUtilities.ValidatedPageParams;
-import eu.arrowhead.common.Defaults;
-import eu.arrowhead.common.Utilities;
 import eu.arrowhead.common.dto.shared.TimeManagerTimeResponseDTO;
-import eu.arrowhead.common.exception.ArrowheadException;
-import eu.arrowhead.common.exception.BadPayloadException;
-import eu.arrowhead.common.exception.DataNotFoundException;
-import eu.arrowhead.common.exception.InvalidParameterException;
-import eu.arrowhead.core.timemanager.database.service.TimeManagerDBService;
 import eu.arrowhead.core.timemanager.service.TimeManagerDriver;
 import eu.arrowhead.core.timemanager.service.TimeService;
 import io.swagger.annotations.Api;
diff --git a/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeWSHandler.java b/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeWSHandler.java
index 4a05fcd92..fe0021245 100644
--- a/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeWSHandler.java
+++ b/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeWSHandler.java
@@ -15,8 +15,6 @@
  
 import java.io.IOException;
 import java.util.List;
-import java.util.Vector;
-import java.util.Map;
 import java.util.concurrent.CopyOnWriteArrayList;
 
 import org.apache.logging.log4j.LogManager;
@@ -32,20 +30,16 @@
 import org.springframework.web.socket.handler.TextWebSocketHandler;
 
 import eu.arrowhead.common.CommonConstants;
-//import eu.arrowhead.core.timemanager.security.TimemanagerACLFilter;
 import eu.arrowhead.common.Utilities;
 import eu.arrowhead.common.dto.shared.TimeManagerTimeResponseDTO;
 import eu.arrowhead.core.timemanager.service.TimeManagerDriver;
 
-import com.google.gson.*;
-import com.google.gson.reflect.TypeToken;
 
 @Component
 @EnableScheduling
 public class TimeWSHandler extends TextWebSocketHandler {
  
     private final Logger logger = LogManager.getLogger(TimeWSHandler.class);
-    //private Gson gson = new Gson();
     
     private final List<WebSocketSession> sessions = new CopyOnWriteArrayList<>();
  
@@ -58,9 +52,6 @@ public class TimeWSHandler extends TextWebSocketHandler {
     @Autowired
     TimeManagerDriver timeManagerDriver;
 
-    //@Autowired
-    //TimemanagerACLFilter dataManagerACLFilter;
-
     //=================================================================================================
     // methods
 

From cf9d56bf6bfe97e3c5b7e3614ac2ae2fa475258b Mon Sep 17 00:00:00 2001
From: Jens Eliasson <jens.eliasson@gmail.com>
Date: Fri, 23 Jul 2021 15:15:49 +0200
Subject: [PATCH 25/53] removed unused file

---
 .../eu/arrowhead/core/timemanager/service/TimeService.java   | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/timemanager/src/main/java/eu/arrowhead/core/timemanager/service/TimeService.java b/timemanager/src/main/java/eu/arrowhead/core/timemanager/service/TimeService.java
index dc668dcdb..779480735 100644
--- a/timemanager/src/main/java/eu/arrowhead/core/timemanager/service/TimeService.java
+++ b/timemanager/src/main/java/eu/arrowhead/core/timemanager/service/TimeService.java
@@ -28,11 +28,6 @@
 import eu.arrowhead.common.exception.InvalidParameterException;
 import eu.arrowhead.core.timemanager.database.service.TimeManagerDBService;
 
-//import java.util.List;
-//import java.util.ArrayList; 
-//import java.util.Iterator; 
-//import java.util.Vector;
-
 
 @Service
 public class TimeService {

From a052328aff8050146c108106a2a1ed0c5376670e Mon Sep 17 00:00:00 2001
From: Jens Eliasson <jens.eliasson@gmail.com>
Date: Fri, 23 Jul 2021 15:16:19 +0200
Subject: [PATCH 26/53] removed unused file

---
 .../core/timemanager/service/TimeService.java | 52 -------------------
 1 file changed, 52 deletions(-)
 delete mode 100644 timemanager/src/main/java/eu/arrowhead/core/timemanager/service/TimeService.java

diff --git a/timemanager/src/main/java/eu/arrowhead/core/timemanager/service/TimeService.java b/timemanager/src/main/java/eu/arrowhead/core/timemanager/service/TimeService.java
deleted file mode 100644
index 779480735..000000000
--- a/timemanager/src/main/java/eu/arrowhead/core/timemanager/service/TimeService.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2021 {Lulea University of Technology}
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0 
- *
- * Contributors: 
- *   {Lulea University of Technology} - implementation
- *   Arrowhead Consortia - conceptualization 
- ********************************************************************************/
-package eu.arrowhead.core.timemanager.service;
-
-import javax.annotation.Resource;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Service;
-
-import eu.arrowhead.common.CommonConstants;
-import eu.arrowhead.common.CoreCommonConstants;
-import eu.arrowhead.common.Utilities;
-import eu.arrowhead.common.dto.internal.DTOConverter;
-import eu.arrowhead.common.exception.InvalidParameterException;
-import eu.arrowhead.core.timemanager.database.service.TimeManagerDBService;
-
-
-@Service
-public class TimeService {
-
-    //=================================================================================================
-    // members
-    //
-
-    private final Logger logger = LogManager.getLogger(TimeService.class);
-
-    //=================================================================================================
-    // methods
-
-    //-------------------------------------------------------------------------------------------------
-    public TimeService() {
-
-    }
-
-    //=================================================================================================
-    // assistant methods
-
-}

From b988fc53217021da9d61264ad5cbe87baedb6982 Mon Sep 17 00:00:00 2001
From: Jens Eliasson <jens.eliasson@gmail.com>
Date: Fri, 23 Jul 2021 15:21:05 +0200
Subject: [PATCH 27/53] code fixes after feedback

---
 .../shared/TimeManagerTimeResponseDTO.java    | 20 +++++++++----------
 .../timemanager/TimeManagerController.java    |  9 +--------
 .../core/timemanager/TimeManagerWSConfig.java | 20 ++++++++++++-------
 .../service/TimeManagerDriver.java            |  6 +++---
 .../main/resources/swagger/swagger-ui.html    |  2 +-
 5 files changed, 28 insertions(+), 29 deletions(-)

diff --git a/core-common/src/main/java/eu/arrowhead/common/dto/shared/TimeManagerTimeResponseDTO.java b/core-common/src/main/java/eu/arrowhead/common/dto/shared/TimeManagerTimeResponseDTO.java
index af12aa811..802f212a8 100644
--- a/core-common/src/main/java/eu/arrowhead/common/dto/shared/TimeManagerTimeResponseDTO.java
+++ b/core-common/src/main/java/eu/arrowhead/common/dto/shared/TimeManagerTimeResponseDTO.java
@@ -27,7 +27,7 @@ public class TimeManagerTimeResponseDTO implements Serializable {
         private static final long serialVersionUID = 1648756742138137282L;
 
         private long epoch;
-        private long epoch_ms;
+        private long epochMs;
         private String tz;
         private boolean dst;
         private boolean trusted;
@@ -44,8 +44,8 @@ public TimeManagerTimeResponseDTO(final String tz) {
                 this.tz = tz;
                 
                 Date date = new Date();
-                epoch_ms = date.getTime();
-                epoch = epoch_ms / 1000;
+                epochMs = date.getTime();
+                epoch = epochMs / 1000;
 
                 dst = TimeZone.getTimeZone(this.tz).inDaylightTime(date);
                 trusted = false;
@@ -55,8 +55,8 @@ public TimeManagerTimeResponseDTO(final String tz, final boolean trusted) {
                 this.tz = tz;
                 
                 Date date = new Date();
-                epoch_ms = date.getTime();
-                epoch = epoch_ms / 1000;
+                epochMs = date.getTime();
+                epoch = epochMs / 1000;
 
                 dst = TimeZone.getTimeZone(this.tz).inDaylightTime(date);
                 this.trusted = trusted;
@@ -66,7 +66,7 @@ public TimeManagerTimeResponseDTO(final String tz, final boolean trusted) {
         public TimeManagerTimeResponseDTO(final long epoch, final String tz, final boolean trusted) {
                 Date date = new Date(epoch*1000);
                 this.epoch = epoch;
-                this.epoch_ms = epoch * 1000;
+                this.epochMs = epoch * 1000;
                 this.tz = tz;
 
                 this.dst = TimeZone.getTimeZone(this.tz).inDaylightTime(date);
@@ -74,9 +74,9 @@ public TimeManagerTimeResponseDTO(final long epoch, final String tz, final boole
         }
 
         //-------------------------------------------------------------------------------------------------
-        public TimeManagerTimeResponseDTO(final long epoch, final long epoch_ms, final String tz, final boolean dst, final boolean trusted) {
+        public TimeManagerTimeResponseDTO(final long epoch, final long epochMs, final String tz, final boolean dst, final boolean trusted) {
                 this.epoch = epoch;
-                this.epoch_ms = epoch_ms;
+                this.epochMs = epochMs;
                 this.tz = tz;
                 this.dst = dst;
                 this.trusted = trusted;
@@ -84,14 +84,14 @@ public TimeManagerTimeResponseDTO(final long epoch, final long epoch_ms, final S
 
         //-------------------------------------------------------------------------------------------------
         public long getEpoch() { return epoch; }
-        public long getEpoch_ms() { return epoch_ms; }
+        public long getEpochMs() { return epochMs; }
         public String getTz() { return tz; }
         public boolean getDst() { return dst; }
         public boolean getTrusted() {return trusted; }
 
         //-------------------------------------------------------------------------------------------------
         public void setEpoch(long epoch) { this.epoch = epoch; }
-        public void setEpoch_ms(long epoch_ms) { this.epoch_ms = epoch_ms; }
+        public void setEpochMs(long epochMs) { this.epochMs = epochMs; }
         public void setTz(String tz) { this.tz = tz; }
         public void setDst(boolean dst) { this.dst = dst; }
         public void setTrusted(boolean trusted) { this.trusted = trusted; }
diff --git a/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeManagerController.java b/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeManagerController.java
index 27d2daf6c..546a8ff5e 100644
--- a/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeManagerController.java
+++ b/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeManagerController.java
@@ -11,7 +11,7 @@
  *   {Lulea University of Technology} - implementation
  *   Arrowhead Consortia - conceptualization 
  ********************************************************************************/
-package eu.arrowhead.core.timeamanager;
+package eu.arrowhead.core.timemanager;
 
 import java.util.List;
 import java.util.ArrayList;
@@ -57,7 +57,6 @@
 import eu.arrowhead.common.exception.InvalidParameterException;
 import eu.arrowhead.core.timemanager.database.service.TimeManagerDBService;
 import eu.arrowhead.core.timemanager.service.TimeManagerDriver;
-import eu.arrowhead.core.timemanager.service.TimeService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiResponse;
@@ -65,9 +64,6 @@
 
 
 @Api(tags = { CoreCommonConstants.SWAGGER_TAG_ALL })
-//@CrossOrigin(maxAge = Defaults.CORS_MAX_AGE, allowCredentials = Defaults.CORS_ALLOW_CREDENTIALS, 
-//allowedHeaders = { HttpHeaders.ORIGIN, HttpHeaders.CONTENT_TYPE, HttpHeaders.ACCEPT, HttpHeaders.AUTHORIZATION }
-//)
 @RestController
 @RequestMapping(CommonConstants.TIMEMANAGER_URI)
 public class TimeManagerController {
@@ -82,9 +78,6 @@ public class TimeManagerController {
 	private static final String OP_NOT_VALID_ERROR_MESSAGE = " Illegal operation. ";
 	private static final String NOT_FOUND_ERROR_MESSAGE = " Resource not found. ";
 	
-	@Autowired 
-	private TimeService timeService;
-
 	@Autowired
 	private TimeManagerDriver timeManagerDriver;
 
diff --git a/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeManagerWSConfig.java b/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeManagerWSConfig.java
index 615b293a4..894729f4f 100644
--- a/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeManagerWSConfig.java
+++ b/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeManagerWSConfig.java
@@ -42,7 +42,13 @@
 @Configuration
 @EnableWebSocket
 public class TimeManagerWSConfig implements WebSocketConfigurer {
- 
+    
+    //=================================================================================================
+    // members
+        
+    private static final String SYSTEM_REF = "systemId";
+    private static final String SERVICE_REF = "serviceId";
+
     private final Logger logger = LogManager.getLogger(TimeManagerWSConfig.class);
 
     @Value("${server.ssl.enabled}")
@@ -52,13 +58,13 @@ public class TimeManagerWSConfig implements WebSocketConfigurer {
     private boolean websocketsEnabled;
 
     @Autowired
-    TimeWSHandler timeWSHandler;
+    private TimeWSHandler timeWSHandler;
 
     @Autowired
-    TimeManagerDriver timeManagerDriver;
+    private TimeManagerDriver timeManagerDriver;
     
     //@Autowired
-    //TimemanagerACLFilter timeACLFilter;
+    //private TimemanagerACLFilter timeACLFilter;
 
     @Override
     public void registerWebSocketHandlers(WebSocketHandlerRegistry webSocketHandlerRegistry) {
@@ -90,15 +96,15 @@ public boolean beforeHandshake(ServerHttpRequest request, ServerHttpResponse res
                             logger.info("No valid client certificate found");
                             return false;
                         }
-                        attributes.put("CN", CN);
+                        attributes.put(CommonConstants.COMMON_NAME_FIELD_NAME, CN);
                     } else {
                         return false;
                     }
                 }
 
                 // Add to the websocket session
-                attributes.put("systemId", systemId);
-                attributes.put("serviceId", serviceId);
+                attributes.put(SYSTEM_REF, systemId);
+                attributes.put(SERVICE_REF, serviceId);
                 
                 return true;
             }
diff --git a/timemanager/src/main/java/eu/arrowhead/core/timemanager/service/TimeManagerDriver.java b/timemanager/src/main/java/eu/arrowhead/core/timemanager/service/TimeManagerDriver.java
index e71506cef..179023cfd 100644
--- a/timemanager/src/main/java/eu/arrowhead/core/timemanager/service/TimeManagerDriver.java
+++ b/timemanager/src/main/java/eu/arrowhead/core/timemanager/service/TimeManagerDriver.java
@@ -88,18 +88,18 @@ public void checkExternalTimeServer() {
 			  final Long offsetMillis = info.getOffset();
 			  final Long delayMillis = info.getDelay();
 			  final long offset = offsetMillis.longValue();
-			  logger.debug(" Roundtrip delay(ms)=" + delayMillis + ", clock offset(ms)=" + delayMillis); // offset in ms
+			  logger.debug("Roundtrip delay(ms)=" + delayMillis + ", clock offset(ms)=" + delayMillis); // offset in ms
 
 			  if (offsetMillis == null) {
 				isTimeTrusted.set(false);
-				logger.debug("Coulnd't get a response, something is wrong!");
+				logger.debug("Couldn't get a response, something is wrong!");
 				return;
 			  }
 
 			  if (offset < timeOffsetThreshold) {
 				  isTimeTrusted.set(true);
 			  } else {
-				  logger.debug("Time offset to large, something is wrong!");
+				  logger.debug("Time offset too large, something is wrong!");
 				  isTimeTrusted.set(false);
 			  }
 
diff --git a/timemanager/src/main/resources/swagger/swagger-ui.html b/timemanager/src/main/resources/swagger/swagger-ui.html
index cc658fbd2..a7b2aa321 100644
--- a/timemanager/src/main/resources/swagger/swagger-ui.html
+++ b/timemanager/src/main/resources/swagger/swagger-ui.html
@@ -3,7 +3,7 @@
 <html lang="en">
 <head>
   <meta charset="UTF-8">
-  <title>Timemanager</title>
+  <title>TimeManager</title>
   <link rel="stylesheet" type="text/css" href="webjars/springfox-swagger-ui/springfox.css?v=2.9.2" >
   <link rel="stylesheet" type="text/css" href="webjars/springfox-swagger-ui/swagger-ui.css?v=2.9.2" >
   <link rel="icon" type="image/png" href="webjars/springfox-swagger-ui/favicon-32x32.png?v=2.9.2" sizes="32x32" />

From bcef09a2432643686bc781e8fcd3deb617e82d89 Mon Sep 17 00:00:00 2001
From: Jens Eliasson <jens.eliasson@gmail.com>
Date: Fri, 23 Jul 2021 15:57:20 +0200
Subject: [PATCH 28/53] code updates after review

---
 core-common/src/deb/control/templates         |   7 +-
 .../java/eu/arrowhead/common/SslUtil.java     | 126 ++++++++++--------
 scripts/start_coresystems.bat                 |   4 +-
 .../TimemanagerAccessControlFilter.java       |  28 +---
 4 files changed, 81 insertions(+), 84 deletions(-)

diff --git a/core-common/src/deb/control/templates b/core-common/src/deb/control/templates
index da1e7e0a4..18e35b436 100644
--- a/core-common/src/deb/control/templates
+++ b/core-common/src/deb/control/templates
@@ -151,7 +151,12 @@ Description: MySQL password for Certificate Authority system (leave empty for ra
 Template: arrowhead-core-common/mysql_password_datamanager
 Type: password
 Default:
-Description: MySQL password for Datamanager system (leave empty for random).
+Description: MySQL password for DataManager system (leave empty for random).
+
+Template: arrowhead-core-common/mysql_password_timemanager
+Type: password
+Default:
+Description: MySQL password for TimeManager system (leave empty for random).
 
 Template: arrowhead-core-common/sr_host
 Type: string
diff --git a/core-common/src/main/java/eu/arrowhead/common/SslUtil.java b/core-common/src/main/java/eu/arrowhead/common/SslUtil.java
index 2d7f9ea6f..bea79be26 100644
--- a/core-common/src/main/java/eu/arrowhead/common/SslUtil.java
+++ b/core-common/src/main/java/eu/arrowhead/common/SslUtil.java
@@ -17,10 +17,6 @@
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.core.io.Resource;
-import org.springframework.stereotype.Component;
-
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStreamReader;
@@ -50,69 +46,87 @@
 import org.bouncycastle.openssl.PEMParser;
 import org.bouncycastle.openssl.jcajce.JcaPEMKeyConverter;
 import org.bouncycastle.openssl.jcajce.JcePEMDecryptorProviderBuilder;
- 
-@Component
+
+
 public class SslUtil
 {
-    private final Logger logger = LogManager.getLogger(SslUtil.class);
 
     //=================================================================================================
-	// methods
+    // members
 
-	//-------------------------------------------------------------------------------------------------
+    private static final String BOUNCYCASTLE_IDENTIFIER = "BC";
+    private static final String CA_CERTIFICATE = "ca-certificate";
+    private static final String CERTIFICATE = "certificate";
+    private static final String PRIVATE_KEY = "private-key";
+    private static final String TLS_VERSION = "TLSv1.3";
+
+    private final Logger logger = LogManager.getLogger(SslUtil.class);
+
+    //=================================================================================================
+    // methods
 
+    //-------------------------------------------------------------------------------------------------
     public static SSLSocketFactory getSslSocketFactory(final String caCrtFile, final String crtFile, final String keyFile, final String password)
               throws
                      InvalidPathException, IOException, KeyStoreException, NoSuchAlgorithmException, CertificateException,
                      UnrecoverableKeyException, KeyManagementException, Exception {
-              Security.addProvider(new BouncyCastleProvider());
+
+              PEMParser parser = null;
+              try {
+                     Security.addProvider(new BouncyCastleProvider());
              
-              // load CA certificate
-              PEMParser parser = new PEMParser(new InputStreamReader(new ByteArrayInputStream(Files.readAllBytes(Paths.get(caCrtFile)))));
-              X509CertificateHolder caCert = (X509CertificateHolder) parser.readObject();
-              parser.close();
-
-              // load client certificate
-              parser = new PEMParser(new InputStreamReader(new ByteArrayInputStream(Files.readAllBytes(Paths.get(crtFile)))));
-              X509CertificateHolder cert = (X509CertificateHolder) parser.readObject();
-              parser.close();
-
-              // load client private key
-              parser = new PEMParser(new InputStreamReader(new ByteArrayInputStream(Files.readAllBytes(Paths.get(keyFile)))));
-              Object obj = parser.readObject();
-              KeyPair key = null;
-              JcaPEMKeyConverter converter = new JcaPEMKeyConverter().setProvider("BC");
-              if (obj instanceof PEMEncryptedKeyPair) {
-                     PEMDecryptorProvider decProv = new JcePEMDecryptorProviderBuilder().build(password.toCharArray());
-                     converter = new JcaPEMKeyConverter().setProvider("BC");
-                     key = converter.getKeyPair(((PEMEncryptedKeyPair) obj).decryptKeyPair(decProv));
-              } else {
-                     key = converter.getKeyPair((PEMKeyPair) obj);
-              }
-              parser.close();
+                     // load CA certificate
+                     parser = new PEMParser(new InputStreamReader(new ByteArrayInputStream(Files.readAllBytes(Paths.get(caCrtFile)))));
+                     final X509CertificateHolder caCert = (X509CertificateHolder) parser.readObject();
+                     parser.close();
+
+                     // load client certificate
+                     parser = new PEMParser(new InputStreamReader(new ByteArrayInputStream(Files.readAllBytes(Paths.get(crtFile)))));
+                     final X509CertificateHolder cert = (X509CertificateHolder) parser.readObject();
+                     parser.close();
+
+                     // load client private key
+                     parser = new PEMParser(new InputStreamReader(new ByteArrayInputStream(Files.readAllBytes(Paths.get(keyFile)))));
+                     Object obj = parser.readObject();
+                     parser.close();
+                     KeyPair key = null;
+                     JcaPEMKeyConverter converter = new JcaPEMKeyConverter().setProvider(BOUNCYCASTLE_IDENTIFIER);
+                     if (obj instanceof PEMEncryptedKeyPair) {
+                            PEMDecryptorProvider decProv = new JcePEMDecryptorProviderBuilder().build(password.toCharArray());
+                            converter = new JcaPEMKeyConverter().setProvider(BOUNCYCASTLE_IDENTIFIER);
+                            key = converter.getKeyPair(((PEMEncryptedKeyPair) obj).decryptKeyPair(decProv));
+                     } else {
+                            key = converter.getKeyPair((PEMKeyPair) obj);
+                     }
             
-              JcaX509CertificateConverter certConverter = new JcaX509CertificateConverter();
-              certConverter.setProvider("BC");
-
-              // CA certificate is used to authenticate server
-              KeyStore caKs = KeyStore.getInstance(KeyStore.getDefaultType());
-              caKs.load(null, null);
-              caKs.setCertificateEntry("ca-certificate", certConverter.getCertificate(caCert));
-              TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
-              tmf.init(caKs);
-
-              // Client key and certificates are sent to server so it can authenticate us
-              KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
-              ks.load(null, null);
-              ks.setCertificateEntry("certificate", certConverter.getCertificate(cert));
-              ks.setKeyEntry("private-key", key.getPrivate(), password.toCharArray(), new java.security.cert.Certificate[]{certConverter.getCertificate(cert)});
-              KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
-              kmf.init(ks, password.toCharArray());
-
-              // Finally, create SSL socket factory
-              SSLContext context = SSLContext.getInstance("TLSv1.3");
-              context.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
-
-              return context.getSocketFactory();
+                     final JcaX509CertificateConverter certConverter = new JcaX509CertificateConverter();
+                     certConverter.setProvider(BOUNCYCASTLE_IDENTIFIER);
+
+                     // CA certificate is used to authenticate server
+                     final KeyStore caKs = KeyStore.getInstance(KeyStore.getDefaultType());
+                     caKs.load(null, null);
+                     caKs.setCertificateEntry(CA_CERTIFICATE, certConverter.getCertificate(caCert));
+                     final TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
+                     tmf.init(caKs);
+
+                     // Client key and certificates are sent to server so it can authenticate us
+                     final KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
+                     ks.load(null, null);
+                     ks.setCertificateEntry(CERTIFICATE, certConverter.getCertificate(cert));
+                     ks.setKeyEntry(PRIVATE_KEY, key.getPrivate(), password.toCharArray(), new java.security.cert.Certificate[]{certConverter.getCertificate(cert)});
+                     final KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
+                     kmf.init(ks, password.toCharArray());
+                     
+                     final SSLContext context = SSLContext.getInstance(TLS_VERSION);
+                     context.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
+
+                     return context.getSocketFactory();
+              } catch(Exception e) {
+                     throw e;
+              } finally {
+                     if (parser != null) {
+                            parser.close();
+                     }
+              }
        }
 }
\ No newline at end of file
diff --git a/scripts/start_coresystems.bat b/scripts/start_coresystems.bat
index a9765bc03..9bf8c4a36 100644
--- a/scripts/start_coresystems.bat
+++ b/scripts/start_coresystems.bat
@@ -30,7 +30,7 @@ START "" /B "cmd /c javaw -jar arrowhead-datamanager-%version%.jar > sout_datama
 echo DataManager started
 
 cd ..\..\timemanager\target
-START "" /B "cmd /c javaw -jar arrowhead-timemanager-4.1.3.jar > sout_timemanager.log 2>&1"
+START "" /B "cmd /c javaw -jar arrowhead-timemanager-%version%.jar > sout_timemanager.log 2>&1"
 echo TimeManager started
 
 cd ..\..\gatekeeper\target
@@ -46,7 +46,7 @@ START "" /B "cmd /c javaw -jar arrowhead-choreographer-%version%.jar > sout_chor
 echo Choreographer started
 
 cd ..\..\configuration\target
-START "" /B "cmd /c javaw -jar arrowhead-configuration-4.2.0.jar > sout_configuration.log 2>&1"
+START "" /B "cmd /c javaw -jar arrowhead-configuration-%version%.jar > sout_configuration.log 2>&1"
 echo Configuration started
 
 cd ..\..\certificate-authority\target
diff --git a/timemanager/src/main/java/eu/arrowhead/core/timemanager/security/TimemanagerAccessControlFilter.java b/timemanager/src/main/java/eu/arrowhead/core/timemanager/security/TimemanagerAccessControlFilter.java
index cc2bcf7cd..2ea62ce75 100644
--- a/timemanager/src/main/java/eu/arrowhead/core/timemanager/security/TimemanagerAccessControlFilter.java
+++ b/timemanager/src/main/java/eu/arrowhead/core/timemanager/security/TimemanagerAccessControlFilter.java
@@ -45,34 +45,12 @@ public class TimemanagerAccessControlFilter extends CoreSystemAccessControlFilte
 	protected void checkClientAuthorized(final String clientCN, final String method, final String requestTarget, final String requestJSON, final Map<String,String[]> queryParams) {
 		super.checkClientAuthorized(clientCN, method, requestTarget, requestJSON, queryParams);
 
-		final String cloudCN = getServerCloudCN();
-
+		
 		if (requestTarget.endsWith(CommonConstants.ECHO_URI)) {
-          // Everybody in the local cloud can test the server => no further check is necessary
-          return;
+                        // Everybody in the local cloud can test the server => no further check is necessary
+                        return;
 		} 
 
-        //checkIfRequesterSystemNameisEqualsWithClientNameFromCN(requestTargetSystemName, clientCN);
-
 	}
 
-	//-------------------------------------------------------------------------------------------------
-        private void checkIfRequesterSystemNameisEqualsWithClientNameFromCN(final String requesterSystemName, final String clientCN) {
-                final String clientNameFromCN = getClientNameFromCN(clientCN);
-                
-                if (Utilities.isEmpty(requesterSystemName) || Utilities.isEmpty(clientNameFromCN)) {
-                        log.debug("Requester system name and client name from certificate do not match!");
-                        throw new AuthException("Requester system name or client name from certificate is null or blank!", HttpStatus.UNAUTHORIZED.value());
-                }
-                
-                if (!requesterSystemName.equalsIgnoreCase(clientNameFromCN) && !requesterSystemName.replaceAll("_", "").equalsIgnoreCase(clientNameFromCN)) {
-                        log.debug("Requester system name and client name from certificate do not match!");
-                        throw new AuthException("Requester system name(" + requesterSystemName + ") and client name from certificate (" + clientNameFromCN + ") do not match!", HttpStatus.UNAUTHORIZED.value());
-                }
-        }
-        
-        //-------------------------------------------------------------------------------------------------
-        private String getClientNameFromCN(final String clientCN) {
-                return clientCN.split("\\.", 2)[0];
-        }
 }

From b7e9912632cc9d29fd5e21b6ee47f0818d7bc8fc Mon Sep 17 00:00:00 2001
From: Jens Eliasson <jens.eliasson@gmail.com>
Date: Fri, 23 Jul 2021 16:04:17 +0200
Subject: [PATCH 29/53] added metadata info

---
 ...itional-spring-configuration-metadata.json |  5 +++++
 ...itional-spring-configuration-metadata.json | 20 +++++++++++++++++++
 2 files changed, 25 insertions(+)

diff --git a/datamanager/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/datamanager/src/main/resources/META-INF/additional-spring-configuration-metadata.json
index 20f805510..e1e885229 100644
--- a/datamanager/src/main/resources/META-INF/additional-spring-configuration-metadata.json
+++ b/datamanager/src/main/resources/META-INF/additional-spring-configuration-metadata.json
@@ -23,5 +23,10 @@
     "name": "core_system_name",
     "type": "java.lang.String",
     "description": "A description for 'core_system_name'"
+  },
+  {
+    "name": "websockets.enabled",
+    "type": "java.lang.Boolean",
+    "description": "Enables WebSocket support"
   }
 ]}
\ No newline at end of file
diff --git a/timemanager/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/timemanager/src/main/resources/META-INF/additional-spring-configuration-metadata.json
index 20f805510..5b665b9a5 100644
--- a/timemanager/src/main/resources/META-INF/additional-spring-configuration-metadata.json
+++ b/timemanager/src/main/resources/META-INF/additional-spring-configuration-metadata.json
@@ -23,5 +23,25 @@
     "name": "core_system_name",
     "type": "java.lang.String",
     "description": "A description for 'core_system_name'"
+  },
+  {
+    "name": "time.timezone",
+    "type": "java.lang.String",
+    "description": "The Local cloud time zone"
+  },
+  {
+    "name": "ntp.server.list",
+    "type": "java.lang.String",
+    "description": "The NTP server to use"
+  },
+  {
+    "name": "time.offset.threshold",
+    "type": "java.lang.Integer",
+    "description": "The maximum allowed time difference for a trusted NTP server"
+  },
+  {
+    "name": "websockets.enabled",
+    "type": "java.lang.Boolean",
+    "description": "Enables WebSocket support"
   }
 ]}
\ No newline at end of file

From 22be6a850e4cd49a074e16f8bd4cc6c27a3cd540 Mon Sep 17 00:00:00 2001
From: Jens Eliasson <jens.eliasson@gmail.com>
Date: Fri, 23 Jul 2021 16:19:34 +0200
Subject: [PATCH 30/53] code updates after feedback

---
 .../core/timemanager/TimeWSHandler.java       | 13 ++--
 .../service/TimeManagerDriver.java            | 64 +++++++++----------
 2 files changed, 38 insertions(+), 39 deletions(-)

diff --git a/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeWSHandler.java b/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeWSHandler.java
index 4a05fcd92..48f309f1e 100644
--- a/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeWSHandler.java
+++ b/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeWSHandler.java
@@ -32,10 +32,10 @@
 import org.springframework.web.socket.handler.TextWebSocketHandler;
 
 import eu.arrowhead.common.CommonConstants;
-//import eu.arrowhead.core.timemanager.security.TimemanagerACLFilter;
 import eu.arrowhead.common.Utilities;
 import eu.arrowhead.common.dto.shared.TimeManagerTimeResponseDTO;
 import eu.arrowhead.core.timemanager.service.TimeManagerDriver;
+import jdk.internal.reflect.UTF8;
 
 import com.google.gson.*;
 import com.google.gson.reflect.TypeToken;
@@ -44,8 +44,12 @@
 @EnableScheduling
 public class TimeWSHandler extends TextWebSocketHandler {
  
+    //=================================================================================================
+    // members
+
+    private static final String MESSAGE_ENCODING = "UTF-8";
+
     private final Logger logger = LogManager.getLogger(TimeWSHandler.class);
-    //private Gson gson = new Gson();
     
     private final List<WebSocketSession> sessions = new CopyOnWriteArrayList<>();
  
@@ -58,9 +62,6 @@ public class TimeWSHandler extends TextWebSocketHandler {
     @Autowired
     TimeManagerDriver timeManagerDriver;
 
-    //@Autowired
-    //TimemanagerACLFilter dataManagerACLFilter;
-
     //=================================================================================================
     // methods
 
@@ -81,7 +82,7 @@ public void sendOutTimeMessages() {
         sessions.forEach(webSocketSession -> {
             try {
                 TimeManagerTimeResponseDTO response = new TimeManagerTimeResponseDTO(serverTimeZone, timeManagerDriver.isTimeTrusted());
-                TextMessage msg = new TextMessage(Utilities.toJson(response).getBytes("UTF-8"));
+                TextMessage msg = new TextMessage(Utilities.toJson(response).getBytes(MESSAGE_ENCODING));
                 webSocketSession.sendMessage(msg);
             } catch (IOException e) {
                 logger.error("Error occurred.", e);
diff --git a/timemanager/src/main/java/eu/arrowhead/core/timemanager/service/TimeManagerDriver.java b/timemanager/src/main/java/eu/arrowhead/core/timemanager/service/TimeManagerDriver.java
index 179023cfd..d4b221e96 100644
--- a/timemanager/src/main/java/eu/arrowhead/core/timemanager/service/TimeManagerDriver.java
+++ b/timemanager/src/main/java/eu/arrowhead/core/timemanager/service/TimeManagerDriver.java
@@ -72,45 +72,43 @@ public boolean isTimeTrusted() {
 	@Scheduled(fixedDelay = 1000 * 60, initialDelay = 1000 * 1)
     public void checkExternalTimeServer() {
 		logger.info("Checking external time!");
-	
-		final NTPUDPClient client = new NTPUDPClient();
-	
-		client.setDefaultTimeout(10000);
-
-		try {
-		  client.open();
 		  
-			try {
-			  final InetAddress hostAddr = InetAddress.getByName(serverList);
-			  final TimeInfo info = client.getTime(hostAddr);
-			  info.computeDetails();
-			 
-			  final Long offsetMillis = info.getOffset();
-			  final Long delayMillis = info.getDelay();
-			  final long offset = offsetMillis.longValue();
-			  logger.debug("Roundtrip delay(ms)=" + delayMillis + ", clock offset(ms)=" + delayMillis); // offset in ms
-
-			  if (offsetMillis == null) {
+		try {
+			final NTPUDPClient client = new NTPUDPClient();
+			client.setDefaultTimeout(10000);
+			client.open();
+			final InetAddress hostAddr = InetAddress.getByName(serverList);
+			final TimeInfo info = client.getTime(hostAddr);
+			client.close();
+			if (info == null) {
 				isTimeTrusted.set(false);
 				logger.debug("Couldn't get a response, something is wrong!");
 				return;
-			  }
-
-			  if (offset < timeOffsetThreshold) {
-				  isTimeTrusted.set(true);
-			  } else {
-				  logger.debug("Time offset too large, something is wrong!");
-				  isTimeTrusted.set(false);
-			  }
-
-			} catch (final IOException ioe) {
-			  ioe.printStackTrace();
 			}
-		} catch (final SocketException e) {
-		  e.printStackTrace();
+			info.computeDetails();
+ 
+			if (info.getOffset() == null || info.getDelay() == null) {
+				isTimeTrusted.set(false);
+				logger.debug("Response details are wrong!");
+				return;
+			}
+
+			final Long offsetMillis = info.getOffset();
+			final Long delayMillis = info.getDelay();
+			final long offset = offsetMillis.longValue();
+			logger.debug("Roundtrip delay(ms)=" + delayMillis + ", clock offset(ms)=" + delayMillis); // offset in ms
+
+			if (offset < timeOffsetThreshold) {
+				isTimeTrusted.set(true);
+		  	} else {
+			  logger.debug("Time offset too large, something is wrong!");
+			  isTimeTrusted.set(false);
+		  	}
+		} catch (final Exception e) {
+			logger.debug("Exception occured: " + e.toString());
+			isTimeTrusted.set(false);
+			return;
 		}
-	
-		client.close();
 	  }
 	//=================================================================================================
 

From 018a7e5938345734ea41f98b4a1c4284e2b3a3bb Mon Sep 17 00:00:00 2001
From: Jens Eliasson <jens.eliasson@gmail.com>
Date: Fri, 23 Jul 2021 16:25:40 +0200
Subject: [PATCH 31/53] code cleanup

---
 .../arrowhead/core/timemanager/service/TimeManagerDriver.java   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/timemanager/src/main/java/eu/arrowhead/core/timemanager/service/TimeManagerDriver.java b/timemanager/src/main/java/eu/arrowhead/core/timemanager/service/TimeManagerDriver.java
index d4b221e96..a30b04d86 100644
--- a/timemanager/src/main/java/eu/arrowhead/core/timemanager/service/TimeManagerDriver.java
+++ b/timemanager/src/main/java/eu/arrowhead/core/timemanager/service/TimeManagerDriver.java
@@ -71,7 +71,7 @@ public boolean isTimeTrusted() {
 	//-------------------------------------------------------------------------------------------------
 	@Scheduled(fixedDelay = 1000 * 60, initialDelay = 1000 * 1)
     public void checkExternalTimeServer() {
-		logger.info("Checking external time!");
+		logger.debug("Checking external time!");
 		  
 		try {
 			final NTPUDPClient client = new NTPUDPClient();

From ea9513291a142878413fe663a75071deb74c2f45 Mon Sep 17 00:00:00 2001
From: Jens Eliasson <jens.eliasson@gmail.com>
Date: Fri, 23 Jul 2021 16:43:05 +0200
Subject: [PATCH 32/53] code cleanup

---
 .../eu/arrowhead/core/timemanager/TimeWSHandler.java  | 11 +++--------
 .../security/TimemanagerAccessControlFilter.java      |  1 -
 2 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeWSHandler.java b/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeWSHandler.java
index 48f309f1e..860c565f2 100644
--- a/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeWSHandler.java
+++ b/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeWSHandler.java
@@ -12,11 +12,11 @@
  *   Arrowhead Consortia - conceptualization 
  ********************************************************************************/
 package eu.arrowhead.core.timemanager;
- 
+
+import java.nio.charset.StandardCharsets;
 import java.io.IOException;
 import java.util.List;
 import java.util.Vector;
-import java.util.Map;
 import java.util.concurrent.CopyOnWriteArrayList;
 
 import org.apache.logging.log4j.LogManager;
@@ -35,10 +35,7 @@
 import eu.arrowhead.common.Utilities;
 import eu.arrowhead.common.dto.shared.TimeManagerTimeResponseDTO;
 import eu.arrowhead.core.timemanager.service.TimeManagerDriver;
-import jdk.internal.reflect.UTF8;
 
-import com.google.gson.*;
-import com.google.gson.reflect.TypeToken;
 
 @Component
 @EnableScheduling
@@ -47,8 +44,6 @@ public class TimeWSHandler extends TextWebSocketHandler {
     //=================================================================================================
     // members
 
-    private static final String MESSAGE_ENCODING = "UTF-8";
-
     private final Logger logger = LogManager.getLogger(TimeWSHandler.class);
     
     private final List<WebSocketSession> sessions = new CopyOnWriteArrayList<>();
@@ -82,7 +77,7 @@ public void sendOutTimeMessages() {
         sessions.forEach(webSocketSession -> {
             try {
                 TimeManagerTimeResponseDTO response = new TimeManagerTimeResponseDTO(serverTimeZone, timeManagerDriver.isTimeTrusted());
-                TextMessage msg = new TextMessage(Utilities.toJson(response).getBytes(MESSAGE_ENCODING));
+                TextMessage msg = new TextMessage(Utilities.toJson(response).getBytes(StandardCharsets.UTF_8));
                 webSocketSession.sendMessage(msg);
             } catch (IOException e) {
                 logger.error("Error occurred.", e);
diff --git a/timemanager/src/main/java/eu/arrowhead/core/timemanager/security/TimemanagerAccessControlFilter.java b/timemanager/src/main/java/eu/arrowhead/core/timemanager/security/TimemanagerAccessControlFilter.java
index 2ea62ce75..4d5d1c724 100644
--- a/timemanager/src/main/java/eu/arrowhead/core/timemanager/security/TimemanagerAccessControlFilter.java
+++ b/timemanager/src/main/java/eu/arrowhead/core/timemanager/security/TimemanagerAccessControlFilter.java
@@ -45,7 +45,6 @@ public class TimemanagerAccessControlFilter extends CoreSystemAccessControlFilte
 	protected void checkClientAuthorized(final String clientCN, final String method, final String requestTarget, final String requestJSON, final Map<String,String[]> queryParams) {
 		super.checkClientAuthorized(clientCN, method, requestTarget, requestJSON, queryParams);
 
-		
 		if (requestTarget.endsWith(CommonConstants.ECHO_URI)) {
                         // Everybody in the local cloud can test the server => no further check is necessary
                         return;

From 4388b01636bfa7a44fc47aa47544675f29fcd17e Mon Sep 17 00:00:00 2001
From: Jens Eliasson <jens.eliasson@gmail.com>
Date: Mon, 26 Jul 2021 17:38:51 +0200
Subject: [PATCH 33/53] coe updaed after review

---
 .../java/eu/arrowhead/common/CommonConstants.java |  2 ++
 .../main/java/eu/arrowhead/common/SslUtil.java    |  4 ++--
 .../core/timemanager/TimeManagerController.java   |  5 ++++-
 .../core/timemanager/TimeManagerWSConfig.java     |  8 ++------
 ...r.java => TimeManagerAccessControlFilter.java} |  2 +-
 .../timemanager/service/TimeManagerDriver.java    | 15 +++++++++++----
 6 files changed, 22 insertions(+), 14 deletions(-)
 rename timemanager/src/main/java/eu/arrowhead/core/timemanager/security/{TimemanagerAccessControlFilter.java => TimeManagerAccessControlFilter.java} (97%)

diff --git a/core-common/src/main/java/eu/arrowhead/common/CommonConstants.java b/core-common/src/main/java/eu/arrowhead/common/CommonConstants.java
index 453094b5a..a4d68544d 100644
--- a/core-common/src/main/java/eu/arrowhead/common/CommonConstants.java
+++ b/core-common/src/main/java/eu/arrowhead/common/CommonConstants.java
@@ -302,6 +302,8 @@ public class CommonConstants {
 	
 	public static final String SERVER_SSL_ENABLED = "server.ssl.enabled";
 	public static final String $SERVER_SSL_ENABLED_WD = "${" + SERVER_SSL_ENABLED + ":" + Defaults.DEFAULT_SSL_SERVER_ENABLED + "}";
+	public static final String WEBSOCKETS_ENABLED = "websockets.enabled";
+	public static final String $WEBSOCKETS_ENABLED = "${" + WEBSOCKETS_ENABLED + "}";
 	public static final String KEYSTORE_TYPE = "server.ssl.key-store-type";
 	public static final String $KEYSTORE_TYPE = "${" + KEYSTORE_TYPE + "}";
 	public static final String KEYSTORE_PATH = "server.ssl.key-store";
diff --git a/core-common/src/main/java/eu/arrowhead/common/SslUtil.java b/core-common/src/main/java/eu/arrowhead/common/SslUtil.java
index bea79be26..351d500f5 100644
--- a/core-common/src/main/java/eu/arrowhead/common/SslUtil.java
+++ b/core-common/src/main/java/eu/arrowhead/common/SslUtil.java
@@ -47,7 +47,6 @@
 import org.bouncycastle.openssl.jcajce.JcaPEMKeyConverter;
 import org.bouncycastle.openssl.jcajce.JcePEMDecryptorProviderBuilder;
 
-
 public class SslUtil
 {
 
@@ -60,7 +59,7 @@ public class SslUtil
     private static final String PRIVATE_KEY = "private-key";
     private static final String TLS_VERSION = "TLSv1.3";
 
-    private final Logger logger = LogManager.getLogger(SslUtil.class);
+    private static final Logger logger = LogManager.getLogger(SslUtil.class);
 
     //=================================================================================================
     // methods
@@ -122,6 +121,7 @@ public static SSLSocketFactory getSslSocketFactory(final String caCrtFile, final
 
                      return context.getSocketFactory();
               } catch(Exception e) {
+                     logger.debug("Unhandled exception: " + e.toString());
                      throw e;
               } finally {
                      if (parser != null) {
diff --git a/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeManagerController.java b/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeManagerController.java
index 2fa01cef4..cba7acdd9 100644
--- a/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeManagerController.java
+++ b/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeManagerController.java
@@ -44,9 +44,12 @@
 @RestController
 @RequestMapping(CommonConstants.TIMEMANAGER_URI)
 public class TimeManagerController {
+
+	private static final String TIME_TZ = "${time.timezone}";
+
 	private final Logger logger = LogManager.getLogger(TimeManagerController.class);
 
-	@Value("${time.timezone}")
+	@Value(TIME_TZ)
     private String serverTimeZone;
 
 	//=================================================================================================
diff --git a/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeManagerWSConfig.java b/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeManagerWSConfig.java
index 894729f4f..92b2d55dc 100644
--- a/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeManagerWSConfig.java
+++ b/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeManagerWSConfig.java
@@ -51,10 +51,10 @@ public class TimeManagerWSConfig implements WebSocketConfigurer {
 
     private final Logger logger = LogManager.getLogger(TimeManagerWSConfig.class);
 
-    @Value("${server.ssl.enabled}")
+    @Value(CommonConstants.SERVER_SSL_ENABLED)
     private boolean sslEnabled;
 
-    @Value("${websockets.enabled}")
+    @Value(CommonConstants.WEBSOCKETS_ENABLED)
     private boolean websocketsEnabled;
 
     @Autowired
@@ -62,9 +62,6 @@ public class TimeManagerWSConfig implements WebSocketConfigurer {
 
     @Autowired
     private TimeManagerDriver timeManagerDriver;
-    
-    //@Autowired
-    //private TimemanagerACLFilter timeACLFilter;
 
     @Override
     public void registerWebSocketHandlers(WebSocketHandlerRegistry webSocketHandlerRegistry) {
@@ -88,7 +85,6 @@ public boolean beforeHandshake(ServerHttpRequest request, ServerHttpResponse res
                 final String systemId = path.substring(path.lastIndexOf('/') + 1);
                 String CN = null;
 
-                // if running in secure mode, check authorization (ACL)
                 if(sslEnabled) {  
                     if (request instanceof org.springframework.http.server.ServletServerHttpRequest) {
                         CN = SecurityUtilities.getCertificateCNFromServerRequest((ServletServerHttpRequest)request);
diff --git a/timemanager/src/main/java/eu/arrowhead/core/timemanager/security/TimemanagerAccessControlFilter.java b/timemanager/src/main/java/eu/arrowhead/core/timemanager/security/TimeManagerAccessControlFilter.java
similarity index 97%
rename from timemanager/src/main/java/eu/arrowhead/core/timemanager/security/TimemanagerAccessControlFilter.java
rename to timemanager/src/main/java/eu/arrowhead/core/timemanager/security/TimeManagerAccessControlFilter.java
index 4d5d1c724..58d4c058b 100644
--- a/timemanager/src/main/java/eu/arrowhead/core/timemanager/security/TimemanagerAccessControlFilter.java
+++ b/timemanager/src/main/java/eu/arrowhead/core/timemanager/security/TimeManagerAccessControlFilter.java
@@ -32,7 +32,7 @@
 
 @Component
 @ConditionalOnProperty(name = CommonConstants.SERVER_SSL_ENABLED, matchIfMissing = true) 
-public class TimemanagerAccessControlFilter extends CoreSystemAccessControlFilter {
+public class TimeManagerAccessControlFilter extends CoreSystemAccessControlFilter {
 	
 	//=================================================================================================
         // members
diff --git a/timemanager/src/main/java/eu/arrowhead/core/timemanager/service/TimeManagerDriver.java b/timemanager/src/main/java/eu/arrowhead/core/timemanager/service/TimeManagerDriver.java
index a30b04d86..e335283ab 100644
--- a/timemanager/src/main/java/eu/arrowhead/core/timemanager/service/TimeManagerDriver.java
+++ b/timemanager/src/main/java/eu/arrowhead/core/timemanager/service/TimeManagerDriver.java
@@ -50,12 +50,19 @@ public class TimeManagerDriver {
 
 	//=================================================================================================
 	// members
+
+	private static final String NTP_SERVER_LIST = "${ntp.server.list}";
+	private static final String TIME_OFFSET_THRESHOLD = "${time.offset.threshold}";
+
+	private static final int TIME_CHECK_INTERVAL = 1000 * 60;
+	private static final int TIME_CHECK_INITIAL = 1000 * 1;
+
 	private final Logger logger = LogManager.getLogger(TimeManagerDriver.class);
 
-	@Value("${ntp.server.list}")
+	@Value(NTP_SERVER_LIST)
     private String serverList;
 
-	@Value("${time.offset.threshold}")
+	@Value(TIME_OFFSET_THRESHOLD)
 	private long timeOffsetThreshold; 
 
 	private AtomicBoolean isTimeTrusted = new AtomicBoolean(true);
@@ -69,7 +76,7 @@ public boolean isTimeTrusted() {
 	}
 
 	//-------------------------------------------------------------------------------------------------
-	@Scheduled(fixedDelay = 1000 * 60, initialDelay = 1000 * 1)
+	@Scheduled(fixedDelay = TIME_CHECK_INTERVAL, initialDelay = TIME_CHECK_INITIAL)
     public void checkExternalTimeServer() {
 		logger.debug("Checking external time!");
 		  
@@ -96,7 +103,7 @@ public void checkExternalTimeServer() {
 			final Long offsetMillis = info.getOffset();
 			final Long delayMillis = info.getDelay();
 			final long offset = offsetMillis.longValue();
-			logger.debug("Roundtrip delay(ms)=" + delayMillis + ", clock offset(ms)=" + delayMillis); // offset in ms
+			logger.debug("Roundtrip delay(ms)=" + delayMillis + ", clock offset(ms)=" + offsetMillis);
 
 			if (offset < timeOffsetThreshold) {
 				isTimeTrusted.set(true);

From c6d4d10769fbdf6075281b000e5344aa6471b540 Mon Sep 17 00:00:00 2001
From: Jens Eliasson <jens.eliasson@gmail.com>
Date: Tue, 27 Jul 2021 00:01:03 +0200
Subject: [PATCH 34/53] code updates

---
 .../src/main/java/eu/arrowhead/common/CommonConstants.java    | 2 +-
 core-common/src/main/java/eu/arrowhead/common/Defaults.java   | 1 +
 .../eu/arrowhead/core/timemanager/TimeManagerWSConfig.java    | 4 ++--
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/core-common/src/main/java/eu/arrowhead/common/CommonConstants.java b/core-common/src/main/java/eu/arrowhead/common/CommonConstants.java
index a4d68544d..52a99a1fb 100644
--- a/core-common/src/main/java/eu/arrowhead/common/CommonConstants.java
+++ b/core-common/src/main/java/eu/arrowhead/common/CommonConstants.java
@@ -303,7 +303,7 @@ public class CommonConstants {
 	public static final String SERVER_SSL_ENABLED = "server.ssl.enabled";
 	public static final String $SERVER_SSL_ENABLED_WD = "${" + SERVER_SSL_ENABLED + ":" + Defaults.DEFAULT_SSL_SERVER_ENABLED + "}";
 	public static final String WEBSOCKETS_ENABLED = "websockets.enabled";
-	public static final String $WEBSOCKETS_ENABLED = "${" + WEBSOCKETS_ENABLED + "}";
+	public static final String $WEBSOCKETS_ENABLED_WD = "${" + WEBSOCKETS_ENABLED + ":" + Defaults.DEFAULT_WEBSOCKETS_ENABLED + "}";
 	public static final String KEYSTORE_TYPE = "server.ssl.key-store-type";
 	public static final String $KEYSTORE_TYPE = "${" + KEYSTORE_TYPE + "}";
 	public static final String KEYSTORE_PATH = "server.ssl.key-store";
diff --git a/core-common/src/main/java/eu/arrowhead/common/Defaults.java b/core-common/src/main/java/eu/arrowhead/common/Defaults.java
index 547541a9d..227bf83d2 100644
--- a/core-common/src/main/java/eu/arrowhead/common/Defaults.java
+++ b/core-common/src/main/java/eu/arrowhead/common/Defaults.java
@@ -20,6 +20,7 @@ public class Defaults {
 	// members
 	
 	public static final boolean DEFAULT_SSL_SERVER_ENABLED = true;
+	public static final boolean DEFAULT_WEBSOCKETS_ENABLED = false;
 	public static final boolean DEFAULT_DISABLE_HOSTNAME_VERIFIER = false;
 	public static final boolean DEFAULT_LOG_ALL_REQUEST_AND_RESPONSE = false;
 	public static final int DEFAULT_URI_CRAWLER_INTERVAL = 30;
diff --git a/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeManagerWSConfig.java b/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeManagerWSConfig.java
index 92b2d55dc..4a0c31042 100644
--- a/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeManagerWSConfig.java
+++ b/timemanager/src/main/java/eu/arrowhead/core/timemanager/TimeManagerWSConfig.java
@@ -51,10 +51,10 @@ public class TimeManagerWSConfig implements WebSocketConfigurer {
 
     private final Logger logger = LogManager.getLogger(TimeManagerWSConfig.class);
 
-    @Value(CommonConstants.SERVER_SSL_ENABLED)
+    @Value(CommonConstants.$SERVER_SSL_ENABLED_WD)
     private boolean sslEnabled;
 
-    @Value(CommonConstants.WEBSOCKETS_ENABLED)
+    @Value(CommonConstants.$WEBSOCKETS_ENABLED_WD)
     private boolean websocketsEnabled;
 
     @Autowired

From ca66a35166c18a0bd6d3d7bf464ff8b8d523f6e8 Mon Sep 17 00:00:00 2001
From: Jens Eliasson <jens.eliasson@gmail.com>
Date: Sun, 1 Aug 2021 20:03:59 +0200
Subject: [PATCH 35/53] added TimeManager information

---
 README.md | 32 +++++++++++++++++++++++++++++++-
 1 file changed, 31 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index da736d550..20e587087 100644
--- a/README.md
+++ b/README.md
@@ -80,7 +80,13 @@ Please be aware, that versions starting from 4.1.3 are __NOT__ backwards compati
        * [Service Description Overview](#datamanager_provided_services)
        * [Endpoints](#datamanager_endpoints)
 	       * [Client](#datamanager_endpoints_client)
-    8. [Certificate Authority](#ca)
+    8. [TimeManager](#timemanager)
+       * [System Design Description Overview](#timemanager_sdd)
+       * [Services and Use Cases](#timemanager_usecases)  
+       * [Service Description Overview](#timemanager_provided_services)
+       * [Endpoints](#timemanager_endpoints)
+	       * [Client](#timemanager_endpoints_client)
+    9. [Certificate Authority](#ca)
        * [System Design Description Overview](#ca_sdd)
        * [Services and Use Cases](#ca_usecases)  
        * [Endpoints](#ca_endpoints)
@@ -268,6 +274,7 @@ Authorization will be available on ```https://localhost:8445``` <br />
 Orchestrator will be available on ```https://localhost:8441``` <br />
 Event Handler will be available on ```https://localhost:8455``` <br />
 DataManager will be available on ```https://localhost:8461``` <br />
+TimeManager will be available on ```https://localhost:8463``` <br />
 Gatekeeper will be available on ```https://localhost:8449``` <br />
 Gateway will be available on ```https://localhost:8453``` <br />
 
@@ -5103,6 +5110,29 @@ __PutSServiceDataRequest__ input:
 ]
 ```
 
+<a name="timemanager" />
+
+# TimeManager
+
+<a name="timemanager_sdd" />
+
+## System Design Description Overview
+
+The purpose of TimeManager supporting core system is to provide time and location based services.
+
+![#1589F0](https://placehold.it/15/1589F0/000000?text=+) `AH Service Registry`
+![#f03c15](https://placehold.it/15/f03c15/000000?text=+) `AH Authorization` 
+![#c5f015](https://placehold.it/15/c5f015/000000?text=+) `AH Orchestrator`
+![#ffcc44](https://placehold.it/15/ffcc44/000000?text=+) `AH TimeManager`
+![Alt text](/documentation/datamanager/overview.png)
+
+The TimeManager provides features for a local cloud systems to :
+* Fetch accurate and trusted time and location information,
+
+
+<a name="timemanager_sysd" />
+
+
 # Gatekeeper 
 
 <a name="gatekeeper_sdd" />

From 100f6deda2e810935ca640809770dbe9462490d7 Mon Sep 17 00:00:00 2001
From: Jens Eliasson <jens.eliasson@gmail.com>
Date: Sun, 1 Aug 2021 20:05:30 +0200
Subject: [PATCH 36/53] added more TimeManager information

---
 README.md | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/README.md b/README.md
index 20e587087..02865cec7 100644
--- a/README.md
+++ b/README.md
@@ -5132,6 +5132,29 @@ The TimeManager provides features for a local cloud systems to :
 
 <a name="timemanager_sysd" />
 
+## System Design Overview
+
+<a name="timeamanager_provided_services" />
+
+## Provided services
+
+The TimeManager provides the following services:
+* [Echo](#timemanager_endpoints_get_echo)
+* [Time](#timemanager_endpoints_time)
+
+<a name="timemanager_consumed_services" />
+
+## Consumed services
+
+The TimeManager consumes the following services:
+
+None currently, but will consume Orchestration later on.
+
+<a name="timemanager_usecases" />
+
+## Use cases
+
+The TimeManager has the following use cases:
 
 # Gatekeeper 
 

From 03c081a0946a0549d50cd41f4b4a09e6f2bc5f43 Mon Sep 17 00:00:00 2001
From: Jens Eliasson <jens.eliasson@gmail.com>
Date: Sun, 1 Aug 2021 20:56:55 +0200
Subject: [PATCH 37/53] more documentation

---
 README.md | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index 02865cec7..fe640cdba 100644
--- a/README.md
+++ b/README.md
@@ -4866,8 +4866,6 @@ The DataManager has the following use cases:
 Swagger API documentation is available on: `https://<host>:<port>` <br />
 The base URL for the requests: `http://<host>:<port>/datamanager`
 
-
-
 ### Client endpoint description<br />
 
 | Function | URL subpath | Method | Input | Output |
@@ -5156,6 +5154,19 @@ None currently, but will consume Orchestration later on.
 
 The TimeManager has the following use cases:
 
+<a name="timemanager_endpoints_time" />
+
+## Endpoints
+
+Swagger API documentation is available on: `https://<host>:<port>` <br />
+The base URL for the requests: `http://<host>:<port>/timemanager`
+
+### Client endpoint description<br />
+
+| Function | URL subpath | Method | Input | Output |
+| -------- | ----------- | ------ | ----- | ------ |
+| [Echo](#datamanager_endpoints_get_echo) | /echo | GET    | -    | OK     |
+
 # Gatekeeper 
 
 <a name="gatekeeper_sdd" />

From 8071bb59c7c8153fdda89de51136cf8a68c0842d Mon Sep 17 00:00:00 2001
From: Jens Eliasson <jens.eliasson@gmail.com>
Date: Sun, 1 Aug 2021 21:00:16 +0200
Subject: [PATCH 38/53] more documentation TM

---
 README.md | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index fe640cdba..1b3b9f616 100644
--- a/README.md
+++ b/README.md
@@ -5059,7 +5059,7 @@ __GetServiceDataResponse__ output:
 
 [
    {
-        "bn": "string",
+    "bn": "string",
 	"bt": 0.0,
 	"bu": "string",
 	"bver": 0
@@ -5153,6 +5153,7 @@ None currently, but will consume Orchestration later on.
 ## Use cases
 
 The TimeManager has the following use cases:
+* [Fetch trusted time](documentation/timemanager/use_cases/TM_use_case_1.md)
 
 <a name="timemanager_endpoints_time" />
 
@@ -5165,7 +5166,8 @@ The base URL for the requests: `http://<host>:<port>/timemanager`
 
 | Function | URL subpath | Method | Input | Output |
 | -------- | ----------- | ------ | ----- | ------ |
-| [Echo](#datamanager_endpoints_get_echo) | /echo | GET    | -    | OK     |
+| [Echo](#timemanager_endpoints_get_echo) | /echo | GET    | -    | OK     |
+| [Time](#timemanager_endpoints_get_time) | /time | GET    | -    | OK     |
 
 # Gatekeeper 
 

From faad147d3cee14ec0b11e4666673d2e0d0a8c559 Mon Sep 17 00:00:00 2001
From: Jens Eliasson <jens.eliasson@gmail.com>
Date: Sun, 1 Aug 2021 21:09:33 +0200
Subject: [PATCH 39/53] data models TM

---
 README.md | 34 +++++++++++++++++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 1b3b9f616..9546b4f84 100644
--- a/README.md
+++ b/README.md
@@ -5167,7 +5167,39 @@ The base URL for the requests: `http://<host>:<port>/timemanager`
 | Function | URL subpath | Method | Input | Output |
 | -------- | ----------- | ------ | ----- | ------ |
 | [Echo](#timemanager_endpoints_get_echo) | /echo | GET    | -    | OK     |
-| [Time](#timemanager_endpoints_get_time) | /time | GET    | -    | OK     |
+| [Time](#timemanager_endpoints_get_time) | /time | GET    | -    | TimeResponse  |
+
+<a name="timemanager_endpoints_get_echo" />
+
+### Echo
+```
+GET /timemanager/echo
+```
+
+Returns a "Got it!" message with the purpose of testing the system availability.
+
+### Get trusted time and location
+```
+GET /timemanager/time
+```
+
+Returns time stamps (UNIX in seconds and millseconds), time zone ("Europe/Budapest"), Daylist savings active (true/false) and if the time is trusted (true/false).
+
+<a name="timemanager_gettime_response" />
+
+__GetTimeResponse__ output:
+
+```json
+
+{
+  "epoch": 1627844812,
+  "epochMs": 1627844812102,
+  "tz": string,
+  "dst": true,
+  "trusted": true
+}
+
+```
 
 # Gatekeeper 
 

From 39dc753e280ca5a748970ffc9f96d34d48a8b15b Mon Sep 17 00:00:00 2001
From: Jens Eliasson <jens.eliasson@gmail.com>
Date: Sun, 1 Aug 2021 21:14:10 +0200
Subject: [PATCH 40/53] documentation cleanup TM

---
 README.md | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/README.md b/README.md
index 9546b4f84..b0dd6f5c6 100644
--- a/README.md
+++ b/README.md
@@ -4815,11 +4815,6 @@ This service can only be used by other core services, therefore this is not part
 
 The purpose of DataManager supporting core system is to provide storage of sensor data.
 
-![#1589F0](https://placehold.it/15/1589F0/000000?text=+) `AH Service Registry`
-![#f03c15](https://placehold.it/15/f03c15/000000?text=+) `AH Authorization` 
-![#c5f015](https://placehold.it/15/c5f015/000000?text=+) `AH Orchestrator`
-![#ffcc44](https://placehold.it/15/ffcc44/000000?text=+) `AH DataManager`
-![Alt text](/documentation/datamanager/overview.png)
 
 The DataManager provides features for producers and consumers to:
 * Store SenML sensor and actuator data,
@@ -5118,12 +5113,6 @@ __PutSServiceDataRequest__ input:
 
 The purpose of TimeManager supporting core system is to provide time and location based services.
 
-![#1589F0](https://placehold.it/15/1589F0/000000?text=+) `AH Service Registry`
-![#f03c15](https://placehold.it/15/f03c15/000000?text=+) `AH Authorization` 
-![#c5f015](https://placehold.it/15/c5f015/000000?text=+) `AH Orchestrator`
-![#ffcc44](https://placehold.it/15/ffcc44/000000?text=+) `AH TimeManager`
-![Alt text](/documentation/datamanager/overview.png)
-
 The TimeManager provides features for a local cloud systems to :
 * Fetch accurate and trusted time and location information,
 
@@ -5178,6 +5167,8 @@ GET /timemanager/echo
 
 Returns a "Got it!" message with the purpose of testing the system availability.
 
+<a name="timemanager_endpoints_get_time" />
+
 ### Get trusted time and location
 ```
 GET /timemanager/time

From bcbb7555155fafd7964d418aa748b27989bbf188 Mon Sep 17 00:00:00 2001
From: Jens Eliasson <jens.eliasson@gmail.com>
Date: Sun, 1 Aug 2021 21:17:37 +0200
Subject: [PATCH 41/53] documentation with use cases TM

---
 documentation/timemanager/use_cases/TM_use_case_1.md | 7 +++++++
 1 file changed, 7 insertions(+)
 create mode 100644 documentation/timemanager/use_cases/TM_use_case_1.md

diff --git a/documentation/timemanager/use_cases/TM_use_case_1.md b/documentation/timemanager/use_cases/TM_use_case_1.md
new file mode 100644
index 000000000..8edcbc933
--- /dev/null
+++ b/documentation/timemanager/use_cases/TM_use_case_1.md
@@ -0,0 +1,7 @@
+| Name | Description |
+| ---- | --------- |
+| ID | Time-Get |
+| Brief Description | A Consumer fetches time information from the Time service |
+| Primary Actors | Consumer, TimeManager system |
+| Preconditions | -  None|
+| Main Flow | - The Consumer performs a request to the TimeManager's Time service. <br/>- The Time responds with time stamps, time zone information etc.
\ No newline at end of file

From a9edadf47f8edf9ea8ea4f6b19ca6649bb1536f4 Mon Sep 17 00:00:00 2001
From: Jens Eliasson <jens.eliasson@gmail.com>
Date: Sun, 1 Aug 2021 21:22:27 +0200
Subject: [PATCH 42/53] documentation cleanup TM

---
 README.md | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/README.md b/README.md
index b0dd6f5c6..9091ce1e5 100644
--- a/README.md
+++ b/README.md
@@ -4861,6 +4861,8 @@ The DataManager has the following use cases:
 Swagger API documentation is available on: `https://<host>:<port>` <br />
 The base URL for the requests: `http://<host>:<port>/datamanager`
 
+<a name="datamanager_endpoints_client" />
+
 ### Client endpoint description<br />
 
 | Function | URL subpath | Method | Input | Output |
@@ -4884,8 +4886,6 @@ GET /datamanager/echo
 
 Returns a "Got it!" message with the purpose of testing the system availability.
 
-<a name="datamanager_endpoints_client" />
-
 <a name="datamanager_proxyendpoints_getsys" />
 
 ### Get system list
@@ -5121,7 +5121,7 @@ The TimeManager provides features for a local cloud systems to :
 
 ## System Design Overview
 
-<a name="timeamanager_provided_services" />
+<a name="timemanager_provided_services" />
 
 ## Provided services
 
@@ -5151,6 +5151,8 @@ The TimeManager has the following use cases:
 Swagger API documentation is available on: `https://<host>:<port>` <br />
 The base URL for the requests: `http://<host>:<port>/timemanager`
 
+<a name="timemanager_endpoints_client" />
+
 ### Client endpoint description<br />
 
 | Function | URL subpath | Method | Input | Output |

From 560453d90e2088222f43fd448fa5dea2b5323df3 Mon Sep 17 00:00:00 2001
From: Jens Eliasson <jens.eliasson@gmail.com>
Date: Sun, 1 Aug 2021 21:25:43 +0200
Subject: [PATCH 43/53] documentation cleanup TM

---
 README.md | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index 9091ce1e5..4536f7ed8 100644
--- a/README.md
+++ b/README.md
@@ -5144,7 +5144,7 @@ None currently, but will consume Orchestration later on.
 The TimeManager has the following use cases:
 * [Fetch trusted time](documentation/timemanager/use_cases/TM_use_case_1.md)
 
-<a name="timemanager_endpoints_time" />
+<a name="timemanager_endpoints" />
 
 ## Endpoints
 
@@ -5187,7 +5187,7 @@ __GetTimeResponse__ output:
 {
   "epoch": 1627844812,
   "epochMs": 1627844812102,
-  "tz": string,
+  "tz": "string",
   "dst": true,
   "trusted": true
 }

From 1e6c725d7568ca8b7dc881597e10fe55531e90ba Mon Sep 17 00:00:00 2001
From: Jens Eliasson <jens.eliasson@gmail.com>
Date: Sun, 1 Aug 2021 21:26:53 +0200
Subject: [PATCH 44/53] documentation cleanup TM

---
 README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 4536f7ed8..f11277811 100644
--- a/README.md
+++ b/README.md
@@ -5180,7 +5180,7 @@ Returns time stamps (UNIX in seconds and millseconds), time zone ("Europe/Budape
 
 <a name="timemanager_gettime_response" />
 
-__GetTimeResponse__ output:
+__TimeResponse__ output:
 
 ```json
 

From c3bf5204552fbf0a70826f61fc07717bc8925afe Mon Sep 17 00:00:00 2001
From: Jens Eliasson <jens.eliasson@gmail.com>
Date: Sun, 1 Aug 2021 21:31:11 +0200
Subject: [PATCH 45/53] documentation cleanup DM

---
 README.md | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/README.md b/README.md
index f11277811..f9423ff17 100644
--- a/README.md
+++ b/README.md
@@ -4972,7 +4972,7 @@ Stores sensor data in a service endpoint in the proxy cache.
 
 <a name="datamanager_putsrvdata_request" />
 
-__PutSServiceDataRequest__ input:
+__PutServiceDataRequest__ input:
 
 ```json
 
@@ -5081,25 +5081,25 @@ Stores sensor data in a service endpoint in the database.
 
 <a name="datamanager_putsrvdata_request" />
 
-__PutSServiceDataRequest__ input:
+__PutServiceDataRequest__ input:
 
 ```json
 
 [
-   {
-        "bn": "string",
-	"bt": 0.0,
-	"bu": "string",
-	"bver": 0
-   }, {
-        "n": "string",
-	"t": 0.0,
-	"u": "string",
-	"v": 0.0,
-	"vs": "string",
-	"vb": false,
-	"vd": "string"
-   }
+  {
+    "bn": "string",
+    "bt": 0.0,
+    "bu": "string",
+    "bver": 0
+  }, {
+    "n": "string",
+    "t": 0.0,
+    "u": "string",
+    "v": 0.0,
+    "vs": "string",
+    "vb": false,
+    "vd": "string"
+  }
 ]
 ```
 

From 6c5e30f67244a276bcc32686df9f976992cee2c9 Mon Sep 17 00:00:00 2001
From: Jens Eliasson <jens.eliasson@gmail.com>
Date: Sun, 1 Aug 2021 21:33:24 +0200
Subject: [PATCH 46/53] documentation cleanup DM

---
 README.md | 48 ++++++++++++++++++++++++------------------------
 1 file changed, 24 insertions(+), 24 deletions(-)

diff --git a/README.md b/README.md
index f9423ff17..514e1872a 100644
--- a/README.md
+++ b/README.md
@@ -4944,7 +4944,7 @@ __GetServiceDataResponse__ output:
 ```json
 
 [
-   {
+  {
     "bn": "string",
 	  "bt": 0.0,
 	  "bu": "string",
@@ -4977,20 +4977,20 @@ __PutServiceDataRequest__ input:
 ```json
 
 [
-   {
+  {
     "bn": "string",
 	  "bt": 0.0,
 	  "bu": "string",
 	  "bver": 0
-    }, {
-     "n": "string",
-	   "t": 0.0,
-	   "u": "string",
-	   "v": 0.0,
-	   "vs": "string",
-	   "vb": false,
-	   "vd": "string"
-    }
+  }, {
+    "n": "string",
+	  "t": 0.0,
+	  "u": "string",
+	  "v": 0.0,
+	  "vs": "string",
+	  "vb": false,
+	  "vd": "string"
+  }
 ]
 ```
 
@@ -5053,20 +5053,20 @@ __GetServiceDataResponse__ output:
 ```json
 
 [
-   {
+  {
     "bn": "string",
-	"bt": 0.0,
-	"bu": "string",
-	"bver": 0
-   }, {
-        "n": "string",
-	"t": 0.0,
-	"u": "string",
-	"v": 0.0,
-	"vs": "string",
-	"vb": false,
-	"vd": "string"
-   }
+    "bt": 0.0,
+    "bu": "string",
+    "bver": 0
+  }, {
+    "n": "string",
+    "t": 0.0,
+    "u": "string",
+    "v": 0.0,
+    "vs": "string",
+    "vb": false,
+    "vd": "string"
+  }
 ]
 ```
 

From b042b9362095e40f614dcc5237d9aa72f8cd570a Mon Sep 17 00:00:00 2001
From: Jens Eliasson <jens.eliasson@gmail.com>
Date: Sun, 1 Aug 2021 21:36:28 +0200
Subject: [PATCH 47/53] documentation cleanup DM

---
 README.md | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/README.md b/README.md
index 514e1872a..506708509 100644
--- a/README.md
+++ b/README.md
@@ -4949,7 +4949,7 @@ __GetServiceDataResponse__ output:
 	  "bt": 0.0,
 	  "bu": "string",
 	  "bver": 0
-   }, {
+  }, {
     "n": "string",
 	  "t": 0.0,
 	  "u": "string",
@@ -4957,7 +4957,7 @@ __GetServiceDataResponse__ output:
 	  "vs": "string",
 	  "vb": false,
 	  "vd": "string"
-   }
+  }
 ]
 ```
 
@@ -4979,7 +4979,7 @@ __PutServiceDataRequest__ input:
 [
   {
     "bn": "string",
-	  "bt": 0.0,
+    "bt": 0.0,
 	  "bu": "string",
 	  "bver": 0
   }, {

From 4c7fc8278e33cfd5f82f9f3d6faa9ff51e59b861 Mon Sep 17 00:00:00 2001
From: Jens Eliasson <jens.eliasson@gmail.com>
Date: Sun, 1 Aug 2021 21:39:12 +0200
Subject: [PATCH 48/53] documentation indentation fixed DM

---
 README.md | 34 +++++++++++++++++-----------------
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/README.md b/README.md
index 506708509..4f8b79388 100644
--- a/README.md
+++ b/README.md
@@ -4946,17 +4946,17 @@ __GetServiceDataResponse__ output:
 [
   {
     "bn": "string",
-	  "bt": 0.0,
-	  "bu": "string",
-	  "bver": 0
+    "bt": 0.0,
+    "bu": "string",
+    "bver": 0
   }, {
     "n": "string",
-	  "t": 0.0,
-	  "u": "string",
-	  "v": 0.0,
-	  "vs": "string",
-	  "vb": false,
-	  "vd": "string"
+    "t": 0.0,
+    "u": "string",
+    "v": 0.0,
+    "vs": "string",
+    "vb": false,
+    "vd": "string"
   }
 ]
 ```
@@ -4980,16 +4980,16 @@ __PutServiceDataRequest__ input:
   {
     "bn": "string",
     "bt": 0.0,
-	  "bu": "string",
-	  "bver": 0
+    "bu": "string",
+    "bver": 0
   }, {
     "n": "string",
-	  "t": 0.0,
-	  "u": "string",
-	  "v": 0.0,
-	  "vs": "string",
-	  "vb": false,
-	  "vd": "string"
+    "t": 0.0,
+    "u": "string",
+    "v": 0.0,
+    "vs": "string",
+    "vb": false,
+    "vd": "string"
   }
 ]
 ```

From ebcbfe1320505fcc840abd9999c6c4e64a127116 Mon Sep 17 00:00:00 2001
From: Jens Eliasson <jens.eliasson@gmail.com>
Date: Mon, 2 Aug 2021 22:57:42 +0200
Subject: [PATCH 49/53] removed duplicate lines

---
 .../arrowhead/common/CoreCommonConstants.java   | 17 -----------------
 1 file changed, 17 deletions(-)

diff --git a/core-common/src/main/java/eu/arrowhead/common/CoreCommonConstants.java b/core-common/src/main/java/eu/arrowhead/common/CoreCommonConstants.java
index 150c291cd..e76173ad7 100644
--- a/core-common/src/main/java/eu/arrowhead/common/CoreCommonConstants.java
+++ b/core-common/src/main/java/eu/arrowhead/common/CoreCommonConstants.java
@@ -100,23 +100,6 @@ public class CoreCommonConstants {
 	public static final String $URI_CRAWLER_INTERVAL_WD = "${" + URI_CRAWLER_INTERVAL + ":" + CoreDefaults.DEFAULT_URI_CRAWLER_INTERVAL + "}";
 	public static final String AUTH_TOKEN_TTL_IN_MINUTES = "auth_token_ttl_in_minutes";
 	public static final String $AUTH_TOKEN_TTL_IN_MINUTES_WD = "${" + AUTH_TOKEN_TTL_IN_MINUTES + ":" + CoreDefaults.DEFAULT_AUTH_TOKEN_TTL_IN_MINUTES + "}";
-
-	public static final String MQTT_BROKER_ENABLED = "mqtt.broker.enabled";
-	public static final String $MQTT_BROKER_ENABLED = "${" + MQTT_BROKER_ENABLED + ":false}";
-	public static final String MQTT_BROKER_ADDRESS = "mqtt.broker.address";
-	public static final String $MQTT_BROKER_ADDRESS = "${" + MQTT_BROKER_ADDRESS + ":0.0.0.0}";
-	public static final String MQTT_BROKER_PORT = "mqtt.broker.port";
-	public static final String $MQTT_BROKER_PORT = "${" + MQTT_BROKER_PORT + ":0}";
-	public static final String MQTT_BROKER_USERNAME = "mqtt.broker.username";
-	public static final String $MQTT_BROKER_USERNAME = "${" + MQTT_BROKER_USERNAME + ":}";
-	public static final String MQTT_BROKER_PASSWORD = "mqtt.broker.password";
-	public static final String $MQTT_BROKER_PASSWORD = "${" + MQTT_BROKER_PASSWORD + ":}";
-	public static final String MQTT_BROKER_CAFILE = "mqtt.broker.cafile";
-	public static final String $MQTT_BROKER_CAFILE = "${" + MQTT_BROKER_CAFILE + ":}";
-	public static final String MQTT_BROKER_CERTFILE = "mqtt.broker.certfile";
-	public static final String $MQTT_BROKER_CERTFILE = "${" + MQTT_BROKER_CERTFILE + ":}";
-	public static final String MQTT_BROKER_KEYFILE = "mqtt.broker.keyfile";
-	public static final String $MQTT_BROKER_KEYFILE = "${" + MQTT_BROKER_KEYFILE + ":}";
 	
 	public static final String REQUEST_PARAM_PAGE = "page";
 	public static final String REQUEST_PARAM_ITEM_PER_PAGE = "item_per_page";

From 736eb00f4d1f735237c8f856e1370eedb5b4e6c5 Mon Sep 17 00:00:00 2001
From: Jens Eliasson <jens.eliasson@gmail.com>
Date: Tue, 3 Aug 2021 00:39:36 +0200
Subject: [PATCH 50/53] fixed indention

---
 .../java/eu/arrowhead/common/CoreCommonConstants.java     | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/core-common/src/main/java/eu/arrowhead/common/CoreCommonConstants.java b/core-common/src/main/java/eu/arrowhead/common/CoreCommonConstants.java
index e76173ad7..88cf3ef66 100644
--- a/core-common/src/main/java/eu/arrowhead/common/CoreCommonConstants.java
+++ b/core-common/src/main/java/eu/arrowhead/common/CoreCommonConstants.java
@@ -236,10 +236,10 @@ public class CoreCommonConstants {
     public static final String CERTIFICATE_FORMAT = "X.509";
 
 	// Translator-Fiware
-    public static final String FIWARE_SERVER_HOST = "fiware.server.host";
-    public static final String $FIWARE_SERVER_HOST = "${" + FIWARE_SERVER_HOST + ":}";
-    public static final String FIWARE_SERVER_PORT = "fiware.server.port";
-    public static final String $FIWARE_SERVER_PORT = "${" + FIWARE_SERVER_PORT + ":0}";
+	public static final String FIWARE_SERVER_HOST = "fiware.server.host";
+	public static final String $FIWARE_SERVER_HOST = "${" + FIWARE_SERVER_HOST + ":}";
+	public static final String FIWARE_SERVER_PORT = "fiware.server.port";
+	public static final String $FIWARE_SERVER_PORT = "${" + FIWARE_SERVER_PORT + ":0}";
 
 	// MQTT 
 	public static final String MQTT_BROKER_ENABLED = "mqtt.broker.enabled";

From 728ea3d4835b1f14b52aa9fae013e80c5dd074d3 Mon Sep 17 00:00:00 2001
From: Jens Eliasson <jens.eliasson@gmail.com>
Date: Tue, 3 Aug 2021 09:54:46 +0200
Subject: [PATCH 51/53] prepared for sun service

---
 timemanager/pom.xml | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/timemanager/pom.xml b/timemanager/pom.xml
index a12fa5937..dd1d72e0a 100644
--- a/timemanager/pom.xml
+++ b/timemanager/pom.xml
@@ -17,6 +17,11 @@
 	      	<artifactId>arrowhead-core-common</artifactId>
 	      	<version>${revision}</version>
 	    </dependency>
+		<dependency>
+			<groupId>org.shredzone.commons</groupId>
+			<artifactId>commons-suncalc</artifactId>
+			<version>3.5</version>
+		</dependency>
   	</dependencies>
   	
   	<build>

From 7bbdd297528e98d35741eb971c114002e99dd98d Mon Sep 17 00:00:00 2001
From: Jens Eliasson <jens.eliasson@gmail.com>
Date: Tue, 3 Aug 2021 09:57:42 +0200
Subject: [PATCH 52/53] fixed bad indentation

---
 .../java/eu/arrowhead/common/CoreCommonConstants.java     | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/core-common/src/main/java/eu/arrowhead/common/CoreCommonConstants.java b/core-common/src/main/java/eu/arrowhead/common/CoreCommonConstants.java
index 88cf3ef66..50068bd2a 100644
--- a/core-common/src/main/java/eu/arrowhead/common/CoreCommonConstants.java
+++ b/core-common/src/main/java/eu/arrowhead/common/CoreCommonConstants.java
@@ -73,7 +73,7 @@ public class CoreCommonConstants {
 	public static final String SWAGGER_HTTP_401_MESSAGE = "You are not authorized";
 	public static final String SWAGGER_HTTP_404_MESSAGE = "Not found";
 	public static final String SWAGGER_HTTP_409_MESSAGE = "Request caused a conflict";
-    public static final String SWAGGER_HTTP_415_MESSAGE = "MediaType not supported";
+	public static final String SWAGGER_HTTP_415_MESSAGE = "MediaType not supported";
 	public static final String SWAGGER_HTTP_500_MESSAGE = "Core service is not available";
 	
 	public static final String SWAGGER_TAG_MGMT = "Management";
@@ -130,8 +130,8 @@ public class CoreCommonConstants {
 	public static final String $SYSTEM_REGISTRY_PING_TIMEOUT_WD =
 			"${" + SYSTEM_REGISTRY_PING_TIMEOUT + ":" + CoreDefaults.DEFAULT_SYSTEM_REGISTRY_PING_TIMEOUT_MILLISECONDS + "}";
 
-    public static final String AUTHORIZATION_IS_EVENTHANDLER_PRESENT = "eventhandler_is_present";
-    public static final String $AUTHORIZATION_IS_EVENTHANDLER_PRESENT_WD = "${" + AUTHORIZATION_IS_EVENTHANDLER_PRESENT + ":" + CoreDefaults.DEFAULT_AUTHORIZATION_IS_EVENTHANDLER_PRESENT + "}";
+	public static final String AUTHORIZATION_IS_EVENTHANDLER_PRESENT = "eventhandler_is_present";
+	public static final String $AUTHORIZATION_IS_EVENTHANDLER_PRESENT_WD = "${" + AUTHORIZATION_IS_EVENTHANDLER_PRESENT + ":" + CoreDefaults.DEFAULT_AUTHORIZATION_IS_EVENTHANDLER_PRESENT + "}";
 	
 	public static final String ORCHESTRATOR_IS_GATEKEEPER_PRESENT = "gatekeeper_is_present";
 	public static final String $ORCHESTRATOR_IS_GATEKEEPER_PRESENT_WD = "${" + ORCHESTRATOR_IS_GATEKEEPER_PRESENT + ":" + CoreDefaults.DEFAULT_ORCHESTRATOR_IS_GATEKEEPER_PRESENT + "}";
@@ -233,7 +233,7 @@ public class CoreCommonConstants {
 	public static final String RELAY_TEST_LOG_MEASUREMENTS_IN_DB = "relay.test.log_measurements_in_db";
 	public static final String $RELAY_TEST_LOG_MEASUREMENTS_IN_DB_WD = "${" + RELAY_TEST_LOG_MEASUREMENTS_IN_DB + ":" + CoreDefaults.DEFAULT_RELAY_TEST_LOG_MEASUREMENTS_IN_DB + "}";
 	
-    public static final String CERTIFICATE_FORMAT = "X.509";
+	public static final String CERTIFICATE_FORMAT = "X.509";
 
 	// Translator-Fiware
 	public static final String FIWARE_SERVER_HOST = "fiware.server.host";

From 0932db830ab526197d20bcf8f723231f2cf35a53 Mon Sep 17 00:00:00 2001
From: Jens Eliasson <jens.eliasson@gmail.com>
Date: Tue, 3 Aug 2021 11:46:36 +0200
Subject: [PATCH 53/53] renamed file after feedback

---
 ...imemanagerSwaggerConfig.java => TimeManagerSwaggerConfig.java} | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 rename timemanager/src/main/java/eu/arrowhead/core/timemanager/swagger/{TimemanagerSwaggerConfig.java => TimeManagerSwaggerConfig.java} (100%)

diff --git a/timemanager/src/main/java/eu/arrowhead/core/timemanager/swagger/TimemanagerSwaggerConfig.java b/timemanager/src/main/java/eu/arrowhead/core/timemanager/swagger/TimeManagerSwaggerConfig.java
similarity index 100%
rename from timemanager/src/main/java/eu/arrowhead/core/timemanager/swagger/TimemanagerSwaggerConfig.java
rename to timemanager/src/main/java/eu/arrowhead/core/timemanager/swagger/TimeManagerSwaggerConfig.java
