Hands-On Spring Security 5 for Reactive Applications by Tomcy John

Hands-On Spring Security 5 for Reactive Applications by Tomcy John

Author:Tomcy John
Language: eng
Format: epub
Tags: COM051280 - COMPUTERS / Programming Languages / Java, COM053000 - COMPUTERS / Security / General, COM005000 - COMPUTERS / Enterprise Applications / General
Publisher: Packt Publishing
Published: 2018-07-31T08:59:22+00:00


<build>

<plugins>

<plugin>

<groupId>org.eclipse.jetty</groupId>

<artifactId>jetty-maven-plugin</artifactId>

<version>9.4.10.v20180503</version>

</plugin>

</plugins>

</build>

We add Spring Framework, Spring Security, JSP/JSTL, and the logging framework (SLF4J and Logback) dependencies. We will be using an embedded jetty server (look at the build section) to run our application.

Setting up LoginModule

LoginModule is responsible for authenticating a user. We will be creating our own LoginModule named JaasLoginModule and then implementing the login method. Being a sample application, our login logic is quite trivial. The LoginModule interface has to be implemented for you to write your own custom login module.

Create a class, JaasLoginModule.java (which implements LoginModule), and implement all the methods. In this class, we will be focusing on two important methods. In the initialize method, we get all the necessary information, such as username/password/subject, that is stored as field variables to be used in our main login method:

// Gather information and then use this in the login method

@Override

public void initialize(Subject subject, CallbackHandler callbackHandler, Map<String,

?> sharedState, Map<String, ?> options) {

this.subject = subject;



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.