Package org.genesys.blocks.oauth.service
Class OAuthServiceImpl
java.lang.Object
org.genesys.blocks.oauth.service.OAuthServiceImpl
- All Implemented Interfaces:
OAuthClientService,org.springframework.beans.factory.InitializingBean,org.springframework.security.oauth2.server.authorization.client.RegisteredClientRepository
@Service
@Transactional(readOnly=true)
public class OAuthServiceImpl
extends Object
implements OAuthClientService, org.springframework.beans.factory.InitializingBean
The Class OAuthServiceImpl.
-
Field Summary
FieldsModifier and TypeFieldDescriptionorg.springframework.security.crypto.password.PasswordEncoderThe password encoder. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddClient(OAuthClient client) Register a new OAuth client.voidautocompleteClients(String term, int limit) Autocomplete OAuth clients by title.org.springframework.security.oauth2.server.authorization.client.RegisteredClientfindByClientId(String clientId) org.springframework.security.oauth2.server.authorization.client.RegisteredClientGets the client.booleanisClientActive(String registrationId) Check OAuthClient.active.booleanisOriginRegistered(String origin) Check if the origin is registered with one of the clientsList client details.org.springframework.data.domain.Page<OAuthClient>listClientDetails(com.querydsl.core.types.Predicate predicate, org.springframework.data.domain.Pageable pageable) List client details with filtering by predicate.org.springframework.data.domain.Page<OAuthClient>listClientDetails(org.springframework.data.domain.Pageable pageable) List client details.loadClientByClientId(String clientId) Load client byclientId.removeClient(OAuthClient client) Removes the client.final OAuthClientremoveSecret(OAuthClient oauthClient) Removes the Client secret.final StringresetSecret(OAuthClient oauthClient) Generates a new clientSecret.voidsave(org.springframework.security.oauth2.server.authorization.client.RegisteredClient registeredClient) final StringsetSecret(OAuthClient oauthClient, String clientSecret) Sets a new clientSecret.updateClient(long id, int version, OAuthClient updates) Update client.updateClientId(String sourceId, String targetId) Update clientId.
-
Field Details
-
passwordEncoder
@Autowired public org.springframework.security.crypto.password.PasswordEncoder passwordEncoderThe password encoder.
-
-
Constructor Details
-
OAuthServiceImpl
public OAuthServiceImpl()
-
-
Method Details
-
afterPropertiesSet
- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean- Throws:
Exception
-
loadClientByClientId
@Cacheable(cacheNames="oauthclient", key="#clientId", unless="#result == null") public OAuthClient loadClientByClientId(String clientId) Description copied from interface:OAuthClientServiceLoad client byclientId.- Specified by:
loadClientByClientIdin interfaceOAuthClientService- Parameters:
clientId- the client ID- Returns:
- fully loaded
OAuthClientornullif client is not found.
-
listClientDetails
Description copied from interface:OAuthClientServiceList client details.- Specified by:
listClientDetailsin interfaceOAuthClientService- Returns:
- the list
-
listClientDetails
public org.springframework.data.domain.Page<OAuthClient> listClientDetails(org.springframework.data.domain.Pageable pageable) Description copied from interface:OAuthClientServiceList client details.- Specified by:
listClientDetailsin interfaceOAuthClientService- Parameters:
pageable- the pageable- Returns:
- page with Client details
-
listClientDetails
public org.springframework.data.domain.Page<OAuthClient> listClientDetails(com.querydsl.core.types.Predicate predicate, org.springframework.data.domain.Pageable pageable) Description copied from interface:OAuthClientServiceList client details with filtering by predicate.- Specified by:
listClientDetailsin interfaceOAuthClientService- Parameters:
predicate- the predicatepageable- the pageable- Returns:
- page with Client details
-
getClient
Description copied from interface:OAuthClientServiceGets the client.- Specified by:
getClientin interfaceOAuthClientService- Parameters:
clientId- the client id- Returns:
- the client
-
removeClient
@Transactional @CacheEvict(cacheNames={"oauthclient","oauthclient.registered"},key="#client.clientId",condition="#client != null") @CacheEvict(cacheNames={"oauthclient.registered.byid","oauthclient.byid.active"},key="T(java.lang.String).valueOf(#client.id)",condition="#client != null and #client.id != null") public OAuthClient removeClient(OAuthClient client) Description copied from interface:OAuthClientServiceRemoves the client.- Specified by:
removeClientin interfaceOAuthClientService- Parameters:
client- the oauth client- Returns:
- the o auth client
-
addClient
Description copied from interface:OAuthClientServiceRegister a new OAuth client.- Specified by:
addClientin interfaceOAuthClientService- Parameters:
client- the client- Returns:
- the OAuth client
-
updateClient
@Transactional @CacheEvict(cacheNames={"oauthclient","oauthclient.registered"},key="#updates.clientId",condition="#updates != null") @CacheEvict(cacheNames={"oauthclient.registered.byid","oauthclient.byid.active"},key="T(java.lang.String).valueOf(#id)",condition="#updates != null") public OAuthClient updateClient(long id, int version, OAuthClient updates) Description copied from interface:OAuthClientServiceUpdate client.- Specified by:
updateClientin interfaceOAuthClientService- Parameters:
id- the idversion- the versionupdates- the updates- Returns:
- the o auth client
-
updateClientId
@Transactional @CacheEvict(cacheNames={"oauthclient","oauthclient.registered"},key="#sourceId",condition="#sourceId != null && #targetId != null") @CacheEvict(cacheNames={"oauthclient.registered.byid","oauthclient.byid.active"},key="T(java.lang.String).valueOf(#result.id)",condition="#result != null and #result.id != null") public OAuthClient updateClientId(String sourceId, String targetId) Description copied from interface:OAuthClientServiceUpdate clientId.- Specified by:
updateClientIdin interfaceOAuthClientService- Parameters:
sourceId- the source clientIdtargetId- the target clientId- Returns:
- the o auth client
-
autocompleteClients
Description copied from interface:OAuthClientServiceAutocomplete OAuth clients by title.- Specified by:
autocompleteClientsin interfaceOAuthClientService- Parameters:
term- the titlelimit- maximum number of results- Returns:
- list of auth clients
-
resetSecret
@Transactional @PreAuthorize("hasRole(\'ADMINISTRATOR\') or hasPermission(#oauthClient, \'ADMINISTRATION\')") public final String resetSecret(OAuthClient oauthClient) Description copied from interface:OAuthClientServiceGenerates a new clientSecret.- Specified by:
resetSecretin interfaceOAuthClientService- Parameters:
oauthClient- the client to regenerate secret for- Returns:
- the new client secret
-
setSecret
@Transactional @PreAuthorize("hasRole(\'ADMINISTRATOR\') or hasPermission(#oauthClient, \'ADMINISTRATION\')") public final String setSecret(OAuthClient oauthClient, String clientSecret) Description copied from interface:OAuthClientServiceSets a new clientSecret.- Specified by:
setSecretin interfaceOAuthClientService- Parameters:
oauthClient- the client to set a secret forclientSecret- the client secret- Returns:
- the new client secret
-
removeSecret
@Transactional @PreAuthorize("hasRole(\'ADMINISTRATOR\') or hasPermission(#oauthClient, \'ADMINISTRATION\')") public final OAuthClient removeSecret(OAuthClient oauthClient) Description copied from interface:OAuthClientServiceRemoves the Client secret.- Specified by:
removeSecretin interfaceOAuthClientService- Parameters:
oauthClient- the oauth client- Returns:
- Updated OAuth client
-
isOriginRegistered
Description copied from interface:OAuthClientServiceCheck if the origin is registered with one of the clients- Specified by:
isOriginRegisteredin interfaceOAuthClientService- Parameters:
origin- the origin- Returns:
- true if a client exists with this origin, false otherwise
-
save
public void save(org.springframework.security.oauth2.server.authorization.client.RegisteredClient registeredClient) - Specified by:
savein interfaceorg.springframework.security.oauth2.server.authorization.client.RegisteredClientRepository
-
findById
@Cacheable(cacheNames="oauthclient.registered.byid", key="#registrationId", unless="#result == null") public org.springframework.security.oauth2.server.authorization.client.RegisteredClient findById(String registrationId) - Specified by:
findByIdin interfaceorg.springframework.security.oauth2.server.authorization.client.RegisteredClientRepository
-
findByClientId
@Cacheable(cacheNames="oauthclient.registered", key="#clientId", unless="#result == null") public org.springframework.security.oauth2.server.authorization.client.RegisteredClient findByClientId(String clientId) - Specified by:
findByClientIdin interfaceorg.springframework.security.oauth2.server.authorization.client.RegisteredClientRepository
-
isClientActive
@Cacheable(cacheNames="oauthclient.byid.active", key="#registrationId", unless="#registrationId == null") public boolean isClientActive(String registrationId) Description copied from interface:OAuthClientServiceCheck OAuthClient.active.- Specified by:
isClientActivein interfaceOAuthClientService- Parameters:
registrationId- the client id- Returns:
- true if client is present and active
-