Introduction
Source Code
Install HTTP client Postman
Postman overview
Resource and Collection URIs
HTTP Methods: GET, POST, DELETE and PUT
HTTP Headers: Accept and Content Type
Introduction to Web Service Application Layers
A few suggestions
Download, Install and run MySQL Database on Local Computer
Downloading and Installing MySQL on MAC
Start MySQL Server and Login
Creating MySQL Database and a new User
Downloading and Installing MySQL Workbench
Connect to MySQL Database using MySQL WorkBench
MySQL WorkBench brief overview
Setup Development Environment
Install Java Platform (JDK)
Download and Install Spring Tool Suite(STS)
Getting Started. Creating a New Project.
Create new Spring Boot Project with Spring Tool Suite
Creating a new Spring project using Spring Boot Initializr
Quick Start
Create Users Rest Controller class
Adding Methods to Handle POST, GET, PUT, DELETE HTTP requests
Running Web Service Application
Adding MySQL Database Support
Update POM.XML file
Configure MySQL Database Access Details
Implementing User Sign up
Adding method to handle HTTP Post Request
Implementing the Create User Request Model class
Implementing Create User Response Model
Implementing the UserDto
Making use of UserRest and UserDto in RestController
Implementing Service class method
Implementing UserEntity class
Set Default Value for Email Verification Status field
Implementing UsersRepository class
Autowire UserRepository into Service class
Trying how the User Sign up works
Preventing Duplicate Entries with @Column(unique=true)
Check if user already exists
Generate User Public ID
Spring Security for User Sign-up
Adding Spring Security to our project
Encrypt User Password
Make the Sign-up Web Service Endpoint Public
Spring Security for User Sign-in
Implementing User Sign-in Request Model
Implementing Load User By Username
Implementing SecurityConstants class
Implementing Authentication Filter
Trying how user Sign-in works
Add public User ID to a Response Header
Customize User Authentication URL
Implementing Authorization Filter
Trying how User Authorization works
Making Your REST API Stateless
Reading Token Secret from a property file
Implementing Get User Details Web Service Endpoint
Get User Details Resource Method
Implement Service layer method
Update UserRepository
Trying the Get User Details API Call
Adding XML Support & JSON Support
Update POM.XML, Add XML & JSON Media Types
Getting Response in XML or JSON format
Exceptions Handling
Introduction
Implementing ErrorMessages enum
Implementing UserServiceException
Handle a Specific Exception
Return Custom Error Object Representation
Handle All Other Exceptions
Update User Details API Call
Update User Details Resource Method
Implementing Service Layer Method
Trying the Update User Details API Call
Delete User API Call
Delete User Resource Method
Implementing Service Layer Method
Trying the Delete User API Call
Pagination and Get Users API Call
The Get Users Request URL
The Get Users Resource Method
Get Users Service Layer Method
Trying the Get Users API Call
Deploying Your App
Running Your Web Services App without STS
Create Context Path to Your Web Service
Run Your App as a Java application
Generating WAR file
Install Apache Tomcat on Windows
Downloading Apache Tomcat
Starting and Stopping Apache Tomcat
Creating a new Apache Tomcat User
Deploying Your Web Service to Apache Tomcat
Deploying to Amazon Cloud. AWS EC2.
Startup Your Own Amazon EC2 Linux Server
Connect To Your Server via SSH
Update Server Software Packages and Update Java
Download & Install Apache Tomcat on AWS EC2 Linux Server
Configure Apache Tomcat Users
Download and Install MySQL Server on EC2 Linux Server
Create Database and Add Database User
Deploy Our Web Service App on Apache Tomcat
Sending HTTP Request to a WebService Deployed on a Remote Server
Introduction: @OneToOne, @OneToMany, @ManyToOne
Object Relationships: @OneToMany Relationship
Add List of Addresses to JSON Payload
Add List of Addresses to a UserDetailsRequestModel
Creating AddressDTO
A Better Way of Mapping DTO to an Entity and Entity to a DTO
Trying if Deep Objects Mapping Works
Create AddressEntity class
Add @OneToMany to UserEntity class
Generate Public Address Id
Updating Service class Java code
Trying How it Works: Creating a new User record
Include List of Addresses Into Response
Get List of Addresses Web Service Endpoint
Get List of Addresses Service Interface
Get List of Addresses Service Interface Implementation
Get List of Addresses Spring Data JPA Interface
Trying How the Get List of Addresses Works
API Call to Get a Single Address Details
HATEOAS
Introduction
Adding HATEOAS Support to Our Project
Adding Adding Links to a Get User Address API Call
Using the methodOn()
Adding Links to a Get Addresses API Call
Applying HAL Format
Implement Email Verification Feature with AWS SES (Simple Email Service)
Source Code
Introduction
Verify Email Address with Amazon SES
Moving Out of AWS SES Sandbox
Submit Support Ticket to Increate Sending Limits
Create AWS IAM Access Credentials
Creating Shared Credentials File
Add AWS Java SDK SES Maven Dependency
Spring Security. Make Email Verification a Public Web Service Endpoint.
The verifyEmailToken() RestController Method
The verifyEmailToken() Service Layer Function
The findUserByEmailVerificationToken() Data Layer Function
Checking if Email Verification Token Has Expired
Generate and Save the Email Verification Token
Prevent Users with Unverified Email Address to Login
Trying How it works
Create a new Web Project
Download Apache Tomcat and Add to Spring STS
Creating Email Verification Service Web Page
Reading JavaScript URL Request Parameters
The verifyToken() AJAX HTTP Get Request
Deploying REST API and Email Verification Service to a Local Tomcat
Trying Email Verification Feature on Local Server
Adding Code to Send Email
Deploying Email Verification to a Remote Amazon EC2 Linux Server
Trying Email Verification on Remote Server
Implementing Password Reset Feature
Introduction
Password Reset Request RestController Method
Password Reset Request Service Layer Method
Generating Password Reset Token
Create PasswordResetTokenEntity & Password Reset Repository
Update AmazonSES Class with Code that Sends Email
Make the /password-reset-request Public
Trying How Password Reset Request Works
Password Reset HTML Page: Add Input fields
Password Reset HTML Page: Add jQuery
Password Reset HTML Page: Add the saveNewPassword() function
Add Content Type HTTP Header
Password Reset RestController Method
Password Reset Service Layer Method
Making Password Rest URL Public
Deploying RESTful Web Service and the Verification Service App
Trying How Password Reset Works
Testing Service Layer Code with JUnit 5 & Mockito
Introduction to Testing with JUnit & Mockito
Test Cases Source Code and Test Libraries Dependency
Creating a new JUnit 5 Test Case
Mocking Objects with Mockito @Mock
JUnit 5 Assertions. Asserting Successful Method Execution.
JUnit 5. Expect an Exception with assertThrows()
The testCreateUser() method. Mocking Objects.
Testing the createUser() Service Method
The testCreateUser() method. Adding more code.
doNothing(). Exclude Integration Code from Unit Test.
Assert an Exception is thrown in the createUser() method
Testing Rest Controller Methods with JUnit 5
Create a New Test Case
Create Mock Objects and Configure Methods Behaviour
Asserting with assertNotNull, assertEquals and assertTrue
JUnit Integration Test. Testing JWT Tokens and UserId.
Create a new JUnit Integration Test Case
Test the Generate UserId Method
Test If JWT Token Has Not Expired
Test the Expired JWT Token
H2 In-Memory Database
What is H2 In-memory Database and Why Using It
H2 Database Console Preview
Adding Support for the H2 Database
Sign in to H2 In-Memory Database
Protect the H2 In-Memory Database with a Password
API Call to Create a New User and Preview User Details in an In-Memory Database
Testing RESTful Web Services with Rest Assured
Source code
Introduction
Creating a new maven project
Add support for Rest Assured and JUnit 5 to your project
Create User API Call: Creating a Test Method
Create User API Call: Setting Request URL, Context Path and a Port number
Create User API Call: Create HTTP Post Request and Validate Response
Create User API Call: Running a Test Case
Create User API Call: Verify JSON Array with a list of Addresses
User Login API Call: Create Test Class
User Login API Call: Create Test Method
User Login API Call: Run Test Method
JUnit Test Methods ordering with @FixMethodOrder
Get User Details API Call: Create Test method
Get User Details API Call: Validating List of Addresses
Get User Details API Call: Use the pathParam()
Get User Details API Call: Running Test Method
Update User Details API Call: Create Test Method & HTTP Request
Update User Details API Call: Validating HTTP Response
Delete User Details API Call: Create Test Method
Delete User Details API Call: Run Test Method
Using Native SQL Queries
Introduction. What If You Need to Run SQL Query?
Native SELECT SQL Query Example
JUnit Test to test Native SELECT SQL Query
Native SQL Query with Positional Parameters
Native SQL Query with Named Parameters
Log SQL Queries and Their Values in the Console
Using Advanced LIKE Expressions
Select Specific Columns from a Table
UPDATE SQL Query Example
Using Java Persistence Query Language(JPQL)
JPQL Introduction
JPQL Select SQL Query
JPQL Query to Select Specific Fields Only
JPQL Update SQL Query
Cross Origin AJAX HTTP Requests. CORS.
Do I Need To Enable CORS?
Send HTTP Request to Reproduce Cross Origin Issue
Enable Cross Origin Requests in Rest Controller
Global CORS configuration
Spring Security Configuration for CORS
My Contact Details
My Contact Details
Create Interactive Documentation for your REST API with Swagger
Introduction
Add Swagger Dependencies
Create Swagger Configuration File
Enable Swagger URLs and View JSON Documentation
View API Documentation In Swagger UI
Add Authorization Header
Add /login endpoint
Upading API Documentation Information
Web Service Endpoints Additional Information
Share Your API with Others
Share Swagger UI URL
Spring Security Roles and Authorities
Introduction to Roles and Authorities
Authentication vs Authorization
Database Tables Design
User Roles @ManyToMany Mapping for User Entity
Create RoleEntity
Role Authority @ManyToMany Mapping for the RoleEntity
Create AuthorityEntity
Create Role Repository
Create Authority Repository
Creating Initial Roles, Authorities and Admin User
Create InitialUsersSetup Class
Creating Authorities: READ, WRITE, DELETE
Creating Roles: ROLE_ADMIN, ROLE_USER
Create User with Admin Role
Create User Principal Class
Update Authentication and Authorization Filters
Configure HttpSecurity to Use the ADMIN Role
Configure HttpSecurity to Use the DELETE_AUTHORITY
hasAnyRole() and hasAnyAuthority()
Method Level Security Introduction
Enable Global Method Security
@Secured Annotation Example
@PreAuthorize Annotation Example
Accessing Principal Object and Method Argument
Trying How It Works
@PostAuthorize Annotation Example
Assign ROLE_USER to a Regular User