commit 9e82bc8a12e86c27be14b14fbd858611c1d37ad1
Author: Jiri Trefil <badjokke@gmail.com>
Date:   Sat Apr 29 22:31:34 2023 +0200

    #10517 repository a controller + service vytvořena. Chybí dodělat verifikace uživ parametrů a různé corner cases.

diff --git a/pom.xml b/pom.xml
index 931b253..408d446 100644
--- a/pom.xml
+++ b/pom.xml
@@ -124,7 +124,6 @@
 			<version>${org.junit.jupiter.version}</version>
 			<scope>test</scope>
 		</dependency>
-
 		<!-- json library with minimal overhead -->
 		<dependency>
 			<groupId>com.googlecode.json-simple</groupId>
diff --git a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/controller/ConfigurationController.java b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/controller/ConfigurationController.java
index 6053390..ad6c5d2 100644
--- a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/controller/ConfigurationController.java
+++ b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/controller/ConfigurationController.java
@@ -1,14 +1,14 @@
 package cz.zcu.fav.kiv.antipatterndetectionapp.v2.controller;
 
-import cz.zcu.fav.kiv.antipatterndetectionapp.v2.model.Configuration;
-import cz.zcu.fav.kiv.antipatterndetectionapp.v2.model.User;
-import cz.zcu.fav.kiv.antipatterndetectionapp.v2.model.UserConfigKey;
-import cz.zcu.fav.kiv.antipatterndetectionapp.v2.model.UserConfiguration;
-import cz.zcu.fav.kiv.antipatterndetectionapp.v2.repository.UserConfigurationRepository;
+import cz.zcu.fav.kiv.antipatterndetectionapp.v2.model.*;
+import cz.zcu.fav.kiv.antipatterndetectionapp.v2.repository.ConfigRepository;
+import cz.zcu.fav.kiv.antipatterndetectionapp.v2.repository.UserConfigurationJoinRepository;
+import cz.zcu.fav.kiv.antipatterndetectionapp.v2.service.ConfigurationService;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
 
 /**
  * @Author Jiri Trefil
@@ -18,15 +18,23 @@ import org.springframework.web.bind.annotation.RestController;
 @RequestMapping("v2/configuration")
 public class ConfigurationController {
     @Autowired
-    private UserConfigurationRepository userConfigurationRepository ;
+    private ConfigurationService configurationService;
+
+    @PostMapping(value="/upload_configuration")
+    public ResponseEntity<String> test(@RequestBody UserConfiguration userConfiguration) {
+        ResponseEntity<String> response = configurationService.addConfiguration(userConfiguration);
 
-    @GetMapping(value="/test")
-    public String test(){
-        UserConfigKey key = new UserConfigKey(1,1);
-        UserConfiguration tmp = userConfigurationRepository.save(new UserConfiguration(key));
-        return "test";
+        return null;
     }
 
+    @GetMapping(value="/get_configuration")
+    public ResponseEntity<String> getUserConfigurations(@RequestParam(name="name") String userName){
+        User user = new User(userName);
+        ResponseEntity<String> response = this.configurationService.getUserConfigurations(user);
+        return response;
+    }
+
+
 
 
 
diff --git a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/model/Configuration.java b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/model/Configuration.java
index 331fa7d..134ccc1 100644
--- a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/model/Configuration.java
+++ b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/model/Configuration.java
@@ -3,7 +3,7 @@ package cz.zcu.fav.kiv.antipatterndetectionapp.v2.model;
 import javax.persistence.*;
 
 @Entity
-@Table(name="configuration")
+@Table(name="configurations")
 public class Configuration {
     @Id
     @GeneratedValue(strategy = GenerationType.IDENTITY)
@@ -13,15 +13,24 @@ public class Configuration {
     //hash of the configuration so users cant upload duplicates
     private String configHash;
     // 'Y' if the configuration is accessible to everyone, 'N' if its user defined
-    private char isDefault;
+    private String isDefault;
 
     public Configuration(){}
-    public Configuration(String config, String configHash, boolean isDefault){
+    public Configuration(String config, String configHash, String isDefault){
         this.config = config;
         this.configHash = configHash;
-        this.isDefault = isDefault?'Y':'N';
+        this.isDefault = isDefault;
     }
 
+    public Configuration(int id){
+        this.id = id;
+    }
+
+    public Configuration(String config, String isDefault){
+        this.config = config;
+        this.configHash = null;
+        this.isDefault = isDefault;
+    }
 
     public int getId() {
         return id;
@@ -35,7 +44,14 @@ public class Configuration {
         return configHash;
     }
 
-    public char getIsDefault() {
+    public String getIsDefault() {
         return isDefault;
     }
+
+
+    public void setHash(String hash){
+        this.configHash = hash;
+    }
+
+
 }
diff --git a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/model/User.java b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/model/User.java
index 43b2935..6871553 100644
--- a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/model/User.java
+++ b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/model/User.java
@@ -55,7 +55,9 @@ public class User {
         this.name = name;
         this.token = token;
     }
-
+    public User(String name){
+        this.name = name;
+    }
     public User(String name, String email, String password){
         this.name = name;
         this.email = email;
diff --git a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/model/UserConfigKey.java b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/model/UserConfigKey.java
index 6456b7c..745ef4c 100644
--- a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/model/UserConfigKey.java
+++ b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/model/UserConfigKey.java
@@ -3,6 +3,12 @@ package cz.zcu.fav.kiv.antipatterndetectionapp.v2.model;
 import javax.persistence.Embeddable;
 import java.io.Serializable;
 
+/**
+ * @Author Jiri Trefil
+ * primary key of table user_configuration is compound (userId,configurationId) pair is unique
+ * @Deprecated not being used (29.04.2023)
+ * the business logic involving this table is in ConfigurationRepository interface
+ */
 @Embeddable
 public class UserConfigKey implements Serializable {
 
@@ -14,6 +20,21 @@ public UserConfigKey(int userId,int configId){
     this.configId = configId;
 }
 
+    public int getUserId() {
+        return userId;
+    }
+
+    public int getConfigId() {
+        return configId;
+    }
+
+    public void setUserId(int userId) {
+        this.userId = userId;
+    }
+
+    public void setConfigId(int configId) {
+        this.configId = configId;
+    }
 
     public UserConfigKey() {
 
diff --git a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/model/UserConfiguration.java b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/model/UserConfiguration.java
index 63c5f03..670dd0b 100644
--- a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/model/UserConfiguration.java
+++ b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/model/UserConfiguration.java
@@ -1,30 +1,35 @@
 package cz.zcu.fav.kiv.antipatterndetectionapp.v2.model;
 
-import javax.persistence.*;
-import java.io.Serializable;
 
 /**
- * @Author Jiri Trefil
- * Join table between user and configuration
- * One user can have multiple (or none) configurations associated with him
- * One configuration can have associated multiple users
- * there this Many:Many relationship has to be decomposed with this table
- * Primary key is a Composite key (userId+configId is always a unique pair)
+ * @author Jiri Trefil
+ * Wrapper for http request for uploading a new configuration by user
  */
-@Entity
-@Table(name="user_configurations")
 public class UserConfiguration {
-    @EmbeddedId
-    private UserConfigKey id;
+    private User user;
+    private Configuration configuration;
 
 
-    public UserConfiguration(){
+    public UserConfiguration(User user, Configuration configuration){
+        this.user = user;
+        this.configuration = configuration;
     }
+    public UserConfiguration(){}
 
-    public UserConfiguration(UserConfigKey id){
-        this.id = id;
+
+    public User getUser() {
+        return user;
+    }
+
+    public Configuration getConfiguration() {
+        return configuration;
     }
-    public UserConfigKey getUserConfigKey(){
-        return this.id;
+
+    public void setUser(User user) {
+        this.user = user;
+    }
+
+    public void setConfiguration(Configuration configuration) {
+        this.configuration = configuration;
     }
 }
diff --git a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/model/UserConfigurationJoin.java b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/model/UserConfigurationJoin.java
new file mode 100644
index 0000000..dc55517
--- /dev/null
+++ b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/model/UserConfigurationJoin.java
@@ -0,0 +1,29 @@
+package cz.zcu.fav.kiv.antipatterndetectionapp.v2.model;
+
+import javax.persistence.*;
+
+/**
+ * @Author Jiri Trefil
+ * Join table between user and configuration
+ * One user can have multiple (or none) configurations associated with him
+ * One configuration can have associated multiple users
+ * there this Many:Many relationship has to be decomposed with this table
+ * Primary key is a Composite key (userId+configId is always a unique pair)
+ */
+@Entity
+@Table(name="user_configurations")
+public class UserConfigurationJoin {
+    @EmbeddedId
+    private UserConfigKey id;
+
+
+    public UserConfigurationJoin(){
+    }
+
+    public UserConfigurationJoin(UserConfigKey id){
+        this.id = id;
+    }
+    public UserConfigKey getUserConfigKey(){
+        return this.id;
+    }
+}
diff --git a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/repository/ConfigRepository.java b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/repository/ConfigRepository.java
new file mode 100644
index 0000000..8993274
--- /dev/null
+++ b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/repository/ConfigRepository.java
@@ -0,0 +1,25 @@
+package cz.zcu.fav.kiv.antipatterndetectionapp.v2.repository;
+
+import cz.zcu.fav.kiv.antipatterndetectionapp.v2.model.Configuration;
+import cz.zcu.fav.kiv.antipatterndetectionapp.v2.model.UserConfigKey;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Modifying;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+@Repository
+public interface ConfigRepository extends JpaRepository<Configuration,Integer> {
+    Configuration findConfigurationById(int id);
+    Configuration findConfigurationByConfigHash(String hash);
+    //query to get all public configurations
+    @Query("Select config from Configuration config where config.isDefault = 'Y'")
+    List<Configuration> getPublicConfigurations();
+    //retrieve all public configurations and configurations available to the user
+    //assumption - default configurations are not assigned to any user explicitly
+    @Query("select config from Configuration config where config.isDefault = 'Y' " +
+            "or config.id in (select userconfig.id.userId from UserConfigurationJoin userconfig where userconfig.id.userId = ?1)")
+    List<Configuration> getAllUserConfigurations(int userId);
+
+
+}
diff --git a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/repository/UserConfigurationJoinRepository.java b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/repository/UserConfigurationJoinRepository.java
new file mode 100644
index 0000000..6a27e46
--- /dev/null
+++ b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/repository/UserConfigurationJoinRepository.java
@@ -0,0 +1,13 @@
+package cz.zcu.fav.kiv.antipatterndetectionapp.v2.repository;
+
+import cz.zcu.fav.kiv.antipatterndetectionapp.v2.model.UserConfigKey;
+import cz.zcu.fav.kiv.antipatterndetectionapp.v2.model.UserConfigurationJoin;
+import org.springframework.data.jpa.repository.JpaRepository;
+
+/**
+ * this repository is not being used (29.04.2023)
+ * but it provides and API to work with Join table user_configurations
+ * the logic is contained in ConfigurationRepository interface (the pairing of user and configuration)
+ */
+public interface UserConfigurationJoinRepository extends JpaRepository<UserConfigurationJoin, UserConfigKey> {
+}
diff --git a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/repository/UserConfigurationRepository.java b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/repository/UserConfigurationRepository.java
deleted file mode 100644
index 7046863..0000000
--- a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/repository/UserConfigurationRepository.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package cz.zcu.fav.kiv.antipatterndetectionapp.v2.repository;
-
-import cz.zcu.fav.kiv.antipatterndetectionapp.v2.model.UserConfigKey;
-import cz.zcu.fav.kiv.antipatterndetectionapp.v2.model.UserConfiguration;
-import org.springframework.data.jpa.repository.JpaRepository;
-
-public interface UserConfigurationRepository extends JpaRepository<UserConfiguration, UserConfigKey> {
-}
diff --git a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/security/JwtAuthenticationFilter.java b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/security/JwtAuthenticationFilter.java
index e97e43c..305e29e 100644
--- a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/security/JwtAuthenticationFilter.java
+++ b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/security/JwtAuthenticationFilter.java
@@ -1,10 +1,5 @@
 package cz.zcu.fav.kiv.antipatterndetectionapp.v2.security;
-
-import cz.zcu.fav.kiv.antipatterndetectionapp.v2.httpExceptions.CustomExceptionHandler;
 import cz.zcu.fav.kiv.antipatterndetectionapp.v2.service.OAuthService;
-import cz.zcu.fav.kiv.antipatterndetectionapp.v2.utils.JSONBuilder;
-import org.json.simple.JSONObject;
-import org.json.simple.parser.ParseException;
 import org.springframework.http.*;
 import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
 import org.springframework.security.core.Authentication;
@@ -37,7 +32,6 @@ public class JwtAuthenticationFilter extends OncePerRequestFilter {
 
         String authorizationHeader = request.getHeader("Authorization");
         if (authorizationHeader == null || !authorizationHeader.startsWith("Bearer ")) {
-//            chain.doFilter(request, response);
             SecurityContextHolder.clearContext();
             response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
             response.getOutputStream().println("{\"error\" : \"Some other error related to jwt token!\"}");
@@ -56,13 +50,6 @@ public class JwtAuthenticationFilter extends OncePerRequestFilter {
 
                 Authentication auth = new UsernamePasswordAuthenticationToken(userDetails, token, userDetails.getAuthorities());
                 SecurityContextHolder.getContext().setAuthentication(auth);
-    /*
-            else {
-                SecurityContextHolder.clearContext();
-                response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
-                response.getOutputStream().println("{\"error\" : \"Token timed out!\"}");
-                return;
-            }*/
         }
         //4xx or 5xx http response from auth application
         //basically copies the response from auth app and send it to client
@@ -79,7 +66,7 @@ public class JwtAuthenticationFilter extends OncePerRequestFilter {
     }
 
     @Override
-    protected boolean shouldNotFilter(HttpServletRequest request) throws ServletException {
+    protected boolean shouldNotFilter(HttpServletRequest request) {
             String path = request.getRequestURI().substring(request.getContextPath().length());
         return path.startsWith("/v2/user/login") || path.startsWith("/v2/user/register");
     }
diff --git a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/security/WebSecurityConfig.java b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/security/WebSecurityConfig.java
index 03f67ab..b74c9b7 100644
--- a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/security/WebSecurityConfig.java
+++ b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/security/WebSecurityConfig.java
@@ -16,6 +16,7 @@ import org.springframework.security.config.http.SessionCreationPolicy;
 import org.springframework.security.core.userdetails.UserDetailsService;
 import org.springframework.security.web.SecurityFilterChain;
 import org.springframework.security.web.access.channel.ChannelProcessingFilter;
+import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
 import org.springframework.web.client.RestTemplate;
 import org.springframework.web.cors.CorsConfiguration;
 import org.springframework.web.cors.CorsConfigurationSource;
@@ -70,11 +71,12 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
     @Override
     protected void configure(HttpSecurity httpSecurity) throws Exception {
         httpSecurity
+                .addFilterBefore(jwtAuthenticationFilter, UsernamePasswordAuthenticationFilter.class)
                 .cors().configurationSource(corsConfigurationSource())
                 .and()
                 .csrf().disable()
                 .authorizeRequests()
-                .mvcMatchers("/v2/user/register", "/v2/user/login", "/v2/user/refresh", "/v2/user/logout","/v2/configuration//test").permitAll()
+                .mvcMatchers("/v2/user/register", "/v2/user/login", "/v2/user/refresh", "/v2/user/logout","/v2/configuration//get_configuration","v2/configuration/upload_configuration").permitAll()
                 .anyRequest().authenticated()
                 .and()
                 .sessionManagement()
diff --git a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/service/ConfigurationService.java b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/service/ConfigurationService.java
new file mode 100644
index 0000000..9553399
--- /dev/null
+++ b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/service/ConfigurationService.java
@@ -0,0 +1,21 @@
+package cz.zcu.fav.kiv.antipatterndetectionapp.v2.service;
+import cz.zcu.fav.kiv.antipatterndetectionapp.v2.model.Configuration;
+import cz.zcu.fav.kiv.antipatterndetectionapp.v2.model.User;
+import cz.zcu.fav.kiv.antipatterndetectionapp.v2.model.UserConfiguration;
+import org.springframework.http.ResponseEntity;
+
+public interface ConfigurationService {
+    //upload configuration
+    ResponseEntity<String> addConfiguration(Configuration cfg);
+    ResponseEntity<String> addConfiguration(UserConfiguration cfg);
+
+    ResponseEntity<String> pairConfigurationWithUser(User user, Configuration configuration);
+    //get all configurations available to user
+    ResponseEntity<String> getUserConfigurations(User user);
+
+
+
+
+
+
+}
diff --git a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/service/ConfigurationServiceImplementation.java b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/service/ConfigurationServiceImplementation.java
new file mode 100644
index 0000000..6d59654
--- /dev/null
+++ b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/service/ConfigurationServiceImplementation.java
@@ -0,0 +1,92 @@
+package cz.zcu.fav.kiv.antipatterndetectionapp.v2.service;
+
+import cz.zcu.fav.kiv.antipatterndetectionapp.v2.model.*;
+import cz.zcu.fav.kiv.antipatterndetectionapp.v2.repository.ConfigRepository;
+import cz.zcu.fav.kiv.antipatterndetectionapp.v2.repository.UserConfigurationJoinRepository;
+import cz.zcu.fav.kiv.antipatterndetectionapp.v2.repository.UserRepository;
+import cz.zcu.fav.kiv.antipatterndetectionapp.v2.utils.Crypto;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+public class ConfigurationServiceImplementation implements ConfigurationService{
+
+    @Autowired
+    private ConfigRepository configurationRepository;
+    @Autowired
+    private UserConfigurationJoinRepository userConfigurationJoinRepository;
+
+    @Autowired
+    private UserService userService;
+    /**
+     * Saves configuration to database
+     * the configuration is default to everyone
+     * @param cfg Configuration - JSON format of configuration with antipatterns and thresholds
+     * @return ResponseEntity with status code and message with more information about operation
+     */
+    @Override
+    public ResponseEntity<String> addConfiguration(Configuration cfg) {
+        return null;
+    }
+    /**
+     * Saves configuration to database
+     * the configuration is available to the user who sent the request
+     * @param cfg Configuration - JSON format of configuration with antipatterns and thresholds
+     * @return ResponseEntity with status code and message with more information about operation
+     */
+    @Override
+    public ResponseEntity<String> addConfiguration(UserConfiguration cfg) {
+        User user = cfg.getUser();
+        Configuration configuration = cfg.getConfiguration();
+
+        String userName = user.getName();
+        user = this.userService.getUserByName(userName);
+        String configurationDefinition = configuration.getConfig();
+        if(configurationDefinition == null){
+            //todo konfigurace neni poslana, chyba requestu
+
+        }
+        String configHash = Crypto.hashString(configurationDefinition);
+        Configuration existingConfiguration = this.configurationRepository.findConfigurationByConfigHash(configHash);
+        //configuration definition does not exist => upload the configuration into database
+        if(existingConfiguration == null){
+            configuration.setHash(configHash);
+            //save the configuration itself
+            Configuration tmp = this.configurationRepository.save(configuration);
+            if(tmp == null){
+                //todo selhal insert do databaze
+            }
+        }
+
+        //pair the configuration to the user
+        return pairConfigurationWithUser(user,configuration);
+
+
+    }
+
+    @Override
+    public ResponseEntity<String> pairConfigurationWithUser(User user, Configuration configuration) {
+        final UserConfigKey key = new UserConfigKey(user.getId(),configuration.getId());
+        boolean exists = this.userConfigurationJoinRepository.existsById(key);
+        if(exists){
+            //todo uzivatel se chce sparovat s konfiguraci se kterou je jiz sparovan, jenom poslat ok nebo error
+        }
+        //save the relation between user and configuration
+        this.userConfigurationJoinRepository.save(new UserConfigurationJoin(key));
+        return null;
+    }
+
+    @Override
+    public ResponseEntity<String> getUserConfigurations(User user) {
+        final String userName = user.getName();
+        //client can only send his name - he obviously does not know his id in db, we have to query that
+        User userInfo = this.userService.getUserByName(userName);
+        //fetch all configurations this particular user can see
+        //ie all public configs + configurations uploaded by this particular user
+        List<Configuration> configurations = this.configurationRepository.getAllUserConfigurations(userInfo.getId());
+        return null;
+    }
+}
diff --git a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/service/UserServiceImpl.java b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/service/UserServiceImpl.java
index 8c7b849..1fbdb48 100644
--- a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/service/UserServiceImpl.java
+++ b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/service/UserServiceImpl.java
@@ -3,6 +3,7 @@ package cz.zcu.fav.kiv.antipatterndetectionapp.v2.service;
 import cz.zcu.fav.kiv.antipatterndetectionapp.v2.dials.UserModelStatusCodes;
 import cz.zcu.fav.kiv.antipatterndetectionapp.v2.model.User;
 import cz.zcu.fav.kiv.antipatterndetectionapp.v2.repository.UserRepository;
+import cz.zcu.fav.kiv.antipatterndetectionapp.v2.utils.Crypto;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -46,7 +47,7 @@ public class UserServiceImpl implements UserService {
             return UserModelStatusCodes.USER_EXISTS;
         }
 
-        String passwordHash = hashPassword(password);
+        String passwordHash = Crypto.hashString(password);
         //server side fault
         if (passwordHash == null) {
             return UserModelStatusCodes.HASH_FAILED;
@@ -83,26 +84,7 @@ public class UserServiceImpl implements UserService {
         return emailPattern.matcher(email).find();
     }
 
-    /**
-     * Method to hash password
-     * @param password  password from client
-     * @return          hashed password for database
-     */
-    public String hashPassword(String password) {
-        //standard java security encryption module
-        MessageDigest digest = null;
-        try {
-            //try to instance the class - throws an error if algorithm
-            digest = MessageDigest.getInstance("SHA3-256");
-        }
-        catch(NoSuchAlgorithmException exception){
-            exception.printStackTrace();
-            return null;
-        }
-        byte [] tmp = digest.digest(password.getBytes(StandardCharsets.UTF_8));
-        //convert byte array into string
-        return (new HexBinaryAdapter()).marshal(tmp);
-    }
+
 
     /**
      * Method
@@ -125,21 +107,12 @@ public class UserServiceImpl implements UserService {
         if (u == null) {
             return UserModelStatusCodes.USER_LOGIN_FAILED;
         }
-        final boolean passwordMatches = comparePassword(password,u.getPassword());
+        final boolean passwordMatches = Crypto.compareHashes(password, u.getPassword());
 
         return (!passwordMatches ? UserModelStatusCodes.USER_LOGIN_FAILED : UserModelStatusCodes.USER_LOGGED_IN);
     }
 
-    /**
-     * Method compares user password with stored hash
-     * @param password String user provided password
-     * @param hash String hash saved in database
-     * @return true if hashes are the same
-     */
-    boolean comparePassword(String password, String hash) {
-        final String passwordHash = this.hashPassword(password);
-        return hash.equals(passwordHash);
-    }
+
 
     @Override
     public User getUserByName(String name) {
diff --git a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/utils/Crypto.java b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/utils/Crypto.java
new file mode 100644
index 0000000..181a48d
--- /dev/null
+++ b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/utils/Crypto.java
@@ -0,0 +1,43 @@
+package cz.zcu.fav.kiv.antipatterndetectionapp.v2.utils;
+
+import javax.xml.bind.annotation.adapters.HexBinaryAdapter;
+import java.nio.charset.StandardCharsets;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+
+public class Crypto {
+
+    /**
+     * Method to hash password
+     * @param password  password from client
+     * @return          hashed password for database
+     */
+    public static String hashString(String password) {
+        //standard java security encryption module
+        MessageDigest digest = null;
+        try {
+            //try to instance the class - throws an error if algorithm
+            digest = MessageDigest.getInstance("SHA3-256");
+        }
+        catch(NoSuchAlgorithmException exception){
+            exception.printStackTrace();
+            return null;
+        }
+        byte [] tmp = digest.digest(password.getBytes(StandardCharsets.UTF_8));
+        //convert byte array into string
+        return (new HexBinaryAdapter()).marshal(tmp);
+    }
+
+    /**
+     * Method compares user password with stored hash
+     * @param password String user provided password
+     * @param hash String hash saved in database
+     * @return true if hashes are the same
+     */
+    public static boolean compareHashes(String password, String hash) {
+        final String passwordHash = hashString(password);
+        return hash.equals(passwordHash);
+    }
+
+
+}
