diff --git a/pom.xml b/pom.xml
index 2e34254bf5..3fd1bcf5fb 100644
--- a/pom.xml
+++ b/pom.xml
@@ -544,7 +544,6 @@
ratpack
reactor-core
- rest-with-spark-java
resteasy
restx
@@ -755,8 +754,6 @@
spring-thymeleaf
- spring-userservice
-
spring-vault
spring-vertx
@@ -925,7 +922,6 @@
spring-state-machine
spring-swagger-codegen/spring-swagger-codegen-app
spring-thymeleaf
- spring-userservice
spring-vault
spring-vertx
spring-zuul/spring-zuul-foos-resource
@@ -1225,7 +1221,6 @@
ratpack
reactor-core
- rest-with-spark-java
resteasy
restx
@@ -1421,8 +1416,6 @@
spring-thymeleaf
- spring-userservice
-
spring-vault
spring-vertx
diff --git a/rest-with-spark-java/README.md b/rest-with-spark-java/README.md
deleted file mode 100644
index ff12555376..0000000000
--- a/rest-with-spark-java/README.md
+++ /dev/null
@@ -1 +0,0 @@
-## Relevant articles:
diff --git a/rest-with-spark-java/pom.xml b/rest-with-spark-java/pom.xml
deleted file mode 100644
index fc78ac6b86..0000000000
--- a/rest-with-spark-java/pom.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-
-
- 4.0.0
- com.baeldung
- rest-with-spark-java
- 1.0-SNAPSHOT
- rest-with-spark-java
- http://maven.apache.org
-
-
- com.baeldung
- parent-modules
- 1.0.0-SNAPSHOT
-
-
-
-
- com.sparkjava
- spark-core
- ${spark-core.version}
-
-
- com.fasterxml.jackson.core
- jackson-core
- ${jackson.version}
-
-
- com.fasterxml.jackson.core
- jackson-databind
- ${jackson.version}
-
-
-
-
- 2.5.4
-
-
-
diff --git a/rest-with-spark-java/src/main/java/com/baeldung/Router.java b/rest-with-spark-java/src/main/java/com/baeldung/Router.java
deleted file mode 100644
index 3482184e1e..0000000000
--- a/rest-with-spark-java/src/main/java/com/baeldung/Router.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package com.baeldung;
-
-import static spark.Spark.after;
-import static spark.Spark.before;
-import static spark.Spark.delete;
-import static spark.Spark.get;
-import static spark.Spark.post;
-import static spark.Spark.port;
-
-import com.baeldung.domain.Book;
-import com.baeldung.service.LibraryService;
-
-public class Router {
-
- public static void main( String[] args ){
-
- port(8080);
-
- before((request, response) -> {
-
- //do some filtering stuff
-
- });
-
- after((request, response) -> {
- response.type("application/json");
- });
-
- get("ListOfBooks", (request, response) -> {
- return LibraryService.view();
- });
-
- get("SearchBook/:title", (request, response) -> {
- return LibraryService.view(request.params("title"));
- });
-
- post("AddBook/:title/:author/:publisher", (request, response) -> {
- Book book = new Book();
- book.setTitle(request.params("title"));
- book.setAuthor(request.params("author"));
- book.setPublisher(request.params("publisher"));
- return LibraryService.add(book);
- });
-
- delete("DeleteBook/:title", (request, response) -> {
- return LibraryService.delete(request.params("title"));
- });
-
- }
-}
diff --git a/rest-with-spark-java/src/main/java/com/baeldung/domain/Book.java b/rest-with-spark-java/src/main/java/com/baeldung/domain/Book.java
deleted file mode 100644
index 977d5d9f89..0000000000
--- a/rest-with-spark-java/src/main/java/com/baeldung/domain/Book.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package com.baeldung.domain;
-
-public class Book {
-
- private String title;
- private String author;
- private String publisher;
-
- public Book() {}
-
- public Book(String title, String author, String publisher) {
- super();
- this.title = title;
- this.author = author;
- this.publisher = publisher;
- }
-
- public String getTitle() {
- return title;
- }
- public void setTitle(String title) {
- this.title = title;
- }
- public String getAuthor() {
- return author;
- }
-
- public void setAuthor(String author) {
- this.author = author;
- }
- public String getPublisher() {
- return publisher;
- }
- public void setPublisher(String publisher) {
- this.publisher = publisher;
- }
-
- protected boolean canEqual(Object other) {
- return other instanceof Book;
- }
-
- @Override
- public boolean equals(Object o) {
- if (o == this) return true;
- if (!(o instanceof Book)) return false;
- Book other = (Book) o;
- if (!other.canEqual((Object)this)) return false;
- if (this.getTitle() == null ? other.getTitle() != null : !this.getTitle().equals(other.getTitle())) return false;
- return true;
- }
-
-}
diff --git a/rest-with-spark-java/src/main/java/com/baeldung/service/LibraryService.java b/rest-with-spark-java/src/main/java/com/baeldung/service/LibraryService.java
deleted file mode 100644
index e4ca4c270c..0000000000
--- a/rest-with-spark-java/src/main/java/com/baeldung/service/LibraryService.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package com.baeldung.service;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import com.baeldung.domain.Book;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.ObjectWriter;
-
-public class LibraryService {
-
- private static ObjectWriter mapper = new ObjectMapper().writer().withDefaultPrettyPrinter();
- private static Map library = new HashMap();
-
- public static String view() throws JsonProcessingException {
- List books = new ArrayList();
- library.forEach((key, value) -> {
- books.add(value);
- });
- return mapper.writeValueAsString(books);
- }
-
- public static String view(String title) throws JsonProcessingException {
- return mapper.writeValueAsString(library.get(title));
- }
-
- public static String add(Book book) throws JsonProcessingException {
- library.put(book.getTitle(), book);
- return mapper.writeValueAsString(book);
- }
-
- public static String delete(String title) throws JsonProcessingException {
- Book deletedBook = library.remove(title);
- return mapper.writeValueAsString(deletedBook);
- }
-
-}
diff --git a/rest-with-spark-java/src/main/resources/logback.xml b/rest-with-spark-java/src/main/resources/logback.xml
deleted file mode 100644
index 7d900d8ea8..0000000000
--- a/rest-with-spark-java/src/main/resources/logback.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
- %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/rest-with-spark-java/src/test/java/com/baeldung/AppLiveTest.java b/rest-with-spark-java/src/test/java/com/baeldung/AppLiveTest.java
deleted file mode 100644
index 9e24879767..0000000000
--- a/rest-with-spark-java/src/test/java/com/baeldung/AppLiveTest.java
+++ /dev/null
@@ -1,148 +0,0 @@
-package com.baeldung;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-
-import com.baeldung.domain.Book;
-import com.fasterxml.jackson.core.type.TypeReference;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-public class AppLiveTest extends TestCase {
-
- ObjectMapper mapper = new ObjectMapper();
-
- public AppLiveTest( String testName ) {
- super( testName );
- }
-
- public static Test suite() {
- return new TestSuite( AppLiveTest.class );
- }
-
- public void testApp() throws IOException, ClassNotFoundException {
-
- URL url;
- HttpURLConnection conn;
- BufferedReader br;
- String output;
- StringBuffer resp;
- Book book;
- Book temp;
-
- url = new URL("http://localhost:8080/AddBook/Odessy/YannMartel/GreenLeaves");
- conn = (HttpURLConnection) url.openConnection();
- conn.setRequestMethod("POST");
- conn.getContent();
- br = new BufferedReader(new InputStreamReader(
- (conn.getInputStream())));
- resp = new StringBuffer();
-
- while ((output = br.readLine()) != null) {
- resp.append(output);
- }
-
- book = mapper.readValue(resp.toString(), Book.class);
- temp = new Book("Odessy","YannMartel","GreenLeaves");
-
- assertEquals(book, temp);
-
- url = new URL("http://localhost:8080/AddBook/Twilight/StephenieMeyer/LittleBrown");
- conn = (HttpURLConnection) url.openConnection();
- conn.setRequestMethod("POST");
- br = new BufferedReader(new InputStreamReader(
- (conn.getInputStream())));
- resp = new StringBuffer();
-
- while ((output = br.readLine()) != null) {
- resp.append(output);
- }
-
- book = mapper.readValue(resp.toString(), Book.class);
- temp = new Book("Twilight","StephenieMeyer","LittleBrown");
-
- assertEquals(book, temp);
-
- url = new URL("http://localhost:8080/ListOfBooks");
- conn = (HttpURLConnection) url.openConnection();
- conn.setRequestMethod("GET");
- br = new BufferedReader(new InputStreamReader(
- (conn.getInputStream())));
- resp = new StringBuffer();
-
- while ((output = br.readLine()) != null) {
- resp.append(output);
- }
-
- List books = new ArrayList();
-
- books.add(new Book("Odessy","YannMartel","GreenLeaves"));
- books.add(new Book("Twilight","StephenieMeyer","LittleBrown"));
-
- List listOfBooks = mapper.readValue(resp.toString(), new TypeReference>(){});
-
- assertEquals(books, listOfBooks);
-
- url = new URL("http://localhost:8080/SearchBook/Twilight");
- conn = (HttpURLConnection) url.openConnection();
- conn.setRequestMethod("GET");
- br = new BufferedReader(new InputStreamReader(
- (conn.getInputStream())));
- resp = new StringBuffer();
-
- while ((output = br.readLine()) != null) {
- resp.append(output);
- }
-
- book = mapper.readValue(resp.toString(), Book.class);
- temp = new Book("Twilight","StephenieMeyer","LittleBrown");
-
- assertEquals(book, temp);
-
- url = new URL("http://localhost:8080/DeleteBook/Twilight");
- conn = (HttpURLConnection) url.openConnection();
- conn.setRequestMethod("DELETE");
- br = new BufferedReader(new InputStreamReader(
- (conn.getInputStream())));
- resp = new StringBuffer();
-
- while ((output = br.readLine()) != null) {
- resp.append(output);
- }
-
- book = mapper.readValue(resp.toString(), Book.class);
- temp = new Book("Twilight","StephenieMeyer","LittleBrown");
-
- assertEquals(book, temp);
-
- url = new URL("http://localhost:8080/ListOfBooks");
- conn = (HttpURLConnection) url.openConnection();
- conn.setRequestMethod("GET");
- br = new BufferedReader(new InputStreamReader(
- (conn.getInputStream())));
- resp = new StringBuffer();
-
- while ((output = br.readLine()) != null) {
- resp.append(output);
- }
-
- books = new ArrayList();
-
- books.add(new Book("Odessy","YannMartel","GreenLeaves"));
- listOfBooks = mapper.readValue(resp.toString(), new TypeReference>(){});
-
- assertEquals(books, listOfBooks);
-
- conn.disconnect();
-
- }
-
-}
diff --git a/spring-userservice/.gitignore b/spring-userservice/.gitignore
deleted file mode 100644
index afe61e7c0c..0000000000
--- a/spring-userservice/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-derby.log
\ No newline at end of file
diff --git a/spring-userservice/.springBeans b/spring-userservice/.springBeans
deleted file mode 100644
index ff32b84d3b..0000000000
--- a/spring-userservice/.springBeans
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
- 1
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/spring-userservice/README.md b/spring-userservice/README.md
deleted file mode 100644
index 097afc5fc1..0000000000
--- a/spring-userservice/README.md
+++ /dev/null
@@ -1 +0,0 @@
-spring-userservice is using a in memory derby db. Right click -> run on server to run the project
\ No newline at end of file
diff --git a/spring-userservice/pom.xml b/spring-userservice/pom.xml
deleted file mode 100644
index cd61dfbf27..0000000000
--- a/spring-userservice/pom.xml
+++ /dev/null
@@ -1,240 +0,0 @@
-
- 4.0.0
- spring-userservice
- spring-userservice
- 0.0.1-SNAPSHOT
- war
- spring-userservice
-
-
- com.baeldung
- parent-spring-4
- 0.0.1-SNAPSHOT
- ../parent-spring-4
-
-
-
-
-
-
-
- org.springframework
- spring-orm
- ${spring.version}
-
-
- org.springframework
- spring-context
- ${spring.version}
-
-
-
-
-
- org.hibernate
- hibernate-entitymanager
- ${hibernate.version}
-
-
- org.hibernate
- hibernate-ehcache
- ${hibernate.version}
-
-
- xml-apis
- xml-apis
- ${xml-apis.version}
-
-
- org.javassist
- javassist
- ${javassist.version}
-
-
- mysql
- mysql-connector-java
- ${mysql-connector-java.version}
- runtime
-
-
- org.springframework.data
- spring-data-jpa
- ${spring-data-jpa.version}
-
-
- com.h2database
- h2
- ${h2.version}
-
-
-
-
-
- org.hibernate
- hibernate-validator
- ${hibernate-validator.version}
-
-
- javax.el
- javax.el-api
- ${javax.el-api.version}
-
-
-
-
-
- com.google.guava
- guava
- ${guava.version}
-
-
-
-
-
- org.apache.commons
- commons-lang3
- ${commons-lang3.version}
- test
-
-
-
- org.springframework
- spring-test
- ${spring.version}
- test
-
-
-
- org.springframework
- spring-core
- ${spring.version}
-
-
- commons-logging
- commons-logging
-
-
-
-
- org.springframework
- spring-web
- ${spring.version}
-
-
- org.springframework
- spring-webmvc
- ${spring.version}
-
-
-
- org.springframework.security
- spring-security-core
- ${org.springframework.security.version}
-
-
- org.springframework.security
- spring-security-web
- ${org.springframework.security.version}
-
-
- org.springframework.security
- spring-security-config
- ${org.springframework.security.version}
-
-
-
- org.apache.derby
- derby
- ${derby.version}
-
-
- org.apache.derby
- derbyclient
- ${derby.version}
-
-
- org.apache.derby
- derbynet
- ${derby.version}
-
-
- org.apache.derby
- derbytools
- ${derby.version}
-
-
- taglibs
- standard
- ${taglibs-standard.version}
-
-
- org.springframework.security
- spring-security-taglibs
- ${org.springframework.security.version}
-
-
- javax.servlet.jsp.jstl
- jstl-api
- ${jstl.version}
-
-
- org.springframework.boot
- spring-boot-test
- ${spring-boot.version}
-
-
- org.springframework.boot
- spring-boot
- ${spring-boot.version}
-
-
- javax.servlet
- javax.servlet-api
- ${javax.servlet-api.version}
-
-
-
-
- spring-userservice
-
-
- src/main/resources
- true
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-war-plugin
- ${maven-war-plugin.version}
-
-
-
-
-
-
-
- 4.2.6.RELEASE
- 1.5.14.RELEASE
- 3.21.0-GA
-
-
- 5.2.10.Final
- 5.1.40
- 1.10.5.RELEASE
- 10.13.1.1
-
-
- 5.3.3.Final
- 2.2.5
- 1.1.2
-
-
- 19.0
- 1.4.01
-
-
-
\ No newline at end of file
diff --git a/spring-userservice/src/main/java/org/baeldung/custom/config/MvcConfig.java b/spring-userservice/src/main/java/org/baeldung/custom/config/MvcConfig.java
deleted file mode 100644
index 4a9e737a92..0000000000
--- a/spring-userservice/src/main/java/org/baeldung/custom/config/MvcConfig.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package org.baeldung.custom.config;
-
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.ComponentScan;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.web.servlet.ViewResolver;
-import org.springframework.web.servlet.config.annotation.EnableWebMvc;
-import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
-import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
-import org.springframework.web.servlet.view.InternalResourceViewResolver;
-import org.springframework.web.servlet.view.JstlView;
-
-@EnableWebMvc
-@Configuration
-@ComponentScan(basePackages = { "org.baeldung.security" })
-public class MvcConfig extends WebMvcConfigurerAdapter {
-
- public MvcConfig() {
- super();
- }
-
- @Override
- public void addViewControllers(final ViewControllerRegistry registry) {
- super.addViewControllers(registry);
-
- registry.addViewController("/");
- registry.addViewController("/index");
- registry.addViewController("/login");
- registry.addViewController("/register");
- }
-
- @Bean
- public ViewResolver viewResolver() {
- final InternalResourceViewResolver bean = new InternalResourceViewResolver();
-
- bean.setViewClass(JstlView.class);
- bean.setPrefix("/WEB-INF/view/");
- bean.setSuffix(".jsp");
-
- return bean;
- }
-}
diff --git a/spring-userservice/src/main/java/org/baeldung/custom/config/PersistenceDerbyJPAConfig.java b/spring-userservice/src/main/java/org/baeldung/custom/config/PersistenceDerbyJPAConfig.java
deleted file mode 100644
index 6be7053b78..0000000000
--- a/spring-userservice/src/main/java/org/baeldung/custom/config/PersistenceDerbyJPAConfig.java
+++ /dev/null
@@ -1,89 +0,0 @@
-package org.baeldung.custom.config;
-
-import java.util.Properties;
-
-import javax.persistence.EntityManagerFactory;
-import javax.sql.DataSource;
-
-import org.baeldung.user.dao.MyUserDAO;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.PropertySource;
-import org.springframework.core.env.Environment;
-import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor;
-import org.springframework.jdbc.datasource.DriverManagerDataSource;
-import org.springframework.orm.jpa.JpaTransactionManager;
-import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
-import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
-import org.springframework.transaction.PlatformTransactionManager;
-import org.springframework.transaction.annotation.EnableTransactionManagement;
-
-import com.google.common.base.Preconditions;
-
-@Configuration
-@EnableTransactionManagement
-@PropertySource({ "classpath:persistence-derby.properties" })
-public class PersistenceDerbyJPAConfig {
-
- @Autowired
- private Environment env;
-
- public PersistenceDerbyJPAConfig() {
- super();
- }
-
- // beans
-
- @Bean
- public LocalContainerEntityManagerFactoryBean myEmf() {
- final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
- em.setDataSource(dataSource());
- em.setPackagesToScan(new String[] { "org.baeldung.persistence.model" });
-
- final HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
- em.setJpaVendorAdapter(vendorAdapter);
- em.setJpaProperties(additionalProperties());
-
- return em;
- }
-
- @Bean
- public DataSource dataSource() {
- final DriverManagerDataSource dataSource = new DriverManagerDataSource();
- dataSource.setDriverClassName(Preconditions.checkNotNull(env.getProperty("jdbc.driverClassName")));
- dataSource.setUrl(Preconditions.checkNotNull(env.getProperty("jdbc.url")));
- dataSource.setUsername(Preconditions.checkNotNull(env.getProperty("jdbc.user")));
- dataSource.setPassword(Preconditions.checkNotNull(env.getProperty("jdbc.pass")));
-
- return dataSource;
- }
-
- @Bean
- public PlatformTransactionManager transactionManager(final EntityManagerFactory emf) {
- final JpaTransactionManager transactionManager = new JpaTransactionManager();
- transactionManager.setEntityManagerFactory(emf);
- return transactionManager;
- }
-
- @Bean
- public PersistenceExceptionTranslationPostProcessor exceptionTranslation() {
- return new PersistenceExceptionTranslationPostProcessor();
- }
-
- final Properties additionalProperties() {
- final Properties hibernateProperties = new Properties();
- hibernateProperties.setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto"));
- hibernateProperties.setProperty("hibernate.dialect", env.getProperty("hibernate.dialect"));
- hibernateProperties.setProperty("hibernate.cache.use_second_level_cache", env.getProperty("hibernate.cache.use_second_level_cache"));
- hibernateProperties.setProperty("hibernate.cache.use_query_cache", env.getProperty("hibernate.cache.use_query_cache"));
- // hibernateProperties.setProperty("hibernate.globally_quoted_identifiers", "true");
- return hibernateProperties;
- }
-
- @Bean
- public MyUserDAO myUserDAO() {
- final MyUserDAO myUserDAO = new MyUserDAO();
- return myUserDAO;
- }
-}
\ No newline at end of file
diff --git a/spring-userservice/src/main/java/org/baeldung/custom/config/SecSecurityConfig.java b/spring-userservice/src/main/java/org/baeldung/custom/config/SecSecurityConfig.java
deleted file mode 100644
index 44df02980f..0000000000
--- a/spring-userservice/src/main/java/org/baeldung/custom/config/SecSecurityConfig.java
+++ /dev/null
@@ -1,75 +0,0 @@
-package org.baeldung.custom.config;
-
-import org.baeldung.security.MyUserDetailsService;
-import org.baeldung.user.service.MyUserService;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.Profile;
-import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
-import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
-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.crypto.bcrypt.BCryptPasswordEncoder;
-import org.springframework.security.crypto.password.PasswordEncoder;
-
-@Configuration
-@EnableWebSecurity
-@Profile("!https")
-public class SecSecurityConfig extends WebSecurityConfigurerAdapter {
-
- public SecSecurityConfig() {
- super();
- }
-
- @Override
- protected void configure(final AuthenticationManagerBuilder auth) throws Exception {
- // @formatter:off
- auth.authenticationProvider(authenticationProvider());
- // @formatter:on
- }
-
- @Override
- protected void configure(final HttpSecurity http) throws Exception {
- // @formatter:off
- http
- .csrf().disable()
- .authorizeRequests()
- .antMatchers("/*").permitAll()
- .and()
- .formLogin()
- .loginPage("/login")
- .loginProcessingUrl("/login")
- .defaultSuccessUrl("/",true)
- .failureUrl("/login?error=true")
- .and()
- .logout()
- .logoutUrl("/logout")
- .deleteCookies("JSESSIONID")
- .logoutSuccessUrl("/");
- // @formatter:on
- }
-
- @Bean
- public DaoAuthenticationProvider authenticationProvider() {
- final DaoAuthenticationProvider authProvider = new DaoAuthenticationProvider();
- authProvider.setUserDetailsService(myUserDetailsService());
- authProvider.setPasswordEncoder(encoder());
- return authProvider;
- }
-
- @Bean
- public PasswordEncoder encoder() {
- return new BCryptPasswordEncoder(11);
- }
-
- @Bean
- public MyUserDetailsService myUserDetailsService() {
- return new MyUserDetailsService();
- }
-
- @Bean
- public MyUserService myUserService() {
- return new MyUserService();
- }
-}
diff --git a/spring-userservice/src/main/java/org/baeldung/persistence/model/MyUser.java b/spring-userservice/src/main/java/org/baeldung/persistence/model/MyUser.java
deleted file mode 100644
index 804d391641..0000000000
--- a/spring-userservice/src/main/java/org/baeldung/persistence/model/MyUser.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package org.baeldung.persistence.model;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.Table;
-
-@Entity
-@Table(schema = "spring_custom_user_service")
-public class MyUser {
-
- @Id
- @GeneratedValue(strategy = GenerationType.AUTO)
- private int id;
-
- @Column(unique = true, nullable = false)
- private String username;
-
- @Column(nullable = false)
- private String password;
-
- public MyUser() {
- }
-
- public int getId() {
- return id;
- }
-
- public void setId(final int id) {
- this.id = id;
- }
-
- public String getUsername() {
- return username;
- }
-
- public void setUsername(final String username) {
- this.username = username;
- }
-
- public String getPassword() {
- return password;
- }
-
- public void setPassword(final String password) {
- this.password = password;
- }
-}
diff --git a/spring-userservice/src/main/java/org/baeldung/security/MyUserDetailsService.java b/spring-userservice/src/main/java/org/baeldung/security/MyUserDetailsService.java
deleted file mode 100644
index fe97984af8..0000000000
--- a/spring-userservice/src/main/java/org/baeldung/security/MyUserDetailsService.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package org.baeldung.security;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-
-import org.baeldung.persistence.model.MyUser;
-import org.baeldung.user.dao.MyUserDAO;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.security.core.GrantedAuthority;
-import org.springframework.security.core.authority.SimpleGrantedAuthority;
-import org.springframework.security.core.userdetails.User;
-import org.springframework.security.core.userdetails.UserDetails;
-import org.springframework.security.core.userdetails.UserDetailsService;
-import org.springframework.security.core.userdetails.UsernameNotFoundException;
-import org.springframework.stereotype.Service;
-
-@Service("userDetailsService")
-public class MyUserDetailsService implements UserDetailsService {
-
- @Autowired
- MyUserDAO myUserDAO;
-
- @Override
- public UserDetails loadUserByUsername(final String username) throws UsernameNotFoundException {
- final MyUser user = myUserDAO.findByUsername(username);
-
- if (user == null) {
- throw new UsernameNotFoundException("No user found with username: " + username);
- }
- return new User(user.getUsername(), user.getPassword(), Arrays.asList(new SimpleGrantedAuthority("ROLE_USER")));
-
- }
-
-}
diff --git a/spring-userservice/src/main/java/org/baeldung/security/UserController.java b/spring-userservice/src/main/java/org/baeldung/security/UserController.java
deleted file mode 100644
index a4c15f7942..0000000000
--- a/spring-userservice/src/main/java/org/baeldung/security/UserController.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package org.baeldung.security;
-
-import javax.annotation.Resource;
-
-import org.baeldung.user.service.MyUserService;
-import org.baeldung.web.MyUserDto;
-import org.springframework.security.core.Authentication;
-import org.springframework.security.core.context.SecurityContextHolder;
-import org.springframework.stereotype.Controller;
-import org.springframework.ui.Model;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-
-@Controller
-public class UserController {
-
- @Resource
- MyUserService myUserService;
-
- @RequestMapping(value = "/register", method = RequestMethod.POST)
- public String registerUserAccount(final MyUserDto accountDto, final Model model) {
- final Authentication auth = SecurityContextHolder.getContext().getAuthentication();
- model.addAttribute("name", auth.getName());
- try {
- myUserService.registerNewUserAccount(accountDto);
- model.addAttribute("message", "Registration successful");
- return "index";
- } catch (final Exception exc) {
- model.addAttribute("message", "Registration failed");
-
- return "index";
- }
- }
-
- @RequestMapping(value = "/", method = RequestMethod.GET)
- public String getHomepage(final Model model) {
- final Authentication auth = SecurityContextHolder.getContext().getAuthentication();
- model.addAttribute("name", auth.getName());
- return "index";
- }
-
- @RequestMapping(value = "/register", method = RequestMethod.GET)
- public String getRegister() {
- return "register";
- }
-
- @RequestMapping(value = "/login", method = RequestMethod.GET)
- public String getLogin() {
- return "login";
- }
-}
diff --git a/spring-userservice/src/main/java/org/baeldung/user/dao/MyUserDAO.java b/spring-userservice/src/main/java/org/baeldung/user/dao/MyUserDAO.java
deleted file mode 100644
index 834941b68b..0000000000
--- a/spring-userservice/src/main/java/org/baeldung/user/dao/MyUserDAO.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package org.baeldung.user.dao;
-
-import java.util.List;
-
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceContext;
-import javax.persistence.Query;
-
-import org.baeldung.persistence.model.MyUser;
-import org.springframework.stereotype.Repository;
-
-@Repository
-public class MyUserDAO {
-
- @PersistenceContext
- private EntityManager entityManager;
-
- public MyUser findByUsername(final String username) {
- final Query query = entityManager.createQuery("from MyUser where username=:username", MyUser.class);
- query.setParameter("username", username);
- final List result = query.getResultList();
- if (result != null && result.size() > 0) {
- return result.get(0);
- } else
- return null;
- }
-
- public MyUser save(final MyUser user) {
- entityManager.persist(user);
- return user;
- }
-
- public void removeUserByUsername(String username) {
- final Query query = entityManager.createQuery("delete from MyUser where username=:username");
- query.setParameter("username", username);
- query.executeUpdate();
- }
-
- public EntityManager getEntityManager() {
- return entityManager;
- }
-
- public void setEntityManager(final EntityManager entityManager) {
- this.entityManager = entityManager;
- }
-}
diff --git a/spring-userservice/src/main/java/org/baeldung/user/service/MyUserService.java b/spring-userservice/src/main/java/org/baeldung/user/service/MyUserService.java
deleted file mode 100644
index 2ab44752c0..0000000000
--- a/spring-userservice/src/main/java/org/baeldung/user/service/MyUserService.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package org.baeldung.user.service;
-
-import org.baeldung.persistence.model.MyUser;
-import org.baeldung.user.dao.MyUserDAO;
-import org.baeldung.web.MyUserDto;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.security.crypto.password.PasswordEncoder;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
-@Service
-@Transactional
-public class MyUserService {
-
- @Autowired
- private PasswordEncoder passwordEncoder;
-
- @Autowired
- MyUserDAO myUserDAO;
-
- public MyUser registerNewUserAccount(final MyUserDto accountDto) throws Exception {
- if (usernameExists(accountDto.getUsername())) {
- throw new Exception("There is an account with that username: " + accountDto.getUsername());
- }
- final MyUser user = new MyUser();
-
- user.setUsername(accountDto.getUsername());
- user.setPassword(passwordEncoder.encode(accountDto.getPassword()));
- return myUserDAO.save(user);
- }
-
- public MyUser getUserByUsername(final String username) {
- final MyUser user = myUserDAO.findByUsername(username);
- return user;
- }
-
- public void removeUserByUsername(String username) {
- myUserDAO.removeUserByUsername(username);
- }
-
- private boolean usernameExists(final String username) {
- final MyUser user = myUserDAO.findByUsername(username);
- if (user != null) {
- return true;
- }
- return false;
- }
-
-}
diff --git a/spring-userservice/src/main/java/org/baeldung/web/MyUserDto.java b/spring-userservice/src/main/java/org/baeldung/web/MyUserDto.java
deleted file mode 100644
index 60a6848ea4..0000000000
--- a/spring-userservice/src/main/java/org/baeldung/web/MyUserDto.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package org.baeldung.web;
-
-import javax.validation.constraints.NotNull;
-import javax.validation.constraints.Size;
-
-public class MyUserDto {
- @NotNull
- @Size(min = 1)
- private String username;
-
- private String password;
-
- public String getUsername() {
- return username;
- }
-
- public void setUsername(final String username) {
- this.username = username;
- }
-
- public String getPassword() {
- return password;
- }
-
- public void setPassword(final String password) {
- this.password = password;
- }
-
-}
diff --git a/spring-userservice/src/main/resources/logback.xml b/spring-userservice/src/main/resources/logback.xml
deleted file mode 100644
index 7d900d8ea8..0000000000
--- a/spring-userservice/src/main/resources/logback.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
- %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/spring-userservice/src/main/resources/persistence-derby.properties b/spring-userservice/src/main/resources/persistence-derby.properties
deleted file mode 100644
index b76c5de12f..0000000000
--- a/spring-userservice/src/main/resources/persistence-derby.properties
+++ /dev/null
@@ -1,12 +0,0 @@
-# jdbc.X
-jdbc.driverClassName=org.apache.derby.jdbc.EmbeddedDriver
-jdbc.url=jdbc:derby:memory:spring_custom_user_service;create=true
-jdbc.user=tutorialuser
-jdbc.pass=tutorialpass
-
-# hibernate.X
-hibernate.dialect=org.hibernate.dialect.DerbyDialect
-hibernate.show_sql=false
-hibernate.hbm2ddl.auto=update
-hibernate.cache.use_second_level_cache=false
-hibernate.cache.use_query_cache=false
\ No newline at end of file
diff --git a/spring-userservice/src/main/webapp/META-INF/MANIFEST.MF b/spring-userservice/src/main/webapp/META-INF/MANIFEST.MF
deleted file mode 100644
index 254272e1c0..0000000000
--- a/spring-userservice/src/main/webapp/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,3 +0,0 @@
-Manifest-Version: 1.0
-Class-Path:
-
diff --git a/spring-userservice/src/main/webapp/WEB-INF/mvc-dispatcher-servlet.xml b/spring-userservice/src/main/webapp/WEB-INF/mvc-dispatcher-servlet.xml
deleted file mode 100644
index 48ef8a8c43..0000000000
--- a/spring-userservice/src/main/webapp/WEB-INF/mvc-dispatcher-servlet.xml
+++ /dev/null
@@ -1,88 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- /WEB-INF/views/
-
-
- .jsp
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ${hibernate.hbm2ddl.auto}
- ${hibernate.dialect}
- ${hibernate.cache.use_second_level_cache}
- ${hibernate.cache.use_query_cache}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/spring-userservice/src/main/webapp/WEB-INF/views/index.jsp b/spring-userservice/src/main/webapp/WEB-INF/views/index.jsp
deleted file mode 100644
index 0c89257cd2..0000000000
--- a/spring-userservice/src/main/webapp/WEB-INF/views/index.jsp
+++ /dev/null
@@ -1,35 +0,0 @@
-<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
- pageEncoding="ISO-8859-1"%>
-<%@ taglib prefix="c"
- uri="http://java.sun.com/jsp/jstl/core" %>
-<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
-
-
-
-
-
-Welcome!
-
-
-
-
-
-
-
-Register
-
-
-Login
-
-
-${message }
-
-
-Hello, ${name }!
-
-
-Logout
-
-
-
-
\ No newline at end of file
diff --git a/spring-userservice/src/main/webapp/WEB-INF/views/login.jsp b/spring-userservice/src/main/webapp/WEB-INF/views/login.jsp
deleted file mode 100644
index 29431f426d..0000000000
--- a/spring-userservice/src/main/webapp/WEB-INF/views/login.jsp
+++ /dev/null
@@ -1,29 +0,0 @@
-<%@ taglib prefix="c"
- uri="http://java.sun.com/jsp/jstl/core" %>
-
-
-
-
-
- Login
-
-
- Username or password invalid!
-
-
\ No newline at end of file
diff --git a/spring-userservice/src/main/webapp/WEB-INF/views/register.jsp b/spring-userservice/src/main/webapp/WEB-INF/views/register.jsp
deleted file mode 100644
index e6e9d373a0..0000000000
--- a/spring-userservice/src/main/webapp/WEB-INF/views/register.jsp
+++ /dev/null
@@ -1,23 +0,0 @@
-<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
- pageEncoding="ISO-8859-1"%>
-<%@ taglib prefix="c"
- uri="http://java.sun.com/jsp/jstl/core" %>
-
-
-
-
-Welcome!
-
-
-
-
-
-Register here:
-
-
-
-
\ No newline at end of file
diff --git a/spring-userservice/src/main/webapp/WEB-INF/web.xml b/spring-userservice/src/main/webapp/WEB-INF/web.xml
deleted file mode 100644
index b526774179..0000000000
--- a/spring-userservice/src/main/webapp/WEB-INF/web.xml
+++ /dev/null
@@ -1,51 +0,0 @@
-
-
-
- Spring MVC Application
-
-
-
-
-
- mvc-dispatcher
- org.springframework.web.servlet.DispatcherServlet
- 1
-
-
- mvc-dispatcher
- /
-
-
-
-
- springSecurityFilterChain
- org.springframework.web.filter.DelegatingFilterProxy
-
-
- springSecurityFilterChain
- /*
-
-
-
- index.jsp
-
-
-
\ No newline at end of file
diff --git a/spring-userservice/src/test/java/org/baeldung/SpringContextIntegrationTest.java b/spring-userservice/src/test/java/org/baeldung/SpringContextIntegrationTest.java
deleted file mode 100644
index 825b89eb10..0000000000
--- a/spring-userservice/src/test/java/org/baeldung/SpringContextIntegrationTest.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package org.baeldung;
-
-import org.baeldung.custom.config.MvcConfig;
-import org.baeldung.custom.config.PersistenceDerbyJPAConfig;
-import org.baeldung.custom.config.SecSecurityConfig;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.junit4.SpringRunner;
-
-@RunWith(SpringRunner.class)
-@SpringBootTest(classes = { MvcConfig.class, PersistenceDerbyJPAConfig.class, SecSecurityConfig.class })
-public class SpringContextIntegrationTest {
-
- @Test
- public void whenSpringContextIsBootstrapped_thenNoExceptions() {
- }
-}
diff --git a/spring-userservice/src/test/java/org/baeldung/userservice/CustomUserDetailsServiceIntegrationTest.java b/spring-userservice/src/test/java/org/baeldung/userservice/CustomUserDetailsServiceIntegrationTest.java
deleted file mode 100644
index 1cd38228b8..0000000000
--- a/spring-userservice/src/test/java/org/baeldung/userservice/CustomUserDetailsServiceIntegrationTest.java
+++ /dev/null
@@ -1,82 +0,0 @@
-package org.baeldung.userservice;
-
-import static org.junit.Assert.assertEquals;
-
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import org.baeldung.custom.config.MvcConfig;
-import org.baeldung.custom.config.PersistenceDerbyJPAConfig;
-import org.baeldung.custom.config.SecSecurityConfig;
-import org.baeldung.user.service.MyUserService;
-import org.baeldung.web.MyUserDto;
-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.security.authentication.AuthenticationProvider;
-import org.springframework.security.authentication.BadCredentialsException;
-import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
-import org.springframework.security.core.Authentication;
-import org.springframework.test.context.junit4.SpringRunner;
-import org.springframework.test.context.web.WebAppConfiguration;
-
-@RunWith(SpringRunner.class)
-@SpringBootTest(classes = { MvcConfig.class, PersistenceDerbyJPAConfig.class, SecSecurityConfig.class })
-@WebAppConfiguration
-public class CustomUserDetailsServiceIntegrationTest {
-
- private static final Logger LOG = Logger.getLogger("CustomUserDetailsServiceTest");
-
- public static final String USERNAME = "user";
- public static final String PASSWORD = "pass";
- public static final String USERNAME2 = "user2";
-
- @Autowired
- MyUserService myUserService;
-
- @Autowired
- AuthenticationProvider authenticationProvider;
-
- @Test
- public void givenExistingUser_whenAuthenticate_thenRetrieveFromDb() {
- try {
- MyUserDto userDTO = new MyUserDto();
- userDTO.setUsername(USERNAME);
- userDTO.setPassword(PASSWORD);
-
- myUserService.registerNewUserAccount(userDTO);
-
- UsernamePasswordAuthenticationToken auth = new UsernamePasswordAuthenticationToken(USERNAME, PASSWORD);
- Authentication authentication = authenticationProvider.authenticate(auth);
-
- assertEquals(authentication.getName(), USERNAME);
-
- } catch (Exception exc) {
- LOG.log(Level.SEVERE, "Error creating account");
- } finally {
- myUserService.removeUserByUsername(USERNAME);
- }
- }
-
- @Test(expected = BadCredentialsException.class)
- public void givenIncorrectUser_whenAuthenticate_thenBadCredentialsException() {
- try {
- MyUserDto userDTO = new MyUserDto();
- userDTO.setUsername(USERNAME);
- userDTO.setPassword(PASSWORD);
-
- try {
- myUserService.registerNewUserAccount(userDTO);
- } catch (Exception exc) {
- LOG.log(Level.SEVERE, "Error creating account");
- }
-
- UsernamePasswordAuthenticationToken auth = new UsernamePasswordAuthenticationToken(USERNAME2, PASSWORD);
- Authentication authentication = authenticationProvider.authenticate(auth);
- } finally {
- myUserService.removeUserByUsername(USERNAME);
- }
- }
-
-}