Class BearerTokenAuthenticationEntryPoint

java.lang.Object
org.springframework.security.oauth2.server.resource.web.BearerTokenAuthenticationEntryPoint
All Implemented Interfaces:
org.springframework.security.web.AuthenticationEntryPoint

public final class BearerTokenAuthenticationEntryPoint extends Object implements org.springframework.security.web.AuthenticationEntryPoint
An AuthenticationEntryPoint implementation used to commence authentication of protected resource requests using BearerTokenAuthenticationFilter.

Uses information provided by BearerTokenError to set HTTP response status code and populate WWW-Authenticate HTTP header.

Since:
5.1
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    commence(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.security.core.AuthenticationException authException)
    Collect error details from the provided parameters and format according to RFC 6750, specifically error, error_description, error_uri, and scope.
    void
    setRealmName(@Nullable String realmName)
    Set the default realm name to use in the bearer token error response
    void
    setResourceMetadataParameterResolver(Function<jakarta.servlet.http.HttpServletRequest, String> resourceMetadataParameterResolver)
    Set the resolver to compute the resource_metadata parameter from the request.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • BearerTokenAuthenticationEntryPoint

      public BearerTokenAuthenticationEntryPoint()
  • Method Details

    • commence

      public void commence(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.security.core.AuthenticationException authException)
      Collect error details from the provided parameters and format according to RFC 6750, specifically error, error_description, error_uri, and scope.
      Specified by:
      commence in interface org.springframework.security.web.AuthenticationEntryPoint
      Parameters:
      request - that resulted in an AuthenticationException
      response - so that the user agent can begin authentication
      authException - that caused the invocation
    • setRealmName

      public void setRealmName(@Nullable String realmName)
      Set the default realm name to use in the bearer token error response
      Parameters:
      realmName - the realm name, or null
    • setResourceMetadataParameterResolver

      public void setResourceMetadataParameterResolver(Function<jakarta.servlet.http.HttpServletRequest, String> resourceMetadataParameterResolver)
      Set the resolver to compute the resource_metadata parameter from the request.
      Parameters:
      resourceMetadataParameterResolver -
      Since:
      7.1