1.

Explain what is AuthenticationManager in Spring security.

Answer»

A Spring Security component called AuthenticationManager tells "How authentication will happen". Because the how part of this question depends on which authentication provider we are using for our application, an AuthenticationManager contains references to all the AuthenticationProviders. AuthenticationManager is the strategy INTERFACE for authentication, which has only one METHOD

public interface AuthenticationManager { Authentication authenticate(Authentication authentication) THROWS AuthenticationException; }

AuthenticationManagers can PERFORM one of three actions in their authenticate() method: 

  • If it can verify that the input represents a valid principal, it will RETURN an Authentication (normally authenticated=true).
  • If the input is believed to represent an invalid principal, it will throw an AuthenticationException.
  • If it is unable to decide, it will return null.


Discussion

No Comment Found