Class DataServiceTokenService

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

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

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

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.springframework.security.core.userdetails.UserDetails findUserByToken​(java.lang.String token)
      Find a user by a security token
      java.lang.String generateAndStoreToken​(java.lang.String username, java.lang.String description)
      Generates a token and associates it with a user.
      void removeToken​(java.lang.String token)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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​(java.lang.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 java.lang.String generateAndStoreToken​(java.lang.String username,
                                                      java.lang.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​(java.lang.String token)
        Specified by:
        removeToken in interface org.molgenis.security.core.token.TokenService