Class OAuthServiceImpl

  • All Implemented Interfaces:
    OAuthClientDetailsService, org.springframework.beans.factory.InitializingBean, org.springframework.security.oauth2.provider.ClientDetailsService

    @Service
    @Transactional(readOnly=true)
    public class OAuthServiceImpl
    extends Object
    implements OAuthClientDetailsService, 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
      • loadClientByClientId

        @Cacheable(cacheNames="oauthclient",
                   key="#clientId",
                   unless="#result == null")
        public org.springframework.security.oauth2.provider.ClientDetails loadClientByClientId​(String clientId)
                                                                                        throws org.springframework.security.oauth2.provider.ClientRegistrationException
        Specified by:
        loadClientByClientId in interface org.springframework.security.oauth2.provider.ClientDetailsService
        Throws:
        org.springframework.security.oauth2.provider.ClientRegistrationException
      • updateClient

        @Transactional
        @CacheEvict(cacheNames="oauthclient",
                    key="#updates.clientId",
                    condition="#updates != null")
        public OAuthClient updateClient​(long id,
                                        int version,
                                        OAuthClient updates)
        Description copied from interface: OAuthClientDetailsService
        Update client.
        Specified by:
        updateClient in interface OAuthClientDetailsService
        Parameters:
        id - the id
        version - the version
        updates - the updates
        Returns:
        the o auth client
      • updateClientId

        @Transactional
        @CacheEvict(cacheNames="oauthclient",
                    key="#sourceId",
                    condition="#sourceId != null && #targetId != null")
        public OAuthClient updateClientId​(String sourceId,
                                          String targetId)
        Description copied from interface: OAuthClientDetailsService
        Update clientId.
        Specified by:
        updateClientId in interface OAuthClientDetailsService
        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: OAuthClientDetailsService
        Generates a new clientSecret.
        Specified by:
        resetSecret in interface OAuthClientDetailsService
        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: OAuthClientDetailsService
        Sets a new clientSecret.
        Specified by:
        setSecret in interface OAuthClientDetailsService
        Parameters:
        oauthClient - the client to set a secret for
        Returns:
        the new client secret
      • removeSecret

        @Transactional
        @PreAuthorize("hasRole(\'ADMINISTRATOR\') or hasPermission(#oauthClient, \'ADMINISTRATION\')")
        public final OAuthClient removeSecret​(OAuthClient oauthClient)
        Description copied from interface: OAuthClientDetailsService
        Removes the Client secret.
        Specified by:
        removeSecret in interface OAuthClientDetailsService
        Parameters:
        oauthClient - the oauth client
        Returns:
        Updated OAuth client