-
Spring Cloud Eureka Service Discovery Client Server Example
In this tutorial we demonstrate how to create and configure a service discovery client server environment using Netflix Eureka. First, we use spring-cloud to create and configure a Service Discovery Registry Server. This server will listen to new nodes spinning up in our environment. Secondly, we create some Service Discovery Clients that will launch on multiple ports. The service discovery registry will automatically register these clients.
Date: 2019-08-10 View: 1354
-
Spring Boot Thymeleaf Configuration Example
This tutorial demonstrates how to configure Spring Boot and Thymeleaf. We are creating a simple Spring Boot Thymeleaf Example. In this example we configure Spring Boot using application.yml file and place the Thymeleaf templates in the src/main/resources/templates folder. We also utilise org.webjars to load static resources like bootstrap and jquery.
Date: 2019-08-10 View: 1351
-
Spring Boot + Spring Mobile Serve Content Based on Device
This tutorial shows how to use Spring Boot and Spring Mobile to serve content based on device type. We distinguish mobile, tablet and normal devices.
Date: 2019-08-10 View: 1377
-
Spring Boot Configure Tomcat SSL over HTTPS
This tutorial demonstrates how to use spring boot to configure embedded tomcat SSL over HTTPS. You can optionally configure multiple Tomcat Connectors to support both HTTP and HTTPS at the same time. Or we also show how to redirect HTTP traffic to HTTPS automatically. These last two optional configuration cannot be used simultaneously.
Date: 2019-08-10 View: 1451
-
Spring Boot + Spring Security + Thymeleaf Form Login Example
This tutorial demonstrates how to configure spring-boot, spring-security and thymeleaf with form-login. We secure our web application using spring security form-login. We create a reusable Thymeleaf layout which we can use to create our secured and unsecured pages. When a user accesses a protected resource with insufficient rights we redirect the user to an access-denied page. Finally we create a login page where the user is able to login to the application. And we create a logout link.
Date: 2019-08-10 View: 1375
-
Adding Static Resources (css, JavaScript, Images) to Thymeleaf
This tutorial demonstrates how to include static resources to Thymeleaf. We use Spring Boot to start our application. We are loading static resources from the class-path and from org.webjars. The static resources are located in the src/main/resources/static folder.
Date: 2019-08-10 View: 1559
-
Spring Security Basic Authentication Configuration Example
The following tutorial is about Spring Security Basic Authentication Configuration. We demonstrate this by configuring Spring Security using both Java and XML Configuration. We create a custom authentication entry point which we can use and customize to give the user a custom login error message. We finish with showing how to write some integration tests using Spring MockMvc and JUnit.
Date: 2019-08-10 View: 993
-
Spring Security Method Level Annotations Example
This tutorial demonstrates how to use Spring Security Method Level Annotations. We can use Spring Security to secure our service layer. We can restrict which roles are able to execute a method by annotating the method with any of spring security annotations or the standard java JSR-250 annotaitons.
Date: 2019-08-10 View: 934
-
Spring Boot + Spring Security + Hibernate Configuration Example
This tutorial demonstrates how to configure Spring Security Hibernate and Spring Boot. We secure a simple stateless web service using basic authentication. We configure Spring Security using Spring Java and/or XML Configuration. Finally, we write some JUnit Integration Tests with spring-test, h2 in-memory database and MockMvc.
Date: 2019-08-10 View: 1207
-
Spring Security User Registration with Hibernate and Thymeleaf
In this example we show how to create a user registration form with Spring Security, Hibernate and Thymeleaf. We validate the user registration fields with hibernate validator annotations and a custom field matching validator to validate if the email and/or password fields match.
Date: 2019-08-10 View: 3472
-
Spring Security Forgot Password Send Email Reset Password
In this tutorial we demonstrate how to use Spring Security, Spring Boot, Hibernate and Thymeleaf to program a password reset flow by sending the user an email address to verify the reset password procedure. When a user has forgot his password, he is able to request a password reset. The application will generate a unique PasswordResetToken and store it in the database. The user’ll receive an email with the unique token. When he clicks the link, the user is redirected to a page where he can change his password.
Date: 2019-08-10 View: 1360
-
Custom Password Constraint Validator Annotation Example
This tutorial demonstrates how to create a custom password validator annotation using custom password rules. You’ll be able to annotate your password field with a @ValidPassword. This’ll trigger the custom PasswordConstraintValidator which’ll enforce a server-side password policy.
Date: 2019-08-10 View: 1280
-
Integrate Google ReCaptcha Java Spring Web Application
This tutorial demonstrates how to integrate Google ReCaptcha into a Java Spring Web Application. reCAPTCHA is used to verify if the current computer is a human, preventing bots from automatically submitting forms. We integrated Google ReCaptcha using server side validation. We wrote a custom @ReCaptcha annotation which you can annotate your java fields. This’ll automatically handle the ReCaptcha server side validation process. At the bottom we also wrote some Unit and Integration tests using Mockito, spring-test and MockMvc.
Date: 2019-08-10 View: 1620
-
Field Matching Bean Validation Annotation Example
This tutorial demonstrates a Field Matching Bean Validation Annotation Example. When you are building forms you may come across a requirement to validate/compare if different fields inside a form are equal to another field in the same form like password and/or email fields. In this example we build a simple form where we have a password and a confirmPassword field. We need to make sure the user has entered the correct password twice before submitting the request.
Date: 2019-08-10 View: 1095
-
Spring Security In Memory Authentication Example
This tutorial demonstrates how to configure Spring Security to use In Memory Authentication. We can easily customize the Spring Security AuthenticationManager to use Spring Security in memory authentication and add multiple users with different attributes, authorities and roles. In this example we used HTTP Basic Authentication with stateless configuration for securing rest full web services. We also demonstrate how to create some Integration Tests using MockMvc.
Date: 2019-08-10 View: 981