Class AuthService
java.lang.Object
hu.rts.mike.example.dev.crm.rest.security.AuthService
- All Implemented Interfaces:
org.springframework.security.core.userdetails.UserDetailsService
@Service
public class AuthService
extends Object
implements org.springframework.security.core.userdetails.UserDetailsService
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final AuthInfoRepositoryprivate final JwtServiceprivate final org.springframework.security.crypto.password.PasswordEncoder -
Constructor Summary
ConstructorsConstructorDescriptionAuthService(JwtService jwtService, AuthInfoRepository authInfoRepository, org.springframework.security.crypto.password.PasswordEncoder passwordEncoder) -
Method Summary
Modifier and TypeMethodDescriptionprivate Set<? extends org.springframework.security.core.GrantedAuthority>getAuthorities(Collection<Role> roles) Returns user privileges as Set of SimpleGrantedAuthorities.private Set<org.springframework.security.core.GrantedAuthority>getGrantedAuthorities(Set<String> privileges) Converts privileges to GrantedAuthorities.getPrivileges(Collection<Role> roles) Gets privileges of given roles.org.springframework.security.core.userdetails.UserDetailsloadUserByUsername(String username)
-
Field Details
-
jwtService
-
authInfoRepository
-
passwordEncoder
private final org.springframework.security.crypto.password.PasswordEncoder passwordEncoder
-
-
Constructor Details
-
AuthService
public AuthService(JwtService jwtService, AuthInfoRepository authInfoRepository, org.springframework.security.crypto.password.PasswordEncoder passwordEncoder)
-
-
Method Details
-
loadUserByUsername
public org.springframework.security.core.userdetails.UserDetails loadUserByUsername(String username) throws org.springframework.security.core.userdetails.UsernameNotFoundException - Specified by:
loadUserByUsernamein interfaceorg.springframework.security.core.userdetails.UserDetailsService- Throws:
org.springframework.security.core.userdetails.UsernameNotFoundException
-
login
public TokenDto login(LoginDto login) throws org.springframework.security.core.userdetails.UsernameNotFoundException - Throws:
org.springframework.security.core.userdetails.UsernameNotFoundException
-
refresh
public TokenDto refresh(String refreshToken) throws org.springframework.security.core.userdetails.UsernameNotFoundException - Throws:
org.springframework.security.core.userdetails.UsernameNotFoundException
-
getAuthorities
private Set<? extends org.springframework.security.core.GrantedAuthority> getAuthorities(Collection<Role> roles) Returns user privileges as Set of SimpleGrantedAuthorities. Used in case of session-based authentication.- Parameters:
roles- The roles to be converted.- Returns:
- Set of privileges as SimpleGrantedAuthority instances.
-
getPrivileges
Gets privileges of given roles. The privilege names are prefixed with "ROLE_" because the view-level @RolesAllowed annotation automatically extends the given role names with the same prefix and @PrivilegesAllowed annotation does not exist.- Parameters:
roles- The roles to be analysed.- Returns:
- Set of privilege names.
-
getGrantedAuthorities
private Set<org.springframework.security.core.GrantedAuthority> getGrantedAuthorities(Set<String> privileges) Converts privileges to GrantedAuthorities.- Parameters:
privileges- The privileges to be converted.- Returns:
- List of SimpleGrantedAuthorities.
-