@@ -0,0 +1,2298 @@
+package com.rizki.mufrizal.spring.oauth2.custom.service.impl;%0A%0Aimport com.rizki.mufrizal.spring.oauth2.custom.domain.UserRole;%0Aimport com.rizki.mufrizal.spring.oauth2.custom.repository.UserRepository;%0Aimport java.util.ArrayList;%0Aimport java.util.HashSet;%0Aimport java.util.List;%0Aimport java.util.Set;%0Aimport org.springframework.beans.factory.annotation.Autowired;%0Aimport org.springframework.security.core.GrantedAuthority;%0Aimport org.springframework.security.core.authority.SimpleGrantedAuthority;%0Aimport org.springframework.security.core.userdetails.User;%0Aimport org.springframework.security.core.userdetails.UserDetails;%0Aimport org.springframework.security.core.userdetails.UserDetailsService;%0Aimport org.springframework.security.core.userdetails.UsernameNotFoundException;%0Aimport org.springframework.stereotype.Service;%0A%0A/**%0A *%0A * @Author Rizki Mufrizal %3Cmufrizalrizki@gmail.com%3E%0A * @Web %3Chttps://RizkiMufrizal.github.io%3E%0A * @Since Feb 5, 2017%0A * @Time 7:31:02 PM%0A * @Encoding UTF-8%0A * @Project Spring-OAuth2-Custom%0A * @Package com.rizki.mufrizal.spring.oauth2.custom.service.impl%0A *%0A */%0A@Service%0Apublic class UserService implements UserDetailsService %7B%0A%0A    @Autowired%0A    private UserRepository userRepository;%0A%0A    @Override%0A    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException %7B%0A        com.rizki.mufrizal.spring.oauth2.custom.domain.User user = userRepository.LoginUser(username);%0A%0A        if (user != null) %7B%0A            List%3CGrantedAuthority%3E authorities = buildUserAuthority(user.getUserRoles());%0A            return buildUserForAuthentication(user, authorities);%0A        %7D%0A%0A        return null;%0A    %7D%0A%0A    private User buildUserForAuthentication(com.rizki.mufrizal.spring.oauth2.custom.domain.User user, List%3CGrantedAuthority%3E grantedAuthorities) %7B%0A        return new User(user.getUsername(), user.getPassword(), user.getIsActive(), true, true, true, grantedAuthorities);%0A    %7D%0A%0A    private List%3CGrantedAuthority%3E buildUserAuthority(Set%3CUserRole%3E userRoles) %7B%0A        Set%3CGrantedAuthority%3E grantedAuthorities = new HashSet%3C%3E();%0A%0A        userRoles.stream().forEach((userRole) -%3E %7B%0A            grantedAuthorities.add(new SimpleGrantedAuthority(userRole.getRole().toString()));%0A        %7D);%0A%0A        return new ArrayList%3C%3E(grantedAuthorities);%0A    %7D%0A%0A%7D%0A

add user service