Class AuthenticatedPrincipalOAuth2AuthorizedClientRepository
- java.lang.Object
-
- org.springframework.security.oauth2.client.web.AuthenticatedPrincipalOAuth2AuthorizedClientRepository
-
- All Implemented Interfaces:
OAuth2AuthorizedClientRepository
public final class AuthenticatedPrincipalOAuth2AuthorizedClientRepository extends java.lang.Object implements OAuth2AuthorizedClientRepository
An implementation of anOAuth2AuthorizedClientRepositorythat delegates to the providedOAuth2AuthorizedClientServiceif the currentPrincipalis authenticated, otherwise, to the default (or provided)OAuth2AuthorizedClientRepositoryif the current request is unauthenticated (or anonymous). The defaultOAuth2AuthorizedClientRepositoryisHttpSessionOAuth2AuthorizedClientRepository.
-
-
Constructor Summary
Constructors Constructor Description AuthenticatedPrincipalOAuth2AuthorizedClientRepository(OAuth2AuthorizedClientService authorizedClientService)Constructs aAuthenticatedPrincipalOAuth2AuthorizedClientRepositoryusing the provided parameters.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T extends OAuth2AuthorizedClient>
TloadAuthorizedClient(java.lang.String clientRegistrationId, org.springframework.security.core.Authentication principal, javax.servlet.http.HttpServletRequest request)Returns theOAuth2AuthorizedClientassociated to the provided client registration identifier and End-UserAuthentication(Resource Owner) ornullif not available.voidremoveAuthorizedClient(java.lang.String clientRegistrationId, org.springframework.security.core.Authentication principal, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)Removes theOAuth2AuthorizedClientassociated to the provided client registration identifier and End-UserAuthentication(Resource Owner).voidsaveAuthorizedClient(OAuth2AuthorizedClient authorizedClient, org.springframework.security.core.Authentication principal, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)Saves theOAuth2AuthorizedClientassociating it to the provided End-UserAuthentication(Resource Owner).voidsetAnonymousAuthorizedClientRepository(OAuth2AuthorizedClientRepository anonymousAuthorizedClientRepository)Sets theOAuth2AuthorizedClientRepositoryused for requests that are unauthenticated (or anonymous).
-
-
-
Constructor Detail
-
AuthenticatedPrincipalOAuth2AuthorizedClientRepository
public AuthenticatedPrincipalOAuth2AuthorizedClientRepository(OAuth2AuthorizedClientService authorizedClientService)
Constructs aAuthenticatedPrincipalOAuth2AuthorizedClientRepositoryusing the provided parameters.- Parameters:
authorizedClientService- the authorized client service
-
-
Method Detail
-
setAnonymousAuthorizedClientRepository
public void setAnonymousAuthorizedClientRepository(OAuth2AuthorizedClientRepository anonymousAuthorizedClientRepository)
Sets theOAuth2AuthorizedClientRepositoryused for requests that are unauthenticated (or anonymous). The default isHttpSessionOAuth2AuthorizedClientRepository.- Parameters:
anonymousAuthorizedClientRepository- the repository used for requests that are unauthenticated (or anonymous)
-
loadAuthorizedClient
public <T extends OAuth2AuthorizedClient> T loadAuthorizedClient(java.lang.String clientRegistrationId, org.springframework.security.core.Authentication principal, javax.servlet.http.HttpServletRequest request)
Description copied from interface:OAuth2AuthorizedClientRepositoryReturns theOAuth2AuthorizedClientassociated to the provided client registration identifier and End-UserAuthentication(Resource Owner) ornullif not available.- Specified by:
loadAuthorizedClientin interfaceOAuth2AuthorizedClientRepository- Type Parameters:
T- a type of OAuth2AuthorizedClient- Parameters:
clientRegistrationId- the identifier for the client's registrationprincipal- the End-UserAuthentication(Resource Owner)request- theHttpServletRequest- Returns:
- the
OAuth2AuthorizedClientornullif not available
-
saveAuthorizedClient
public void saveAuthorizedClient(OAuth2AuthorizedClient authorizedClient, org.springframework.security.core.Authentication principal, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
Description copied from interface:OAuth2AuthorizedClientRepositorySaves theOAuth2AuthorizedClientassociating it to the provided End-UserAuthentication(Resource Owner).- Specified by:
saveAuthorizedClientin interfaceOAuth2AuthorizedClientRepository- Parameters:
authorizedClient- the authorized clientprincipal- the End-UserAuthentication(Resource Owner)request- theHttpServletRequestresponse- theHttpServletResponse
-
removeAuthorizedClient
public void removeAuthorizedClient(java.lang.String clientRegistrationId, org.springframework.security.core.Authentication principal, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)Description copied from interface:OAuth2AuthorizedClientRepositoryRemoves theOAuth2AuthorizedClientassociated to the provided client registration identifier and End-UserAuthentication(Resource Owner).- Specified by:
removeAuthorizedClientin interfaceOAuth2AuthorizedClientRepository- Parameters:
clientRegistrationId- the identifier for the client's registrationprincipal- the End-UserAuthentication(Resource Owner)request- theHttpServletRequestresponse- theHttpServletResponse
-
-