Class OrcidLoginFilter

All Implemented Interfaces:
jakarta.servlet.Filter, Aware, BeanNameAware, DisposableBean, InitializingBean, ApplicationEventPublisherAware, EnvironmentAware, MessageSourceAware, EnvironmentCapable, ServletContextAware

public class OrcidLoginFilter extends StatelessLoginFilter
This class will filter ORCID requests and try and authenticate them. In this case, the actual authentication is performed by ORCID. After authentication succeeds, ORCID will send the authentication data to this filter in order for it to be processed by DSpace.
Author:
Luca Giamminonni (luca.giamminonni at 4science.it)
  • Constructor Details

  • Method Details

    • attemptAuthentication

      public Authentication attemptAuthentication(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse res) throws AuthenticationException
      Description copied from class: StatelessLoginFilter
      Attempt to authenticate the user by using Spring Security's AuthenticationManager. The AuthenticationManager will delegate this task to one or more AuthenticationProvider classes.

      For DSpace, our custom AuthenticationProvider is EPersonRestAuthenticationProvider, so that is the authenticate() method which is called below.

      Overrides:
      attemptAuthentication in class StatelessLoginFilter
      Parameters:
      req - current request
      res - current response
      Returns:
      a valid Spring Security Authentication object if authentication succeeds
      Throws:
      AuthenticationException - if authentication fails
      See Also:
    • successfulAuthentication

      protected void successfulAuthentication(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse res, jakarta.servlet.FilterChain chain, Authentication auth) throws IOException, jakarta.servlet.ServletException
      Description copied from class: StatelessLoginFilter
      If the above attemptAuthentication() call was successful (no authentication error was thrown), then this method will take the returned DSpaceAuthentication class (which includes all the data from the authenticated user) and add the authentication data to the response.

      For DSpace, this is calling our JWTTokenRestAuthenticationServiceImpl in order to create a JWT based on the authentication data & send that JWT back in the response.

      Overrides:
      successfulAuthentication in class StatelessLoginFilter
      Parameters:
      req - current request
      res - response
      chain - FilterChain
      auth - Authentication object containing info about user who had a successful authentication
      Throws:
      IOException
      jakarta.servlet.ServletException
      See Also:
    • unsuccessfulAuthentication

      protected void unsuccessfulAuthentication(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, AuthenticationException failed) throws IOException, jakarta.servlet.ServletException
      Description copied from class: StatelessLoginFilter
      If the above attemptAuthentication() call was unsuccessful, then ensure that the response is a 401 Unauthorized AND it includes a WWW-Authentication header. We use this header in DSpace to return all the enabled authentication options available to the UI (along with the path to the login URL for each option)
      Overrides:
      unsuccessfulAuthentication in class StatelessLoginFilter
      Parameters:
      request - current request
      response - current response
      failed - exception that was thrown by attemptAuthentication()
      Throws:
      IOException
      jakarta.servlet.ServletException