for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
package com.osomapps.pt.auth;
import com.osomapps.pt.admin.ptuser.PtUser;
import java.util.Collection;
import java.util.stream.Collectors;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.security.core.userdetails.UserDetails;
class CustomUserDetails implements UserDetails {
private final PtUser ptUser;
CustomUserDetails(PtUser ptUser) {
this.ptUser = ptUser;
}
public PtUser getPtUser() {
return ptUser;
@Override
public Collection<? extends GrantedAuthority> getAuthorities() {
return AuthorityUtils.commaSeparatedStringToAuthorityList(
ptUser.getPtRoles().stream()
.map(ptRole -> ptRole.getName())
.collect(Collectors.joining(",")));
public String getPassword() {
return ptUser.getPassword();
public String getUsername() {
return ptUser.getName();
public boolean isAccountNonExpired() {
return true;
public boolean isAccountNonLocked() {
public boolean isCredentialsNonExpired() {
public boolean isEnabled() {
return !ptUser.getIs_deleted();