RESTful Web Services, Java, Spring Boot, Spring MVC and JPA

RESTful Web Services, Java, Spring Boot, Spring MVC and JPA

English | MP4 | AVC 1280×720 | AAC 44KHz 2ch | 23h 22m | 7.47 GB

Implement API calls: Sign-up, sign-in, email verification, password reset, update, delete. Deploy to Amazon AWS Cloud.

This is a very practical video course aimed at beginner Java developers to help them build their very first RESTful Web Service application with Java, Spring MVC, Spring Boot and Spring Data JPA to implement features like:

  • User sign-up and User sign-in,
  • Email verification,
  • Password Reset,
  • Get user details API call,
  • Get list of users API call and implement Pagination,
  • Update user details and Delete user details API calls,
  • Learn to secure Web Service endpoints with Spring Security,
  • Learn to use Amazon AWS Simple Email Service(SES) to send and request to confirm user email address,
    and learn to generate and include the JSON Web Token in HTTP Request.

Students will learn how to use Postman HTTP client software to send: HTTP POST, GET, DELETE and PUT requests, as well as how to set needed HTTP Headers. We will also cover how to:

  • Send data to your RESTful WebService via HTTP Body and,
  • How to pass data via URL Query String and as a Path parameter,
  • How to enable your RESTful Web Service to respond to Cross Origin AJAX HTTP Requests.

You will also learn how to make your RESTful Web Service accept and respond back with JSON or XML media type.

This video course you will learn how to:

  • Download and install Spring Tool Suite(STS),
  • Download and install MySQL server and MySQL Workbench GUI,
  • Download and run Apache Tomcat,
  • Add a specific Apache Tomcat Version to your Spring Tool Suite,
  • User Maven to build and run your project as well as package it into a deployable WAR file,
  • You will also learn how to run your Web Service as a stand along Java application with build-in Tomcat,
  • Deploy your RESTful Web Service to Apache Tomcat as well as,
  • Start up your own Amazon AWS EC2 Service in Amazon Cloud, install Java, MySQL, Tomcat and deploy RESTful Web Service to your very own cloud server.

This video course also covers the H2 in-memory database and teaches how to build RESTful Web Service that stores data in a database without a need to install MySQL or any other database server. You will also learn how to use H2 console to preview data stored in an in-memory database tables or in a MySQL database server.

When it comes to storing data in a database you will learn how to use Spring Data JPA Query Methods as well as Native SQL Queries.

You will also learn how to use JUnit 5 to test your code and how to use one of the most popular test frameworks called Rest Assured to test RESTful Web Service endpoints of your REST Api.

What you’ll learn

  • Build a RESTful Web Service with Spring MVC and Spring Boot
  • Learn how to implement User Sign-in functionality
  • Learn how to implement User Sign-up functionality
  • Protect RESTful Web Service with Spring Security Framework
  • Learn how to implement Token-Based Authentication
  • Implement Password Reset and Email Verification features
  • Use Spring Data JPA Query Methods
  • Use Spring Data JPA Native SQL Queries
  • Download and Install MySQL Server on Mac
  • Download and Install MySQL Workbench
  • Download and Install Spring Tool Suite
  • Create new project using Spring Tool Suite and Spring Initializer
  • Download, run and stop Apache Tomcat
  • Deploy RESTful Web Service application to Apache Tomcat
  • Run RESTful Web Service application as a stand along Java application
  • Build and run REST API with Maven
  • Use Postman HTTP client to send HTTP Request to a Web Service endpoints
  • Start up Amazon EC2 server
  • Install Java, MySQL and Apache Tomcat on Amazon AWS EC2 server
  • Deploy RESTful Web Service to Amazon AWS EC2 server
  • Use H2 in-memory database
  • Use H2 database console to preview data in memory database as well as in a stand along MySQL database server
  • Use JUnit 5 to test code
  • Use Rest Assured to test RESTful Web Service endpoint
Table of Contents

Introduction
1 Source Code
2 Install HTTP client Postman
3 Postman overview
4 Resource and Collection URIs
5 HTTP Methods GET, POST, DELETE and PUT
6 HTTP Headers Accept and Content Type
7 Introduction to Web Service Application Layers
8 A few suggestions

Download, Install and run MySQL Database on Local Computer
9 Downloading and Installing MySQL on MAC
10 Start MySQL Server and Login
11 Creating MySQL Database and a new User
12 Downloading and Installing MySQL Workbench
13 Connect to MySQL Database using MySQL WorkBench
14 MySQL WorkBench brief overview

Setup Development Environment
15 Install Java Platform (JDK)
16 Download and Install Spring Tool Suite(STS)

Getting Started. Creating a New Project
17 Create new Spring Boot Project with Spring Tool Suite
18 Creating a new Spring project using Spring Boot Initializr

Quick Start
19 Create Users Rest Controller class
20 Adding Methods to Handle POST, GET, PUT, DELETE HTTP requests
21 Running Web Service Application

Adding MySQL Database Support
22 Update POM.XML file
23 Configure MySQL Database Access Details

Implementing User Sign up
24 Adding method to handle HTTP Post Request
25 Implementing the Create User Request Model class
26 Implementing Create User Response Model
27 Implementing the UserDto
28 Making use of UserRest and UserDto in RestController
29 Implementing Service class method
30 Implementing UserEntity class
31 Set Default Value for Email Verification Status field
32 Implementing UsersRepository class
33 Autowire UserRepository into Service class
34 Trying how the User Sign up works
35 Preventing Duplicate Entries with @Column(unique=true)
36 Check if user already exists
37 Generate User Public ID

Spring Security for User Sign-up
38 Adding Spring Security to our project
39 Encrypt User Password
40 Make the Sign-up Web Service Endpoint Public

Spring Security for User Sign-in
41 Implementing User Sign-in Request Model
42 Implementing Load User By Username
43 Implementing SecurityConstants class
44 Implementing Authentication Filter
45 Trying how user Sign-in works
46 Add public User ID to a Response Header
47 Customize User Authentication URL
48 Implementing Authorization Filter
49 Trying how User Authorization works
50 Making Your REST API Stateless
51 Reading Token Secret from a property file

Implementing Get User Details Web Service Endpoint
52 Get User Details Resource Method
53 Implement Service layer method
54 Update UserRepository
55 Trying the Get User Details API Call

Adding XML Support & JSON Support
56 Update POM.XML
57 Responding with XML or JSON
58 Consuming XML or JSON

Exceptions Handling
59 Introduction
60 Implementing ErrorMessages enum
61 Implementing UserServiceException
62 Handle a Specific Exception
63 Return Custom Error Object Representation
64 Handle All Other Exceptions

Update User Details API Call
65 Update User Details Resource Method
66 Implementing Service Layer Method
67 Trying the Update User Details API Call

Delete User API Call
68 Delete User Resource Method
69 Implementing Service Layer Method
70 Trying the Delete User API Call

Pagination and Get Users API Call
71 The Get Users Request URL
72 The Get Users Resource Method
73 Get Users Service Layer Method
74 Trying the Get Users API Call

Deploying Your App
75 Running Your Web Services App without STS
76 Create Context Path to Your Web Service
77 Run Your App as a Java application
78 Generating WAR file
79 Install Apache Tomcat on Windows
80 Downloading Apache Tomcat on Mac
81 Starting and Stopping Apache Tomcat
82 Creating a new Apache Tomcat User
83 Deploying Your Web Service to Apache Tomcat

Deploying to Amazon Cloud. AWS EC2
84 Startup Your Own Amazon EC2 Linux Server
85 Connect To Your Server via SSH
86 Update Server Software Packages and Update Java
87 Download & Install Apache Tomcat on AWS EC2 Linux Server
88 Configure remote access to Manager app
89 Configure Apache Tomcat Users
90 Important note
91 Download and Install MySQL Server on EC2 Linux Server
92 Installing MySQL on AWS Linux 2 AMI
93 Install MariaDb Server on EC2 Linux 2 AMI
94 Create Database and Add Database User
95 Deploy Our Web Service App on Apache Tomcat
96 Sending HTTP Request to a WebService Deployed on a Remote Server

Object Relationships @OneToMany Relationship
97 Introduction @OneToOne, @OneToMany, @ManyToOne
98 Add List of Addresses to JSON Payload
99 Add List of Addresses to a UserDetailsRequestModel
100 Creating AddressDTO
101 A Better Way of Mapping DTO to an Entity and Entity to a DTO
102 Trying if Deep Objects Mapping Works
103 Create AddressEntity class
104 Add @OneToMany to UserEntity class
105 Generate Public Address Id
106 Updating Service class Java code
107 Trying How it Works Creating a new User record
108 Include List of Addresses Into Response
109 Get List of Addresses Web Service Endpoint
110 Get List of Addresses Service Interface
111 Get List of Addresses Service Interface Implementation
112 Get List of Addresses Spring Data JPA Interface
113 Trying How the Get List of Addresses Works
114 API Call to Get a Single Address Details

HATEOAS. Spring Boot v. 2.0.1
115 Important house keeping message
116 Introduction
117 Adding HATEOAS Support to Our Project
118 Adding Links to the AddressRest Model
119 Using the methodOn()
120 Adding Links to a Get Addresses API Call
121 Applying HAL Format

HATEOAS. Spring Boot v. 2.3.0.RELEASE
122 Introduction
123 Adding HATEOAS support to our project
124 Adding Links. Representation Model
125 Adding Links. Entity Model
126 Building links with methodOn()
127 Returning a collection of resources with CollectionModel
128 Adding links to embedded list of addresses

Implement Email Verification Feature with AWS SES (Simple Email Service)
129 Source Code
130 Introduction
131 Verify Email Address with Amazon SES
132 Moving Out of AWS SES Sandbox
133 Submit Support Ticket to Increate Sending Limits
134 Create AWS IAM Access Credentials
135 Creating Shared Credentials File
136 Add AWS Java SDK SES Maven Dependency
137 Spring Security. Make Email Verification a Public Web Service Endpoint
138 The verifyEmailToken() RestController Method
139 The verifyEmailToken() Service Layer Function
140 The findUserByEmailVerificationToken() Data Layer Function
141 Checking if Email Verification Token Has Expired
142 Generate and Save the Email Verification Token
143 Prevent Users with Unverified Email Address to Login
144 Trying How it works
145 Create a new Web Project
146 Download Apache Tomcat and Add to Spring STS
147 Creating Email Verification Service Web Page
148 Reading JavaScript URL Request Parameters
149 The verifyToken() AJAX HTTP Get Request
150 Deploying REST API and Email Verification Service to a Local Tomcat
151 Trying Email Verification Feature on Local Server
152 Adding Code to Send Email
153 Deploying Email Verification to a Remote Amazon EC2 Linux Server
154 Trying Email Verification on Remote Server

Implementing Password Reset Feature
155 Introduction
156 Password Reset Request RestController Method
157 Password Reset Request Service Layer Method
158 Generating Password Reset Token
159 Create PasswordResetTokenEntity & Password Reset Repository
160 Update AmazonSES Class with Code that Sends Email
161 Make the password-reset-request Public
162 Trying How Password Reset Request Works
163 Password Reset HTML Page Add Input fields
164 Password Reset HTML Page Add jQuery
165 Password Reset HTML Page Add the saveNewPassword() function
166 Add Content Type HTTP Header
167 Password Reset RestController Method
168 Password Reset Service Layer Method
169 Making Password Rest URL Public
170 Deploying RESTful Web Service and the Verification Service App
171 Trying How Password Reset Works

Testing Service Layer Code with JUnit 5 & Mockito
172 Introduction to Testing with JUnit & Mockito
173 Test Cases Source Code and Test Libraries Dependency
174 Creating a new JUnit 5 Test Case
175 Mocking Objects with Mockito @Mock
176 JUnit 5 Assertions. Asserting Successful Method Execution
177 JUnit 5. Expect an Exception with assertThrows()
178 The testCreateUser() method. Mocking Objects
179 Testing the createUser() Service Method
180 The testCreateUser() method. Adding more code
181 doNothing(). Exclude Integration Code from Unit Test
182 Assert an Exception is thrown in the createUser() method

Testing Rest Controller Methods with JUnit 5
183 Create a New Test Case
184 Create Mock Objects and Configure Methods Behaviour
185 Asserting with assertNotNull, assertEquals and assertTrue

JUnit Integration Test. Testing JWT Tokens and UserId
186 Create a new JUnit Integration Test Case
187 Test the Generate UserId Method
188 Test If JWT Token Has Not Expired
189 Test the Expired JWT Token

H2 In-Memory Database
190 What is H2 In-memory Database and Why Using It
191 H2 Database Console Preview
192 Adding Support for the H2 Database
193 Sign in to H2 In-Memory Database
194 Protect the H2 In-Memory Database with a Password
195 API Call to Create a New User and Preview User Details in an In-Memory Database

Testing RESTful Web Services with Rest Assured
196 Source code
197 Introduction
198 Creating a new maven project
199 Add support for Rest Assured and JUnit 5 to your project
200 Create User API Call Creating a Test Method
201 Create User API Call Setting Request URL, Context Path and a Port number
202 Create User API Call Create HTTP Post Request and Validate Response
203 Create User API Call Running a Test Case
204 Create User API Call Verify JSON Array with a list of Addresses
205 User Login API Call Create Test Class
206 User Login API Call Create Test Method
207 User Login API Call Run Test Method
208 JUnit Test Methods ordering with @FixMethodOrder
209 Get User Details API Call Create Test method
210 Get User Details API Call Validating List of Addresses
211 Get User Details API Call Use the pathParam()
212 Get User Details API Call Running Test Method
213 Update User Details API Call Create Test Method & HTTP Request
214 Update User Details API Call Validating HTTP Response
215 Delete User Details API Call Create Test Method
216 Delete User Details API Call Run Test Method

Using Native SQL Queries
217 Introduction. What If You Need to Run SQL Query
218 Native SELECT SQL Query Example
219 JUnit Test to test Native SELECT SQL Query
220 Native SQL Query with Positional Parameters
221 Native SQL Query with Named Parameters
222 Log SQL Queries and Their Values in the Console
223 Using Advanced LIKE Expressions
224 Select Specific Columns from a Table
225 UPDATE SQL Query Example

Using Java Persistence Query Language(JPQL)
226 JPQL Introduction
227 JPQL Select SQL Query
228 JPQL Query to Select Specific Fields Only
229 JPQL Update SQL Query

Cross Origin AJAX HTTP Requests. CORS
230 Do I Need To Enable CORS
231 Send HTTP Request to Reproduce Cross Origin Issue
232 Enable Cross Origin Requests in Rest Controller
233 Global CORS configuration
234 Spring Security Configuration for CORS

My Contact Details
235 My Contact Details

Swagger. Creating Interactive Documentation
236 Introduction
237 Add Swagger Dependencies
238 Create Swagger Configuration File
239 Enable Swagger URLs and View JSON Documentation
240 View API Documentation In Swagger UI
241 Add Authorization Header
242 Add login endpoint
243 Upading API Documentation Information
244 Web Service Endpoints Additional Information
245 Share Your API with Others
246 Share Swagger UI URL
247 Update Version 3.0 updates

Spring Security Roles and Authorities
248 Introduction to Roles and Authorities
249 Authentication vs Authorization
250 Database Tables Design
251 User Roles @ManyToMany Mapping for User Entity
252 Create RoleEntity
253 Role Authority @ManyToMany Mapping for the RoleEntity
254 Create AuthorityEntity
255 Create Role Repository
256 Create Authority Repository
257 Creating Initial Roles, Authorities and Admin User
258 Create InitialUsersSetup Class
259 Creating Authorities READ, WRITE, DELETE
260 Creating Roles ROLE ADMIN, ROLE USER
261 Create User with Admin Role
262 Create User Principal Class
263 Update Authentication and Authorization Filters
264 Configure HttpSecurity to Use the ADMIN Role
265 Configure HttpSecurity to Use the DELETE AUTHORITY
266 hasAnyRole() and hasAnyAuthority()
267 Method Level Security Introduction
268 Enable Global Method Security
269 @Secured Annotation Example
270 @PreAuthorize Annotation Example
271 Accessing Principal Object and Method Argument
272 Trying How It Works
273 @PostAuthorize Annotation Example
274 Assign ROLE USER to a Regular User

Next steps
275 What’s next

Homepage