Implemented loading VC from gz files & updated OAuth2 expiry check.

Change-Id: I01c607b86b992526400a3df9c5a66fa6211f4ac8
diff --git a/full/src/main/resources/db/insert/V3.5__insert_oauth2_clients.sql b/full/src/main/resources/db/insert/V3.5__insert_oauth2_clients.sql
index 68bbfa7..0d518a3 100644
--- a/full/src/main/resources/db/insert/V3.5__insert_oauth2_clients.sql
+++ b/full/src/main/resources/db/insert/V3.5__insert_oauth2_clients.sql
@@ -47,6 +47,7 @@
 --  "https://korap.ids-mannheim.de/public/redirect","system", 
 --  "This is a test super public client."); 
 
-INSERT INTO oauth2_access_token(token,user_id,created_date, user_auth_time)
-VALUES("fia0123ikBWn931470H8s5gRqx7Moc4p","marlin","2018-05-30 16:25:50",
-"2018-05-30 16:23:10");
\ No newline at end of file
+INSERT INTO oauth2_access_token(token,user_id,created_date, 
+expiry_date, refresh_expiry_date, user_auth_time)
+VALUES("fia0123ikBWn931470H8s5gRqx7Moc4p","marlin","2018-05-30 16:25:50", 
+"2018-05-31 16:25:50", "2018-08-30 16:25:50", "2018-05-30 16:23:10");
diff --git a/full/src/main/resources/db/new-mysql/V1.4__oauth2_tables.sql b/full/src/main/resources/db/new-mysql/V1.4__oauth2_tables.sql
index 4c35fca..10e069d 100644
--- a/full/src/main/resources/db/new-mysql/V1.4__oauth2_tables.sql
+++ b/full/src/main/resources/db/new-mysql/V1.4__oauth2_tables.sql
@@ -11,7 +11,7 @@
 	name VARCHAR(200) NOT NULL,
 	secret VARCHAR(200) DEFAULT NULL,
 	type VARCHAR(200) NOT NULL,
-	native BOOLEAN DEFAULT FALSE,
+	super BOOLEAN DEFAULT FALSE,
 	redirect_uri TEXT DEFAULT NULL,
 	description VARCHAR(250) NOT NULL,
 	registered_by VARCHAR(100) NOT NULL,
@@ -27,6 +27,7 @@
 	user_id VARCHAR(100) NOT NULL,
 	redirect_uri TEXT DEFAULT NULL,
 	created_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
+	expiry_date TIMESTAMP NULL,
 	is_revoked BOOLEAN DEFAULT 0,
 	total_attempts INTEGER DEFAULT 0,
 	user_auth_time TIMESTAMP NULL,
@@ -57,9 +58,11 @@
 	user_id VARCHAR(100) DEFAULT NULL,
 	client_id VARCHAR(100) DEFAULT NULL,
 	created_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
+	expiry_date TIMESTAMP NULL,
 	is_revoked BOOLEAN DEFAULT 0,
 	user_auth_time TIMESTAMP NULL,
     refresh_token VARCHAR(255) DEFAULT NULL,
+    refresh_expiry_date TIMESTAMP NULL,
 	is_refresh_revoked BOOLEAN DEFAULT 0,
 	FOREIGN KEY (client_id)
 	   REFERENCES oauth2_client(id)
diff --git a/full/src/main/resources/db/new-sqlite/V1.4__oauth2_tables.sql b/full/src/main/resources/db/new-sqlite/V1.4__oauth2_tables.sql
index 47f0a0f..45fa1f4 100644
--- a/full/src/main/resources/db/new-sqlite/V1.4__oauth2_tables.sql
+++ b/full/src/main/resources/db/new-sqlite/V1.4__oauth2_tables.sql
@@ -28,7 +28,8 @@
 	client_id VARCHAR(100) NOT NULL,
 	user_id VARCHAR(100) NOT NULL,
 	redirect_uri TEXT DEFAULT NULL,
-	created_date TIMESTAMP DEFAULT (datetime('now','localtime')),
+	created_date TIMESTAMP NOT NULL,
+	expiry_date TIMESTAMP NOT NULL,
 	is_revoked BOOLEAN DEFAULT 0,
 	total_attempts INTEGER DEFAULT 0,
 	user_auth_time TIMESTAMP NOT NULL,
@@ -61,10 +62,12 @@
 	token VARCHAR(255) NOT NULL,
 	user_id VARCHAR(100) DEFAULT NULL,
 	client_id VARCHAR(100) DEFAULT NULL,
-	created_date TIMESTAMP DEFAULT (datetime('now','localtime')),
+	created_date TIMESTAMP NOT NULL,
+	expiry_date TIMESTAMP NOT NULL,
 	is_revoked BOOLEAN DEFAULT 0,
 	user_auth_time TIMESTAMP NOT NULL,
 	refresh_token VARCHAR(255) DEFAULT NULL,
+	refresh_expiry_date TIMESTAMP NOT NULL,
 	is_refresh_revoked BOOLEAN DEFAULT 0,
 	FOREIGN KEY (client_id)
 	   REFERENCES oauth2_client(id)
diff --git a/full/src/main/resources/db/new-sqlite/V1.5__oauth2_triggers.sql b/full/src/main/resources/db/new-sqlite/V1.5__oauth2_triggers.sql
index d62e4df..96329af 100644
--- a/full/src/main/resources/db/new-sqlite/V1.5__oauth2_triggers.sql
+++ b/full/src/main/resources/db/new-sqlite/V1.5__oauth2_triggers.sql
@@ -1,14 +1,15 @@
-CREATE TRIGGER insert_authorization_date AFTER INSERT ON oauth2_authorization
-     BEGIN
-      UPDATE oauth2_authorization
-      SET created_date = DATETIME('now', 'localtime')  
-      WHERE rowid = new.rowid;
-     END;
-
-CREATE TRIGGER insert_access_token_date AFTER INSERT ON oauth2_access_token
-     BEGIN
-      UPDATE oauth2_access_token
-      SET created_date = DATETIME('now', 'localtime')  
-      WHERE rowid = new.rowid;
-     END;
+--CREATE TRIGGER insert_authorization_date AFTER INSERT ON oauth2_authorization
+--     BEGIN
+--      UPDATE oauth2_authorization
+--      SET created_date = DATETIME('now', 'localtime')  
+--      WHERE rowid = new.rowid;
+--     END;
+--     
+--
+--CREATE TRIGGER insert_access_token_date AFTER INSERT ON oauth2_access_token
+--     BEGIN
+--      UPDATE oauth2_access_token
+--      SET created_date = DATETIME('now', 'localtime')  
+--      WHERE rowid = new.rowid;
+--     END;
      
\ No newline at end of file
diff --git a/full/src/main/resources/default-config.xml b/full/src/main/resources/default-config.xml
index 32ebb35..f9ce666 100644
--- a/full/src/main/resources/default-config.xml
+++ b/full/src/main/resources/default-config.xml
@@ -139,6 +139,7 @@
 				</prop>
 				<prop key="hibernate.cache.provider_class">${hibernate.cache.provider}</prop>
 				<prop key="hibernate.cache.region.factory_class">${hibernate.cache.region.factory}</prop>
+				<prop key="hibernate.jdbc.time_zone">${hibernate.jdbc.time_zone}</prop>
 				<!-- <prop key="net.sf.ehcache.configurationResourceName">classpath:ehcache.xml</prop> -->
 			</props>
 		</property>
diff --git a/full/src/main/resources/properties/hibernate.properties b/full/src/main/resources/properties/hibernate.properties
index 161b737..199dc73 100644
--- a/full/src/main/resources/properties/hibernate.properties
+++ b/full/src/main/resources/properties/hibernate.properties
@@ -4,4 +4,5 @@
 hibernate.cache.use_query_cache=false
 hibernate.cache.use_second_level_cache=false
 hibernate.cache.provider=org.hibernate.cache.EhCacheProvider
-hibernate.cache.region.factory=org.hibernate.cache.ehcache.EhCacheRegionFactory
\ No newline at end of file
+hibernate.cache.region.factory=org.hibernate.cache.ehcache.EhCacheRegionFactory
+hibernate.jdbc.time_zone=UTC
\ No newline at end of file
diff --git a/full/src/main/resources/properties/jdbc.properties b/full/src/main/resources/properties/jdbc.properties
index 1afe44b..1f5e8ab 100644
--- a/full/src/main/resources/properties/jdbc.properties
+++ b/full/src/main/resources/properties/jdbc.properties
@@ -4,7 +4,7 @@
 
 #jdbc.database=mysql
 #jdbc.driverClassName=com.mysql.jdbc.Driver
-#jdbc.url=jdbc:mysql://localhost:3306/kustvakt?autoReconnect=true&useLegacyDatetimeCode=false
+#jdbc.url=jdbc:mysql://localhost:3306/kustvakt?autoReconnect=true&useSSL=false&useLegacyDatetimeCode=false&serverTimezone=UTC
 #jdbc.username=korap
 #jdbc.password=password