All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.formkiq.server.service.OAuthUserDetailsService Maven / Gradle / Ivy

There is a newer version: 0.6.1
Show newest version
package com.formkiq.server.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import com.formkiq.server.dao.UserDao;
import com.formkiq.server.domain.User;

/**
 * OAuth User Details Service.
 *
 */
@Service
public class OAuthUserDetailsService implements UserDetailsService {

    /** UserDao. */
    @Autowired
    private UserDao userDao;

    @Override
    public UserDetails loadUserByUsername(final String username)
            throws UsernameNotFoundException {

        User user = null;

        if (!StringUtils.isEmpty(username)) {
            user = this.userDao.findUser(username);
        }

        if (user == null) {
            throw new UsernameNotFoundException("user not found " + username);
        }

        return user;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy