Book Image

Spring 5.0 Cookbook

By : Sherwin John C. Tragura
Book Image

Spring 5.0 Cookbook

By: Sherwin John C. Tragura

Overview of this book

The Spring framework has been the go-to framework for Java developers for quite some time. It enhances modularity, provides more readable code, and enables the developer to focus on developing the application while the underlying framework takes care of transaction APIs, remote APIs, JMX APIs, and JMS APIs. The upcoming version of the Spring Framework has a lot to offer, above and beyond the platform upgrade to Java 9, and this book will show you all you need to know to overcome common to advanced problems you might face. Each recipe will showcase some old and new issues and solutions, right from configuring Spring 5.0 container to testing its components. Most importantly, the book will highlight concurrent processes, asynchronous MVC and reactive programming using Reactor Core APIs. Aside from the core components, this book will also include integration of third-party technologies that are mostly needed in building enterprise applications. By the end of the book, the reader will not only be well versed with the essential concepts of Spring, but will also have mastered its latest features in a solution-oriented manner.
Table of Contents (20 chapters)
Title Page
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

Mapping sessions to channels and ports


In preparation for reactive and concurrent web programming in the later chapters, Tomcat 9.0 was installed in Chapter 1, Getting Started with Spring to use TLS to enable HTTPS. This recipe will showcase how Spring Security 4.2.2 manages all URL requests to run on secured HTTP protocols only.

Getting started

Open web project ch04 and create another security model restricting all URL requests to execute on top of the secured HTTP at port 8443.

How to do it...

After the initial setup and configuration, it is time to experiment with the Spring Security 4.2.2 module:

  1. Let us now disable the previous AppSecurityConfig model by applying comment symbols to its @Configuration and @EnableWebSecurity annotations:
//@Configuration 
//@EnableWebSecurity 
public class AppSecurityConfig extends  
  WebSecurityConfigurerAdapter { 
     // refer to sources    
} 

Note

The use of the @Order annotation can be another option instead of manually commenting the annotations in AppSecurityConfig...