1 package com.supwisdom.institute.backend.admin.bff.security.core.userdetails;
3 import java.util.ArrayList;
4 import java.util.Collection;
8 import org.springframework.security.core.GrantedAuthority;
9 import org.springframework.security.core.userdetails.User;
11 public class MyUser extends User {
16 private static final long serialVersionUID = 3195151947212484499L;
18 public MyUser(String username, String password,
19 Collection<? extends GrantedAuthority> authorities,
20 Map<String, Object> attributes) {
21 this(username, password, true, true, true, true, authorities, attributes);
24 public MyUser(String username, String password,
25 boolean enabled, boolean accountNonExpired, boolean credentialsNonExpired, boolean accountNonLocked,
26 Collection<? extends GrantedAuthority> authorities,
27 Map<String, Object> attributes) {
28 super(username, password, enabled, accountNonExpired, credentialsNonExpired, accountNonLocked, authorities);
30 this.attributes = attributes;
33 private final Map<String, Object> attributes;
34 public Map<String, Object> getAttributes() {
35 return this.attributes;
38 public List<String> getRoles() {
39 List<String> roles = new ArrayList<>();
40 for (GrantedAuthority grantedAuthority : this.getAuthorities()) {
41 roles.add(grantedAuthority.getAuthority());
48 public Object getAttribute(String key) {
49 if (attributes == null) {
53 if (!attributes.containsKey(key)) {
57 return attributes.get(key);