Class UserService

  • All Implemented Interfaces:
    org.springframework.core.convert.converter.Converter<org.springframework.security.oauth2.jwt.Jwt,​org.springframework.security.authentication.UsernamePasswordAuthenticationToken>

    @Service
    public class UserService
    extends Object
    implements org.springframework.core.convert.converter.Converter<org.springframework.security.oauth2.jwt.Jwt,​org.springframework.security.authentication.UsernamePasswordAuthenticationToken>
    The class is a @Service class that implements a converter that converts a java web token to an authentication token for the user.
    • Constructor Detail

      • UserService

        @Autowired
        public UserService​(UserRepository userRepository)
        This Constructor creates a UserRepository object.
    • Method Detail

      • getOrCreate

        public User getOrCreate​(String oauthKey,
                                String userName)
        Searches for a user with an Oauth Key and then makes a new user with an OauthKey if it cannot find them.
        Parameters:
        oauthKey - This is an Oauth Key assigned to user.
        userName - This is a display name assigned to a user.
        Returns:
        Returns a saved user from user repository.
      • convert

        public org.springframework.security.authentication.UsernamePasswordAuthenticationToken convert​(org.springframework.security.oauth2.jwt.Jwt jwt)
        This is a helper method that converts a Jwt to grant authority to a user via a UsernamePasswordAuthenticationToken.
        Specified by:
        convert in interface org.springframework.core.convert.converter.Converter<org.springframework.security.oauth2.jwt.Jwt,​org.springframework.security.authentication.UsernamePasswordAuthenticationToken>
        Parameters:
        jwt - is the converted Json web token.
        Returns:
        Returns a new Jwt to user.