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
Fields Modifier and Type Field Description org.springframework.security.crypto.password.PasswordEncoderpasswordEncoderThe password encoder.
-
Constructor Summary
Constructors Constructor Description OAuthServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description OAuthClientaddClient(OAuthClient client)Register a new OAuth client.voidafterPropertiesSet()List<OAuthClient>autocompleteClients(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.RegisteredClientfindById(String registrationId)OAuthClientgetClient(String clientId)Gets the client.booleanisOriginRegistered(String origin)Check if the origin is registered with one of the clientsList<OAuthClient>listClientDetails()List 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.OAuthClientloadClientByClientId(String clientId)OAuthClientremoveClient(OAuthClient client)Removes the client.OAuthClientremoveSecret(OAuthClient oauthClient)Removes the Client secret.StringresetSecret(OAuthClient oauthClient)Generates a new clientSecret.voidsave(org.springframework.security.oauth2.server.authorization.client.RegisteredClient registeredClient)StringsetSecret(OAuthClient oauthClient, String clientSecret)Sets a new clientSecret.OAuthClientupdateClient(long id, int version, OAuthClient updates)Update client.OAuthClientupdateClientId(String sourceId, String targetId)Update clientId.
-
-
-
Method Detail
-
afterPropertiesSet
public void afterPropertiesSet() throws Exception- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean- Throws:
Exception
-
loadClientByClientId
@Cacheable(cacheNames="oauthclient", key="#clientId", unless="#result == null") public OAuthClient loadClientByClientId(String clientId)- Specified by:
loadClientByClientIdin interfaceOAuthClientService
-
listClientDetails
public List<OAuthClient> 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
public OAuthClient getClient(String clientId)
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",key="#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
@Transactional public OAuthClient addClient(OAuthClient client)
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",key="#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",key="#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
public List<OAuthClient> autocompleteClients(String term, int limit)
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
public boolean isOriginRegistered(String origin)
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
-
-