Added columns to the oauth2_client table and updated client registration

Change-Id: Ic16b41859fdda464fc2315ae40b1ddded9c45dca
diff --git a/full/src/main/resources/db/sqlite/V1.11__plugin.sql b/full/src/main/resources/db/sqlite/V1.11__plugin.sql
new file mode 100644
index 0000000..94b90ca
--- /dev/null
+++ b/full/src/main/resources/db/sqlite/V1.11__plugin.sql
@@ -0,0 +1,22 @@
+ALTER TABLE oauth2_client 
+	ADD COLUMN registration_date TIMESTAMP NOT NULL;
+
+-- default 365 days in seconds
+ALTER TABLE oauth2_client 
+	ADD COLUMN refresh_token_expiry INTEGER DEFAULT 31536000;
+	
+ALTER TABLE oauth2_client 
+	ADD COLUMN source BLOB DEFAULT NULL;
+
+ALTER TABLE oauth2_client 
+	ADD COLUMN is_permitted BOOLEAN DEFAULT FALSE;
+
+--CREATE TABLE IF NOT EXISTS user_installed_client (
+--	id INTEGER PRIMARY KEY AUTOINCREMENT,
+--	installed_by VARCHAR(100) NOT NULL,
+--	installed_date TIMESTAMP NOT NULL,
+--	client_id VARCHAR(100) NOT NULL,
+--	FOREIGN KEY (client_id)
+--	   REFERENCES oauth2_client(id)
+--	   ON DELETE CASCADE
+--);
\ No newline at end of file
diff --git a/full/src/main/resources/db/sqlite/V1.9__query_alteration.sql b/full/src/main/resources/db/sqlite/V1.9__query_alteration.sql
index 0d3bf8c..02cf486 100644
--- a/full/src/main/resources/db/sqlite/V1.9__query_alteration.sql
+++ b/full/src/main/resources/db/sqlite/V1.9__query_alteration.sql
@@ -23,7 +23,6 @@
 	ON query(name,created_by);
 
 
-
 ALTER TABLE virtual_corpus_access 
 RENAME COLUMN virtual_corpus_id TO query_id;
 
@@ -31,8 +30,6 @@
 RENAME TO query_access;
 
 
-
-
 DROP TABLE IF EXISTS query_reference;
 
 DROP INDEX IF EXISTS query_reference_owner_index;
diff --git a/full/src/main/resources/db/test/V3.5__insert_oauth2_clients.sql b/full/src/main/resources/db/test/V3.5__insert_oauth2_clients.sql
index 858d238..043426d 100644
--- a/full/src/main/resources/db/test/V3.5__insert_oauth2_clients.sql
+++ b/full/src/main/resources/db/test/V3.5__insert_oauth2_clients.sql
@@ -2,50 +2,55 @@
 
 -- plain secret value is "secret"
 INSERT INTO oauth2_client(id,name,secret,type,super,
-  redirect_uri,registered_by, description, url) 
+  redirect_uri,registered_by, description, url, registration_date, 
+  is_permitted) 
 VALUES ("fCBbQkAyYzI4NzUxMg","super confidential client",
   "$2a$08$vi1FbuN3p6GcI1tSxMAoeuIYL8Yw3j6A8wJthaN8ZboVnrQaTwLPq",
   "CONFIDENTIAL", 1, 
   "https://korap.ids-mannheim.de/confidential/redirect", "system",
   "This is a test super confidential client.", 
-  "http://korap.ids-mannheim.de/confidential");
+  "http://korap.ids-mannheim.de/confidential", CURRENT_TIMESTAMP, 1);
 
   
 -- plain secret value is "secret"
 INSERT INTO oauth2_client(id,name,secret,type,super,
-  redirect_uri,registered_by, description,url) 
+  redirect_uri,registered_by, description,url,registration_date, 
+  is_permitted) 
 VALUES ("9aHsGW6QflV13ixNpez","non super confidential client",
   "$2a$08$vi1FbuN3p6GcI1tSxMAoeuIYL8Yw3j6A8wJthaN8ZboVnrQaTwLPq",
   "CONFIDENTIAL", 0,
   "https://third.party.com/confidential/redirect", "system",
   "This is a test nonsuper confidential client.",
-  "http://third.party.com/confidential");
+  "http://third.party.com/confidential", CURRENT_TIMESTAMP,1);
 
 INSERT INTO oauth2_client(id,name,secret,type,super,
-  redirect_uri,registered_by, description,url) 
+  redirect_uri,registered_by, description,url, registration_date, 
+  is_permitted) 
 VALUES ("52atrL0ajex_3_5imd9Mgw","confidential client 2",
   "$2a$08$vi1FbuN3p6GcI1tSxMAoeuIYL8Yw3j6A8wJthaN8ZboVnrQaTwLPq",
   "CONFIDENTIAL", 0,
   "https://example.client.de/redirect", "system",
   "This is a test nonsuper confidential client.",
-  "http://example.client.de");
+  "http://example.client.de", CURRENT_TIMESTAMP, 1);
 
 INSERT INTO oauth2_client(id,name,secret,type,super,
-  redirect_uri, registered_by, description, url) 
+  redirect_uri, registered_by, description, url, registration_date, 
+  is_permitted)
 VALUES ("8bIDtZnH6NvRkW2Fq","third party client",null,
   "PUBLIC", 0,
   "https://third.party.client.com/redirect","system",
   "This is a test public client.",
-  "http://third.party.client.com");
+  "http://third.party.client.com", CURRENT_TIMESTAMP,1);
 
   
 INSERT INTO oauth2_client(id,name,secret,type,super,
-  redirect_uri, registered_by, description,url) 
+  redirect_uri, registered_by, description, url, registration_date, 
+  is_permitted) 
 VALUES ("nW5qM63Rb2a7KdT9L","test public client",null,
   "PUBLIC", 0, 
   "https://korap.ids-mannheim.de/public/redirect","system", 
   "This is a test public client.",
-  "http://korap.ids-mannheim.de/public");
+  "http://korap.ids-mannheim.de/public", CURRENT_TIMESTAMP, 1);
   
 
 INSERT INTO oauth2_access_token(token,user_id,created_date, 
diff --git a/full/src/main/resources/kustvakt.conf b/full/src/main/resources/kustvakt.conf
index daf0e9a..5d822ae 100644
--- a/full/src/main/resources/kustvakt.conf
+++ b/full/src/main/resources/kustvakt.conf
@@ -5,10 +5,10 @@
 krill.index.commit.log = log/krill.commit.log
 krill.index.commit.auto = 500
 krill.index.relations.max = 100
-## Directory path of virtual corpora to cache
+# Directory path of virtual corpora to cache
 #krill.namedVC = vc
 
-## LDAP
+# LDAP
 ldap.config = file-path-to-ldap-config
 
 # Kustvakt
@@ -17,20 +17,20 @@
 # multiple versions separated by space
 # supported.api.version = v1.0
 
-## server
+# server
 server.port=8089
 server.host=localhost
 
-## mail settings
+# mail settings
 mail.enabled = false
 mail.receiver = test@localhost
 mail.sender = noreply@ids-mannheim.de
 mail.address.retrieval = test
 
-## mail.templates
+# mail.templates
 template.group.invitation = notification.vm
 
-## default foundries for specific layers
+# default foundries for specific layers
 default.foundry.partOfSpeech = tt
 default.foundry.lemma = tt
 default.foundry.orthography = opennlp
@@ -39,32 +39,33 @@
 default.foundry.morphology = marmot
 default.foundry.surface = base
 
-## delete configuration (default hard)
+# delete configuration (default hard)
 # delete.auto.group = hard
 delete.group = soft
 delete.group.member = soft
 
-## availability regex
-## only support |
+# availability regex (only support | )
 availability.regex.free = CC-BY.*
 availability.regex.public = ACA.*|QAO.NC
 availability.regex.all = QAO.*
 
-## options referring to the security module!
+# options referring to the security module!
 
-## OAuth 
-### (see de.ids_mannheim.korap.constant.AuthenticationMethod for possible 
-### oauth.password.authentication values)
+# OAuth 
+# (see de.ids_mannheim.korap.constant.AuthenticationMethod for possible 
+# oauth.password.authentication values)
 oauth.password.authentication = TEST
-### used to determine native client, currently not used
-oauth2.native.client.host = korap.ids-mannheim.de
+# used to determine native client, currently not used
+# oauth2.native.client.host = korap.ids-mannheim.de
 oauth2.max.attempts = 1
 # expiry in seconds (S), minutes (M), hours (H), days (D)
 oauth2.access.token.expiry = 1D
-oauth2.access.token.long.expiry = 365D
 oauth2.refresh.token.expiry = 90D
+# default 365D
+# oauth2.access.token.long.expiry = 365D
+# oauth2.refresh.token.long.expiry = 365D
 oauth2.authorization.code.expiry = 10M
-# -- scopes separated by space
+# scopes separated by space
 oauth2.default.scopes = search match_info 
 oauth2.client.credentials.scopes = client_info