foundation.cmo.api.mls.graphql.security.dto.MUserDetails Maven / Gradle / Ivy
package foundation.cmo.api.mls.graphql.security.dto;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import lombok.AllArgsConstructor;
import lombok.Data;
@Data
@AllArgsConstructor(staticName = "to")
public class MUserDetails implements UserDetails {
private static final long serialVersionUID = 1L;
private final String ROLE_PREFIX = "ROLE_";
private MUser user;
@Override
public Collection extends GrantedAuthority> getAuthorities() {
List list = new ArrayList();
list.add(new SimpleGrantedAuthority(ROLE_PREFIX + user.getRole()));
return list;
}
@Override
public String getPassword() {
return user.getPassword();
}
@Override
public String getUsername() {
return user.getUsername();
}
@Override
public boolean isAccountNonExpired() {
return user.isExpired();
}
@Override
public boolean isAccountNonLocked() {
return user.isLocked();
}
@Override
public boolean isCredentialsNonExpired() {
return user.isCredentialExpired();
}
@Override
public boolean isEnabled() {
return user.isEnabled();
}
}