Class OAuth2ClientAuthenticationToken

java.lang.Object
org.springframework.security.authentication.AbstractAuthenticationToken
org.springframework.security.oauth2.server.authorization.authentication.OAuth2ClientAuthenticationToken
All Implemented Interfaces:
Serializable, Principal, Authentication, CredentialsContainer

@Transient public class OAuth2ClientAuthenticationToken extends AbstractAuthenticationToken
An Authentication implementation used for OAuth 2.0 Client Authentication.
Since:
7.0
See Also:
  • Constructor Details

    • OAuth2ClientAuthenticationToken

      public OAuth2ClientAuthenticationToken(String clientId, ClientAuthenticationMethod clientAuthenticationMethod, @Nullable Object credentials, @Nullable Map<String,Object> additionalParameters)
      Constructs an OAuth2ClientAuthenticationToken using the provided parameters.
      Parameters:
      clientId - the client identifier
      clientAuthenticationMethod - the authentication method used by the client
      credentials - the client credentials
      additionalParameters - the additional parameters
    • OAuth2ClientAuthenticationToken

      public OAuth2ClientAuthenticationToken(RegisteredClient registeredClient, ClientAuthenticationMethod clientAuthenticationMethod, @Nullable Object credentials)
      Constructs an OAuth2ClientAuthenticationToken using the provided parameters.
      Parameters:
      registeredClient - the authenticated registered client
      clientAuthenticationMethod - the authentication method used by the client
      credentials - the client credentials
  • Method Details

    • getPrincipal

      public Object getPrincipal()
      Description copied from interface: Authentication
      The identity of the principal being authenticated. In the case of an authentication request with username and password, this would be the username. Callers are expected to populate the principal for an authentication request.

      The AuthenticationManager implementation will often return an Authentication containing richer information as the principal for use by the application. Many of the authentication providers will create a UserDetails object as the principal.

      Returns:
      the Principal being authenticated or the authenticated principal after authentication.
    • getCredentials

      @Nullable public Object getCredentials()
      Description copied from interface: Authentication
      The credentials that prove the principal is correct. This is usually a password, but could be anything relevant to the AuthenticationManager. Callers are expected to populate the credentials.
      Returns:
      the credentials that prove the identity of the Principal
    • getRegisteredClient

      @Nullable public RegisteredClient getRegisteredClient()
      Returns the authenticated registered client, or null if not authenticated.
      Returns:
      the authenticated RegisteredClient, or null if not authenticated
    • getClientAuthenticationMethod

      public ClientAuthenticationMethod getClientAuthenticationMethod()
      Returns the authentication method used by the client.
      Returns:
      the ClientAuthenticationMethod used by the client
    • getAdditionalParameters

      public Map<String,Object> getAdditionalParameters()
      Returns the additional parameters.
      Returns:
      the additional parameters