Merge branch 'DEVELOP' of ssh://git.eclipse.org:29418/openk-usermodules/org.eclipse.openk-usermodules.contactBaseData.backend into KON_110-SpringSecurity
diff --git a/pom.xml b/pom.xml
index d03b684..dcabe5e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -56,6 +56,9 @@
 		<postgresql.version>42.2.8</postgresql.version>
 		<lombock.version>1.18.10</lombock.version>
 		<h2.version>1.4.200</h2.version>
+		<jsonwebtoken.version>0.9.1</jsonwebtoken.version>
+		<openfeign.version>2.2.0.RELEASE</openfeign.version>
+		<keycloak-core.version>3.4.2.Final</keycloak-core.version>
 	</properties>
 
 	<dependencies>
@@ -83,8 +86,13 @@
 		<dependency>
 			<groupId>org.springframework.cloud</groupId>
 			<artifactId>spring-cloud-starter-openfeign</artifactId>
+			<version>${openfeign.version}</version>
 		</dependency>
-
+		<dependency>
+			<groupId>org.keycloak</groupId>
+			<artifactId>keycloak-core</artifactId>
+			<version>${keycloak-core.version}</version>
+		</dependency>
 		<dependency>
 			<groupId>org.postgresql</groupId>
 			<artifactId>postgresql</artifactId>
@@ -104,6 +112,11 @@
 			<scope>provided</scope>
 		</dependency>
 		<dependency>
+			<groupId>io.jsonwebtoken</groupId>
+			<artifactId>jjwt</artifactId>
+			<version>${jsonwebtoken.version}</version>
+		</dependency>
+		<dependency>
 			<groupId>io.springfox</groupId>
 			<artifactId>springfox-swagger2</artifactId>
 			<version>${springfox.version}</version>
diff --git a/src/main/asciidoc/architectureDocumentation/architectureDocumentation.adoc b/src/main/asciidoc/architectureDocumentation/architectureDocumentation.adoc
index 8d01f75..12b1231 100644
--- a/src/main/asciidoc/architectureDocumentation/architectureDocumentation.adoc
+++ b/src/main/asciidoc/architectureDocumentation/architectureDocumentation.adoc
@@ -17,7 +17,7 @@
 ===============================================================
 :Author: Frank Dietrich
 :Email: frank.dietrich@pta.de
-:Date: 2018-03-19
+:Date: 2019-12-17
 :Revision: 1
 :icons:
 :source-highlighter: highlightjs
@@ -29,11 +29,21 @@
 
 === Requirements Overview
 
-The module 'Contact Base Data' supports the different openKonsesequence domain- and user-modules ...
+Many user modules of an openKONSEQUENZ installion need contact datas for their
+daily business. Furthermore they have to fulfil the regulatory requirement
+of the General Data Protection Regulation (GDPR).
+
+This core module 'Contact Base Data' provides a central component for managing contact
+datas including the crucial functionality of GDPR.
+
+The full requirements of the module 'Contact Base Data' (in German: Modul 'Kontaktstammdaten') is described in the document
+
+* "Anforderungsspezifikation Modul Kontaktstammdaten" version 1.2 / 07-11-2019.
+
 
 
 === Quality Goals
-The module 'Contact Base Data' represents a user module that is based on the architecture platform of openKONSEQUENZ. The main quality
+The module 'Contact Base Data' represents a core module that is based on the architecture platform of openKONSEQUENZ. The main quality
 goals of the platform are:
 
 * *Flexibility* The reference platform shall grant that different systems and modules from different vendors/developers can interact and interoperate, and may be exchanged or recombined.
@@ -42,19 +52,19 @@
 * *Integration performance* New implemented functionality of oK own modules and external modules shall be included fast / automatically.
 * *Security* The platform and its modules need to underly security-by-design
 
-The main quality goals of the user module Contact Base Data are:
+The main quality goals of the core module Contact Base Data are:
 
-* *Functionality* The user module must fulfil the functional requirements mentioned in the section before
+* *Functionality* The core module must fulfil the functional requirements mentioned in the section before
 * *Ergonomics* The web interface must be realized according to oK-GUI-Styleguide.
 * *Good documentation* (i.e. code and architecture documentation) makes code changes easier and automatic
 tests facilitate rigorous verification.
 * *Modifiability* (and testability as part of modifiability)
-* *Integration performance* The user module must be easy integratable in different production environments.
+* *Integration performance* The core module must be easy integratable in different production environments.
 
 The following documents contain the quality goals in detail:
 
-* Architecture Committee Handbook v1.3.1 from 05-09-2017
-* Quality Committee Handbook v1.1.1 from 11-09-2017
+* Architecture Committee Handbook v1.6.0 from 10-07-2019
+* Quality Committee Handbook v2.0.1 from 15-10-2018
 
 The architecture is based on the AC-Handbook. The quality demands are described in the QC-Handbook.
 Both specifications were fully complied with in the project, so that a high quality is given.
@@ -63,7 +73,7 @@
 are ensured by the use of sonarqube. The rule set and the qualtity gate are defined by the default, the
 so called "sonar way".
 
-The module 'Contact Base Data' is part of the Eclipse project 'Eclipse openK User Modules'.
+The module 'Contact Base Data' is part of the Eclipse project 'Eclipse openK Core Modules'.
 This project bases on the Eclipse Public Licence 2.0.
 
 === Stakeholders
@@ -72,7 +82,7 @@
 [options="header,footer"]
 |=========================================================
 |Role/Name|Contact|Expectations
-|Product Owner (represents the Distribution System Operators)|Rainer Fuhrmann, Gordon Pickfort|The software must fulfil their functional and nonfunctional requirements.
+|Product Owner (represents the Distribution System Operators)|Gordon Pickfort, Rainer Fuhrmann|The software must fulfil their functional and nonfunctional requirements.
 |Module Developer|Michel Alessandrini, Jonas Tewolde, Frank Dietrich|All relevant business and technical information must be available for implementing the software.
 |External Reviewer (represents the AC/QC)|n.n.|The software and the documentation is realized according to the Quality and Architecture Handbook of openKONSEQUENZ.
 |External Reviewer (represents the Eclipse-Requirements)|n.n.|The software is  licensed under the EPL 2.0. It must be validated that all requirements are fulfilled.
@@ -84,12 +94,14 @@
 The main architecture constraints are:
 
 * *Public License* The module must be available under the “Eclipse Public License 2.0”.
+* *Standardization* The module must use the reference platform.
 * *Availability* The source code of the module must be accessible to any interested person/company.
 
 Therefore the project is published under the following repositories:
-•https://git.eclipse.org/r/openk-usermodules/org.eclipse.openk-usermodules.mics.centralService
 
-* *Standardization* The module must use standardized data structures (CIM) [if available] and the reference platform.
+* https://git.eclipse.org/r/openk-usermodules/org.eclipse.openk-usermodules.contactBaseData.backend
+* https://git.eclipse.org/r/openk-usermodules/org.eclipse.openk-usermodules.contactBaseData.frontend
+
 
 === Technical Constraints
 
@@ -177,18 +189,11 @@
 
 === Business Context
 
-The user module 'Contact Base Data' communicates via Restful Webservices with the follwowing modules
-(see also figure 1):
+The core module 'Contact Base Data' communicates via Restful Webservices with the follwowing modules:
 
 * *Core Module 'Auth & Auth'* The 'Contact Base Data' can only be used by authorized users.
-   Therefore, it is essential to invoke the module 'Auth & Auth' for authorization and authentication
-   purposes.
-
-
-
-
-
-
+Therefore, it is essential to invoke the module 'Auth & Auth' for authorization and authentication
+purposes.
 
 
 === Technical Context
@@ -198,7 +203,6 @@
 * RESTful web services are used as interface-technology.
 * Each external interface (interfaces between modules or external systems) has to be documented.
 * Dependencies of modules to services realized by other modules have to be specified and documented explicitly.
-* When CIM is not appropriate (like access management), other standards in their respective domain shall be taken into account first to avoid proprietary and inaccurate interfaces. The interface has to be documented in the overall openKONSEQUENZ interface profile and it should use REST & XML.
 
 The interfaces of the module 'Contact Base Data' are described in the interface documentation.
 
@@ -246,7 +250,7 @@
 
 This component implements the presentation logic for the *contact-base-data*-module using the *Angular*-TypeScript
 framework. The Frontend is a so called *Single Page Application* (SPA) because
-it behaves like a single HTML-page. 
+it behaves like a single HTML-page.
 
 
 ==== contact-base-data.jar (backend tier)
@@ -314,13 +318,13 @@
 The backend tier contains five components which can be summarized in three layers:
 
 . *Presentation layer* - Represented by
- .. REST-Srv
- .. View model
+.. REST-Srv
+.. View model
 . *Controller layer* - Represented by
- ..	Controller
+..	Controller
 .	*Model layer* - Represented by
- ..	DAO
- ..	Model
+..	DAO
+..	Model
 
 
 
@@ -453,8 +457,8 @@
 
 The continuous deployment is realized on two platforms:
 
- * the development platform (Dev-Environment)
- * the quality platform (Q-Environment)
+* the development platform (Dev-Environment)
+* the quality platform (Q-Environment)
 
 The automatic deployment on both of the environments is
 directly linked to the branches on the GIT-repositories:
@@ -495,7 +499,6 @@
 |DSO|Distribution System Operator|Verteilnetz-betreiber (VNB)|Manages the distribution network for energy, gas or water.
 |EPL|Eclipse Public License||Underlying license model for Eclipse projects like contact-base-data@openK
 |ESB|Enterprise Service Bus||Central instance to exchange data to overcome point-to-point connections.
-|GNM|Geplante Netzmaßnahme||German name of the module 'Contact Base Data'
 |oK|openKONSEQUENZ|openKONSEQUENZ|Name of the consortium of DSOs
 |QC|Quality Committee|Qualitätskomitee|Gives framework and constraints according to quality for oK projects.
 |SCADA|Supervisory Control and Data Acquisition|Netzleitsystem|System, that allows DSOs view/control actual parameters of their power grid.
diff --git a/src/main/java/org/eclipse/openk/contactbasedata/config/SecurityConfig.java b/src/main/java/org/eclipse/openk/contactbasedata/config/SecurityConfig.java
index 17efe79..ad85744 100644
--- a/src/main/java/org/eclipse/openk/contactbasedata/config/SecurityConfig.java
+++ b/src/main/java/org/eclipse/openk/contactbasedata/config/SecurityConfig.java
@@ -11,19 +11,53 @@
  *
  * SPDX-License-Identifier: EPL-2.0
  *******************************************************************************
-*/
+ */
 package org.eclipse.openk.contactbasedata.config;
 
+import org.eclipse.openk.contactbasedata.config.auth.JwtAuthenticationEntryPoint;
+import org.eclipse.openk.contactbasedata.config.auth.JwtAuthenticationTokenFilter;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
 import org.springframework.security.config.annotation.web.builders.HttpSecurity;
+import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
 import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
+import org.springframework.security.config.http.SessionCreationPolicy;
+import org.springframework.security.web.authentication.www.BasicAuthenticationFilter;
 
 @Configuration
+@EnableWebSecurity
+@EnableGlobalMethodSecurity(
+        prePostEnabled = true,
+        securedEnabled = true,
+        jsr250Enabled = true)
 public class SecurityConfig extends WebSecurityConfigurerAdapter {
+
+    @Autowired
+    private JwtAuthenticationTokenFilter jwtAuthenticationTokenFilter;
+
+    @Autowired
+    private JwtAuthenticationEntryPoint jwtAuthenticationEntryPoint;
+
     @Override
-    protected void configure(HttpSecurity security ) throws Exception {
-        security.httpBasic().disable();
-        security.csrf().disable();
+    protected void configure(HttpSecurity http ) throws Exception {
+        http
+                .authorizeRequests()
+                .antMatchers("/**").permitAll()
+                .anyRequest().authenticated()
+                .and()
+                .cors()
+                .and()
+                .exceptionHandling().authenticationEntryPoint(jwtAuthenticationEntryPoint)
+                .and()
+                .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)
+                .and()
+                .csrf().disable()
+                .logout().disable()
+                .formLogin().disable()
+                .anonymous()
+                .and()
+                .addFilterAfter(jwtAuthenticationTokenFilter, BasicAuthenticationFilter.class);
     }
 
 }
diff --git a/src/main/java/org/eclipse/openk/contactbasedata/config/auth/JwtAuthenticationEntryPoint.java b/src/main/java/org/eclipse/openk/contactbasedata/config/auth/JwtAuthenticationEntryPoint.java
new file mode 100644
index 0000000..85a5eda
--- /dev/null
+++ b/src/main/java/org/eclipse/openk/contactbasedata/config/auth/JwtAuthenticationEntryPoint.java
@@ -0,0 +1,34 @@
+/*
+ *******************************************************************************
+ * Copyright (c) 2019 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *******************************************************************************
+*/
+package org.eclipse.openk.contactbasedata.config.auth;
+
+import org.springframework.security.core.AuthenticationException;
+import org.springframework.security.web.AuthenticationEntryPoint;
+import org.springframework.stereotype.Component;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.Serializable;
+
+@Component
+public class JwtAuthenticationEntryPoint implements AuthenticationEntryPoint, Serializable {
+
+    @Override
+    public void commence(HttpServletRequest request, HttpServletResponse response,
+                         AuthenticationException authException) throws IOException {
+        response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Unauthorized");
+    }
+}
diff --git a/src/main/java/org/eclipse/openk/contactbasedata/config/auth/JwtAuthenticationTokenFilter.java b/src/main/java/org/eclipse/openk/contactbasedata/config/auth/JwtAuthenticationTokenFilter.java
new file mode 100644
index 0000000..766d6d8
--- /dev/null
+++ b/src/main/java/org/eclipse/openk/contactbasedata/config/auth/JwtAuthenticationTokenFilter.java
@@ -0,0 +1,88 @@
+/*
+ *******************************************************************************
+ * Copyright (c) 2019 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *******************************************************************************
+*/
+
+package org.eclipse.openk.contactbasedata.config.auth;
+
+import org.keycloak.RSATokenVerifier;
+import org.keycloak.representations.AccessToken;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
+import org.springframework.security.core.AuthenticationException;
+import org.springframework.security.core.GrantedAuthority;
+import org.springframework.security.core.authority.SimpleGrantedAuthority;
+import org.springframework.security.core.context.SecurityContext;
+import org.springframework.security.core.context.SecurityContextHolder;
+import org.springframework.stereotype.Component;
+import org.springframework.web.filter.OncePerRequestFilter;
+
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+@Component
+public class JwtAuthenticationTokenFilter extends OncePerRequestFilter {
+
+    @Value("${jwt.useStaticJwt}")
+    private boolean useStaticJwt;
+
+    @Value("${jwt.tokenHeader}")
+    private String tokenHeader;
+
+    @Value("${jwt.staticJwt}")
+    private String staticJwt;
+
+    @Override
+    protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws ServletException, IOException {
+        String authenticationHeader = useStaticJwt ? staticJwt : request.getHeader(this.tokenHeader);
+
+        try {
+            SecurityContext context= SecurityContextHolder.getContext();
+
+            if(authenticationHeader != null) {
+
+                final String bearerTkn= authenticationHeader.replace("Bearer ", "");
+
+                createToken(context, bearerTkn);
+
+            }
+            chain.doFilter(request, response);
+        } catch(AuthenticationException ex) {
+            throw new ServletException("Authentication exception.");
+        }
+
+    }
+
+    private void createToken(SecurityContext context, String bearerTkn) throws ServletException {
+        try {
+            AccessToken token = RSATokenVerifier.create(bearerTkn).getToken();
+
+            List<GrantedAuthority> authorities= new ArrayList<>();
+            token.getRealmAccess().getRoles().stream()
+                    .forEach( x -> authorities.add(new SimpleGrantedAuthority("ROLE_"+x.toUpperCase())));
+
+            UsernamePasswordAuthenticationToken auth = new UsernamePasswordAuthenticationToken(token.getName(), null,
+                    authorities);
+
+            context.setAuthentication(auth);
+
+        } catch (Exception e) {
+            throw new ServletException("Invalid token.");
+        }
+    }
+}
diff --git a/src/main/java/org/eclipse/openk/contactbasedata/controller/ContactController.java b/src/main/java/org/eclipse/openk/contactbasedata/controller/ContactController.java
index af4fc26..6d83796 100644
--- a/src/main/java/org/eclipse/openk/contactbasedata/controller/ContactController.java
+++ b/src/main/java/org/eclipse/openk/contactbasedata/controller/ContactController.java
@@ -11,6 +11,7 @@
 import org.springframework.data.domain.Pageable;
 import org.springframework.data.web.PageableDefault;
 import org.springframework.http.HttpStatus;
+import org.springframework.security.access.annotation.Secured;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.Optional;
@@ -28,6 +29,7 @@
     @ApiOperation(value = "Anzeigen aller gespeicherter Kontakte")
     @ApiResponses(value = {@ApiResponse(code = 200, message = "Erfolgreich durchgeführt")})
     @ResponseStatus(HttpStatus.OK)
+    @Secured("ROLE_KON-READER")
     @GetMapping
     public Page<VwDetailedContact> findContacts(
             @RequestParam( "contactType") Optional<String> contactType,
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
index 707ce94..0973cb6 100644
--- a/src/main/resources/application.yml
+++ b/src/main/resources/application.yml
@@ -21,10 +21,40 @@
 server:
   max-http-header-size: 262144
 
+jwt:
+  tokenHeader: accessToken
+  useStaticJwt: false
+  staticJwt: x
+
+---
+
+spring:
+  profiles: test
+
+  datasource:
+    url: jdbc:h2:mem:test;DB_CLOSE_DELAY=-1
+jpa:
+  hibernate:
+    ddl-auto: create
+  show-sql: true
+flyway:
+  enabled: false
+
+jwt:
+  tokenHeader: accessToken
+  useStaticJwt: true
+  staticJwt: eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJIYlI3Z2pobmE2eXJRZnZJTWhUSV9tY2g3ZmtTQWVFX3hLTjBhZVl0bjdjIn0.eyJqdGkiOiI1OWVmNTYxNi1hYjlkLTQwMDItODUxNC05Njg4NzMwNmRiMzciLCJleHAiOjE1NzY0ODY4NzYsIm5iZiI6MCwiaWF0IjoxNTc2NDg2NTc2LCJpc3MiOiJodHRwOi8vbG9jYWxob3N0OjgwODAvYXV0aC9yZWFsbXMvRWxvZ2Jvb2siLCJhdWQiOiJlbG9nYm9vay1iYWNrZW5kIiwic3ViIjoiYzFkMTA5NDAtNzRjYS00ZWZjLWFlNWUtY2Q5NmE5ZWE3MTI3IiwidHlwIjoiQmVhcmVyIiwiYXpwIjoiZWxvZ2Jvb2stYmFja2VuZCIsImF1dGhfdGltZSI6MCwic2Vzc2lvbl9zdGF0ZSI6IjQ2ZmVlNTE2LTA0ODktNGYzNC1iZDI4LWI1NjBiNzFmZDViMCIsImFjciI6IjEiLCJhbGxvd2VkLW9yaWdpbnMiOlsiKiJdLCJyZWFsbV9hY2Nlc3MiOnsicm9sZXMiOlsia29uLWFjY2VzcyIsImtvbi1yZWFkZXIiXX0sInJlc291cmNlX2FjY2VzcyI6e30sIm5hbWUiOiJGaW5pYSBSZWFkZXIiLCJwcmVmZXJyZWRfdXNlcm5hbWUiOiJmaW5pYV9yIiwiZ2l2ZW5fbmFtZSI6IkZpbmlhIiwiZmFtaWx5X25hbWUiOiJSZWFkZXIifQ.CHtZ_SdXxwzQeji41vVCh6e84pls2LfJC1Z6cMiU0ks0nBa9GXPy_TtqMAsmVEbjPJOkFaOY0rO28h7kldUALCiWEl2-7bzKlW4FvKYv_xrlhWJDWI9PTvYKZHMD7igp8ePs9t4ksvr3J8pRl75-_jWa-lPI6dW0B2vinwyZcH0RW6ImQUG23zcvtUpVIGUHbD0YiZKdBg--UU4760EzrGYAXQPgaU63Fw4aw8qbRsD4007mETbpr5avmUnQeWjhG0swukgmA4t9xTWElXD0JaheDxNPQsZMDkv-dX-A114UHjjoIC_S9EDDYc3P7yZkKwcp-CbUBkR7WIMu6zQD7g
+
+usercontext:
+  id: b6d19e04-3f08-4ef6-8637-9cd82e9736af
+  username: user-admin-m1
+  tenant: public
+  security:
+    enabled: false
 ---
 
 spring:
   profiles: devserver
 
 server:
-  port: 9155
\ No newline at end of file
+  port: 9155
diff --git a/src/main/resources/application_localdev.yml b/src/main/resources/application_localdev.yml
index 59dff56..a05e3e2 100644
--- a/src/main/resources/application_localdev.yml
+++ b/src/main/resources/application_localdev.yml
@@ -24,3 +24,8 @@
   servlet:
     session:
       tracking-modes: cookie
+
+jwt:
+  tokenHeader: accessToken
+  useStaticJwt: true
+  staticJwt: eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJIYlI3Z2pobmE2eXJRZnZJTWhUSV9tY2g3ZmtTQWVFX3hLTjBhZVl0bjdjIn0.eyJqdGkiOiI1OWVmNTYxNi1hYjlkLTQwMDItODUxNC05Njg4NzMwNmRiMzciLCJleHAiOjE1NzY0ODY4NzYsIm5iZiI6MCwiaWF0IjoxNTc2NDg2NTc2LCJpc3MiOiJodHRwOi8vbG9jYWxob3N0OjgwODAvYXV0aC9yZWFsbXMvRWxvZ2Jvb2siLCJhdWQiOiJlbG9nYm9vay1iYWNrZW5kIiwic3ViIjoiYzFkMTA5NDAtNzRjYS00ZWZjLWFlNWUtY2Q5NmE5ZWE3MTI3IiwidHlwIjoiQmVhcmVyIiwiYXpwIjoiZWxvZ2Jvb2stYmFja2VuZCIsImF1dGhfdGltZSI6MCwic2Vzc2lvbl9zdGF0ZSI6IjQ2ZmVlNTE2LTA0ODktNGYzNC1iZDI4LWI1NjBiNzFmZDViMCIsImFjciI6IjEiLCJhbGxvd2VkLW9yaWdpbnMiOlsiKiJdLCJyZWFsbV9hY2Nlc3MiOnsicm9sZXMiOlsia29uLWFjY2VzcyIsImtvbi1yZWFkZXIiXX0sInJlc291cmNlX2FjY2VzcyI6e30sIm5hbWUiOiJGaW5pYSBSZWFkZXIiLCJwcmVmZXJyZWRfdXNlcm5hbWUiOiJmaW5pYV9yIiwiZ2l2ZW5fbmFtZSI6IkZpbmlhIiwiZmFtaWx5X25hbWUiOiJSZWFkZXIifQ.CHtZ_SdXxwzQeji41vVCh6e84pls2LfJC1Z6cMiU0ks0nBa9GXPy_TtqMAsmVEbjPJOkFaOY0rO28h7kldUALCiWEl2-7bzKlW4FvKYv_xrlhWJDWI9PTvYKZHMD7igp8ePs9t4ksvr3J8pRl75-_jWa-lPI6dW0B2vinwyZcH0RW6ImQUG23zcvtUpVIGUHbD0YiZKdBg--UU4760EzrGYAXQPgaU63Fw4aw8qbRsD4007mETbpr5avmUnQeWjhG0swukgmA4t9xTWElXD0JaheDxNPQsZMDkv-dX-A114UHjjoIC_S9EDDYc3P7yZkKwcp-CbUBkR7WIMu6zQD7g
diff --git a/src/test/java/org/eclipse/openk/contactbasedata/config/TestConfiguration.java b/src/test/java/org/eclipse/openk/contactbasedata/config/TestConfiguration.java
index e7122ef..8323d28 100644
--- a/src/test/java/org/eclipse/openk/contactbasedata/config/TestConfiguration.java
+++ b/src/test/java/org/eclipse/openk/contactbasedata/config/TestConfiguration.java
@@ -18,11 +18,16 @@
 import org.eclipse.openk.contactbasedata.mapper.*;
 import org.eclipse.openk.contactbasedata.service.*;
 import org.springframework.boot.autoconfigure.domain.EntityScan;
+import org.springframework.boot.test.context.ConfigFileApplicationContextInitializer;
 import org.springframework.context.annotation.Bean;
 import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.TestPropertySource;
 
 @EnableJpaRepositories(basePackages = "org.eclipse.openk.contactbasedata")
 @EntityScan(basePackageClasses = ContactBaseDataApplication.class)
+@ContextConfiguration( initializers = {ConfigFileApplicationContextInitializer.class})
+@TestPropertySource("spring.config.location=classpath:application.yml")
 public class TestConfiguration {
     @Bean
     VersionMapper versionMapper() { return new VersionMapperImpl(); }
diff --git a/src/test/java/org/eclipse/openk/contactbasedata/controller/ContactControllerTest.java b/src/test/java/org/eclipse/openk/contactbasedata/controller/ContactControllerTest.java
index 626d5e0..1b79c1d 100644
--- a/src/test/java/org/eclipse/openk/contactbasedata/controller/ContactControllerTest.java
+++ b/src/test/java/org/eclipse/openk/contactbasedata/controller/ContactControllerTest.java
@@ -26,6 +26,7 @@
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;
 import org.springframework.http.MediaType;
+import org.springframework.test.context.ActiveProfiles;
 import org.springframework.test.web.servlet.MockMvc;
 
 import static org.hamcrest.Matchers.is;
@@ -39,6 +40,7 @@
 
 @SpringBootTest(classes = ContactBaseDataApplication.class)
 @AutoConfigureMockMvc
+@ActiveProfiles("test") // Todo: Find a better way to configure the tests
 public class ContactControllerTest {
 
     @MockBean
diff --git a/src/test/resouces/application.yml b/src/test/resouces/application.yml
index 63decee..c95f067 100644
--- a/src/test/resouces/application.yml
+++ b/src/test/resouces/application.yml
@@ -1,21 +1,27 @@
- #  *******************************************************************************
- #  Copyright (c) 2019 Contributors to the Eclipse Foundation
- #
- #  See the NOTICE file(s) distributed with this work for additional
- #  information regarding copyright ownership.
- #
- #  This program and the accompanying materials are made available under the
- #  terms of the Eclipse Public License v. 2.0 which is available at
- #  http://www.eclipse.org/legal/epl-2.0.
- #
- #  SPDX-License-Identifier: EPL-2.0
- #  *******************************************************************************
-  spring:
+#  *******************************************************************************
+#  Copyright (c) 2019 Contributors to the Eclipse Foundation
+#
+#  See the NOTICE file(s) distributed with this work for additional
+#  information regarding copyright ownership.
+#
+#  This program and the accompanying materials are made available under the
+#  terms of the Eclipse Public License v. 2.0 which is available at
+#  http://www.eclipse.org/legal/epl-2.0.
+#
+#  SPDX-License-Identifier: EPL-2.0
+#  *******************************************************************************
+spring:
   datasource:
     url: jdbc:h2:mem:test;DB_CLOSE_DELAY=-1
-  jpa:
-    hibernate:
-      ddl-auto: create
-    show-sql: true
-  flyway:
-    enabled: false
\ No newline at end of file
+
+jpa:
+  hibernate:
+    ddl-auto: create
+  show-sql: true
+flyway:
+  enabled: false
+
+jwt:
+  tokenHeader: accessToken
+  useStaticJwt: true
+  staticJwt: eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJIYlI3Z2pobmE2eXJRZnZJTWhUSV9tY2g3ZmtTQWVFX3hLTjBhZVl0bjdjIn0.eyJqdGkiOiI1OWVmNTYxNi1hYjlkLTQwMDItODUxNC05Njg4NzMwNmRiMzciLCJleHAiOjE1NzY0ODY4NzYsIm5iZiI6MCwiaWF0IjoxNTc2NDg2NTc2LCJpc3MiOiJodHRwOi8vbG9jYWxob3N0OjgwODAvYXV0aC9yZWFsbXMvRWxvZ2Jvb2siLCJhdWQiOiJlbG9nYm9vay1iYWNrZW5kIiwic3ViIjoiYzFkMTA5NDAtNzRjYS00ZWZjLWFlNWUtY2Q5NmE5ZWE3MTI3IiwidHlwIjoiQmVhcmVyIiwiYXpwIjoiZWxvZ2Jvb2stYmFja2VuZCIsImF1dGhfdGltZSI6MCwic2Vzc2lvbl9zdGF0ZSI6IjQ2ZmVlNTE2LTA0ODktNGYzNC1iZDI4LWI1NjBiNzFmZDViMCIsImFjciI6IjEiLCJhbGxvd2VkLW9yaWdpbnMiOlsiKiJdLCJyZWFsbV9hY2Nlc3MiOnsicm9sZXMiOlsia29uLWFjY2VzcyIsImtvbi1yZWFkZXIiXX0sInJlc291cmNlX2FjY2VzcyI6e30sIm5hbWUiOiJGaW5pYSBSZWFkZXIiLCJwcmVmZXJyZWRfdXNlcm5hbWUiOiJmaW5pYV9yIiwiZ2l2ZW5fbmFtZSI6IkZpbmlhIiwiZmFtaWx5X25hbWUiOiJSZWFkZXIifQ.CHtZ_SdXxwzQeji41vVCh6e84pls2LfJC1Z6cMiU0ks0nBa9GXPy_TtqMAsmVEbjPJOkFaOY0rO28h7kldUALCiWEl2-7bzKlW4FvKYv_xrlhWJDWI9PTvYKZHMD7igp8ePs9t4ksvr3J8pRl75-_jWa-lPI6dW0B2vinwyZcH0RW6ImQUG23zcvtUpVIGUHbD0YiZKdBg--UU4760EzrGYAXQPgaU63Fw4aw8qbRsD4007mETbpr5avmUnQeWjhG0swukgmA4t9xTWElXD0JaheDxNPQsZMDkv-dX-A114UHjjoIC_S9EDDYc3P7yZkKwcp-CbUBkR7WIMu6zQD7g