Class Oauth2SecurityConfiguration
- java.lang.Object
-
- org.drdeesw.commons.security.oauth2.client.registration.Oauth2SecurityConfiguration
-
public abstract class Oauth2SecurityConfiguration extends java.lang.ObjectThis is where to get the OAuth2 ClientRegistrationRepository.
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.StringCOINBASE_CLIENTprotected static java.lang.StringFACEBOOK_CLIENTprotected static java.lang.StringGITHUB_CLIENTprotected static java.lang.StringGOOGLE_CLIENTprotected static java.lang.StringOKTA_CLIENT
-
Constructor Summary
Constructors Modifier Constructor Description protectedOauth2SecurityConfiguration()Oauth2SecurityConfiguration(org.springframework.core.env.Environment env)For unit testing.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected org.springframework.security.oauth2.client.OAuth2AuthorizedClientServiceauthorizedClientService()protected org.springframework.security.oauth2.client.registration.ClientRegistrationRepositoryclientRegistrationRepository()Returns a new ClientRegistrationRepository based on the clients defined by the "security.oauth2.client.registration.clients" property.java.lang.StringgetAccessToken(javax.servlet.http.HttpServletRequest request)protected org.springframework.security.oauth2.client.registration.ClientRegistrationgetCustomClientRegistration(java.lang.String client, java.lang.String clientId, java.lang.String clientSecret, java.lang.String[] clientScopes)java.lang.StringgetPrefixedSessionBearerToken()Returns the bearer token with "Bearer " prefixed.java.lang.StringgetPrincipalId()Returns the principal ID of the user.java.lang.StringgetSessionBearerToken()Returns the session bearer token, if it exists, null otherwise.protected org.springframework.security.oauth2.client.registration.ClientRegistrationRepositorynewClientRegistrationRepository(java.util.List<org.springframework.security.oauth2.client.registration.ClientRegistration> registrations)Returns a new instance of ClientRegistrationRepository; defaults to InMemoryClientRegistrationRepositoryprotected org.springframework.security.oauth2.client.OAuth2AuthorizedClientServicenewOAuth2AuthorizedClientService(org.springframework.security.oauth2.client.registration.ClientRegistrationRepository clientRegistrationRepository)Returns a new instance of OAuth2AuthorizedClientService; defaults to InMemoryOAuth2AuthorizedClientService.
-
-
-
Field Detail
-
COINBASE_CLIENT
protected static final java.lang.String COINBASE_CLIENT
- See Also:
- Constant Field Values
-
FACEBOOK_CLIENT
protected static final java.lang.String FACEBOOK_CLIENT
- See Also:
- Constant Field Values
-
GITHUB_CLIENT
protected static final java.lang.String GITHUB_CLIENT
- See Also:
- Constant Field Values
-
GOOGLE_CLIENT
protected static final java.lang.String GOOGLE_CLIENT
- See Also:
- Constant Field Values
-
OKTA_CLIENT
protected static final java.lang.String OKTA_CLIENT
- See Also:
- Constant Field Values
-
-
Method Detail
-
authorizedClientService
@Bean protected org.springframework.security.oauth2.client.OAuth2AuthorizedClientService authorizedClientService()
- Returns:
-
clientRegistrationRepository
@Bean protected org.springframework.security.oauth2.client.registration.ClientRegistrationRepository clientRegistrationRepository()
Returns a new ClientRegistrationRepository based on the clients defined by the "security.oauth2.client.registration.clients" property.- Returns:
- a new ClientRegistrationRepository based on the clients defined by the "security.oauth2.client.registration.clients" property
-
getAccessToken
public java.lang.String getAccessToken(javax.servlet.http.HttpServletRequest request)
- Returns:
-
getCustomClientRegistration
protected org.springframework.security.oauth2.client.registration.ClientRegistration getCustomClientRegistration(java.lang.String client, java.lang.String clientId, java.lang.String clientSecret, java.lang.String[] clientScopes)- Parameters:
client-- Returns:
-
getPrincipalId
public java.lang.String getPrincipalId()
Returns the principal ID of the user.- Returns:
- the principal ID of the user
-
getPrefixedSessionBearerToken
public java.lang.String getPrefixedSessionBearerToken()
Returns the bearer token with "Bearer " prefixed.- Returns:
- the bearer token with "Bearer " prefixed
-
getSessionBearerToken
public java.lang.String getSessionBearerToken()
Returns the session bearer token, if it exists, null otherwise.- Returns:
- the session bearer token, if it exists, null otherwise
-
newClientRegistrationRepository
protected org.springframework.security.oauth2.client.registration.ClientRegistrationRepository newClientRegistrationRepository(java.util.List<org.springframework.security.oauth2.client.registration.ClientRegistration> registrations)
Returns a new instance of ClientRegistrationRepository; defaults to InMemoryClientRegistrationRepository- Parameters:
registrations-- Returns:
- a new instance of ClientRegistrationRepository; defaults to InMemoryClientRegistrationRepository
-
newOAuth2AuthorizedClientService
protected org.springframework.security.oauth2.client.OAuth2AuthorizedClientService newOAuth2AuthorizedClientService(org.springframework.security.oauth2.client.registration.ClientRegistrationRepository clientRegistrationRepository)
Returns a new instance of OAuth2AuthorizedClientService; defaults to InMemoryOAuth2AuthorizedClientService.- Parameters:
clientRegistrationRepository-- Returns:
- a new instance of OAuth2AuthorizedClientService; defaults to InMemoryOAuth2AuthorizedClientService
-
-