PrincipalDetail.java 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package com.its.web.dto.admin;
  2. import org.springframework.security.core.GrantedAuthority;
  3. import org.springframework.security.core.userdetails.UserDetails;
  4. import java.util.ArrayList;
  5. import java.util.Collection;
  6. public class PrincipalDetail implements UserDetails {
  7. private TbWwwMemberDto user;
  8. public PrincipalDetail(TbWwwMemberDto user) {
  9. this.user = user;
  10. }
  11. @Override
  12. public Collection<? extends GrantedAuthority> getAuthorities() {
  13. Collection<GrantedAuthority> collectors = new ArrayList<>();
  14. collectors.add(()->{return "ROLE_ADMIN";}); //add에 들어올 파라미터는 GrantedAuthority밖에 없으니
  15. return collectors;
  16. }
  17. @Override
  18. public String getPassword() {
  19. return this.user.getPwd();
  20. }
  21. @Override
  22. public String getUsername() {
  23. return this.user.getEmail();
  24. }
  25. @Override
  26. public boolean isAccountNonExpired() {
  27. return true;
  28. }
  29. @Override
  30. public boolean isAccountNonLocked() {
  31. return true;
  32. }
  33. @Override
  34. public boolean isCredentialsNonExpired() {
  35. return true;
  36. }
  37. @Override
  38. public boolean isEnabled() {
  39. return true;
  40. }
  41. }