Class DataServiceTokenService

  • All Implemented Interfaces:
    org.molgenis.security.core.token.TokenService

    public class DataServiceTokenService
    extends Object
    implements org.molgenis.security.core.token.TokenService
    TokensService implementation that uses the DataService
    • Constructor Detail

      • DataServiceTokenService

        public DataServiceTokenService​(TokenGenerator tokenGenerator,
                                       org.molgenis.data.DataService dataService,
                                       org.springframework.security.core.userdetails.UserDetailsService userDetailsService,
                                       org.molgenis.data.security.auth.TokenFactory tokenFactory)
    • Method Detail

      • findUserByToken

        @Transactional(readOnly=true)
        public org.springframework.security.core.userdetails.UserDetails findUserByToken​(String token)
        Find a user by a security token
        Specified by:
        findUserByToken in interface org.molgenis.security.core.token.TokenService
        Parameters:
        token - security token
        Returns:
        the user or null if not found or token is expired
      • generateAndStoreToken

        @Transactional
        public String generateAndStoreToken​(String username,
                                            String description)
        Generates a token and associates it with a user.

        Token expires in 2 hours

        Specified by:
        generateAndStoreToken in interface org.molgenis.security.core.token.TokenService
        Parameters:
        username - username
        description - token description
        Returns:
        token
      • removeToken

        @Transactional
        public void removeToken​(String token)
        Specified by:
        removeToken in interface org.molgenis.security.core.token.TokenService