Class 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 Detail

      • passwordEncoder

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

      • OAuthServiceImpl

        public OAuthServiceImpl()
    • Method Detail

      • afterPropertiesSet

        public void afterPropertiesSet()
                                throws Exception
        Specified by:
        afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
        Throws:
        Exception
      • 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
      • 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: OAuthClientService
        Removes the client.
        Specified by:
        removeClient in interface OAuthClientService
        Parameters:
        client - the oauth client
        Returns:
        the o auth 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: 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",key="#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
      • 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