Once we have IdentityStore implementation, we can use it in our application code for security. In Java EE 8, there is an API that can achieve this element of security—HttpAuthenticationMechanism. This can be used to secure servlets, and equally, to secure any frameworks based on them. HttpAuthenticationMechanism is used to validate the user identity information. HttpAuthenticationMechanism, together with the IdentityStore, enables the application to control the identity stores that it uses for authentication in a portable manner.
The HttpAuthenticationMechanism validates the request and checks the authentication status. It then uses the identity store to validate the identity information that it has received from the incoming request. After this, it passes the request information to the identity store. Based on the validation result, it either...