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 Details

    • passwordEncoder

      @Autowired public org.springframework.security.crypto.password.PasswordEncoder passwordEncoder
      The password encoder.
  • Constructor Details

    • OAuthServiceImpl

      public OAuthServiceImpl()
  • Method Details

    • afterPropertiesSet

      public void afterPropertiesSet() throws Exception
      Specified by:
      afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
      Throws:
      Exception
    • loadClientByClientId

      @Cacheable(cacheNames="oauthclient", key="#clientId", unless="#result == null") public OAuthClient loadClientByClientId(String clientId)
      Description copied from interface: OAuthClientService
      Load client by clientId.
      Specified by:
      loadClientByClientId in interface OAuthClientService
      Parameters:
      clientId - the client ID
      Returns:
      fully loaded OAuthClient or null if client is not found.
    • listClientDetails

      public List<OAuthClient> listClientDetails()
      Description copied from interface: OAuthClientService
      List client details.
      Specified by:
      listClientDetails in interface OAuthClientService
      Returns:
      the list
    • listClientDetails

      public org.springframework.data.domain.Page<OAuthClient> listClientDetails(org.springframework.data.domain.Pageable pageable)
      Description copied from interface: OAuthClientService
      List client details.
      Specified by:
      listClientDetails in interface OAuthClientService
      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: OAuthClientService
      List client details with filtering by predicate.
      Specified by:
      listClientDetails in interface OAuthClientService
      Parameters:
      predicate - the predicate
      pageable - the pageable
      Returns:
      page with Client details
    • getClient

      public OAuthClient getClient(String clientId)
      Description copied from interface: OAuthClientService
      Gets the client.
      Specified by:
      getClient in interface OAuthClientService
      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: OAuthClientService
      Removes the client.
      Specified by:
      removeClient in interface OAuthClientService
      Parameters:
      client - the oauth client
      Returns:
      the o auth client
    • addClient

      @Transactional public OAuthClient addClient(OAuthClient client)
      Description copied from interface: OAuthClientService
      Register a new OAuth client.
      Specified by:
      addClient in interface OAuthClientService
      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: OAuthClientService
      Update client.
      Specified by:
      updateClient in interface OAuthClientService
      Parameters:
      id - the id
      version - the version
      updates - 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: OAuthClientService
      Update clientId.
      Specified by:
      updateClientId in interface OAuthClientService
      Parameters:
      sourceId - the source clientId
      targetId - the target clientId
      Returns:
      the o auth client
    • autocompleteClients

      public List<OAuthClient> autocompleteClients(String term, int limit)
      Description copied from interface: OAuthClientService
      Autocomplete OAuth clients by title.
      Specified by:
      autocompleteClients in interface OAuthClientService
      Parameters:
      term - the title
      limit - 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: OAuthClientService
      Generates a new clientSecret.
      Specified by:
      resetSecret in interface OAuthClientService
      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: OAuthClientService
      Sets a new clientSecret.
      Specified by:
      setSecret in interface OAuthClientService
      Parameters:
      oauthClient - the client to set a secret for
      clientSecret - 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: OAuthClientService
      Removes the Client secret.
      Specified by:
      removeSecret in interface OAuthClientService
      Parameters:
      oauthClient - the oauth client
      Returns:
      Updated OAuth client
    • isOriginRegistered

      public boolean isOriginRegistered(String origin)
      Description copied from interface: OAuthClientService
      Check if the origin is registered with one of the clients
      Specified by:
      isOriginRegistered in interface OAuthClientService
      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:
      save in interface org.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:
      findById in interface org.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:
      findByClientId in interface org.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: OAuthClientService
      Check OAuthClient.active.
      Specified by:
      isClientActive in interface OAuthClientService
      Parameters:
      registrationId - the client id
      Returns:
      true if client is present and active