| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- //package seecoder.devcloud.web.vo.user;
- //
- //import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
- //
- //import lombok.*;
- //import org.apache.commons.codec.digest.DigestUtils;
- //import org.springframework.beans.BeanUtils;
- //import org.springframework.security.core.GrantedAuthority;
- //import org.springframework.security.core.userdetails.UserDetails;
- //import org.springframework.security.core.userdetails.UsernameNotFoundException;
- //import seecoder.devcloud.web.po.user.User;
- //
- //import java.util.Collections;
- //import java.util.Set;
- //
- //import static seecoder.devcloud.web.enums.UserIdentity.STUDENT;
- //import static seecoder.devcloud.web.enums.UserIdentity.TEACHER;
- //import static seecoder.devcloud.web.infrastructure.security.WebSecurityConstants.*;
- //
- //
- //@Data
- //@EqualsAndHashCode
- //@ToString
- //@NoArgsConstructor
- //@AllArgsConstructor
- //@JsonIgnoreProperties(ignoreUnknown = true)
- //public class CustomUserDetails implements UserDetails {
- // private Integer id;
- // private String username;
- // private String password;
- // private Set<GrantedAuthority> authorities;
- //
- // CustomUserDetails(User user) {
- // BeanUtils.copyProperties(user, this);
- // switch (user.getRole()) {
- // case STUDENT:
- // this.authorities = Collections.singleton(STUDENT_AUTHORITY);
- // break;
- // case TEACHER:
- // this.authorities = Collections.singleton(TEACHER_AUTHORITY);
- // break;
- // default:
- // throw new UsernameNotFoundException(username);
- // }
- // }
- //
- // CustomUserDetails(String username, String password) {
- // this.id = 0;
- // this.username = username;
- // this.password = DigestUtils.sha256Hex(password);
- // this.authorities = Collections.singleton(ADMIN_AUTHORITY);
- // }
- //
- // @Override
- // public boolean isAccountNonExpired() {
- // return true;
- // }
- //
- // @Override
- // public boolean isAccountNonLocked() {
- // return true;
- // }
- //
- // @Override
- // public boolean isCredentialsNonExpired() {
- // return true;
- // }
- //
- // @Override
- // public boolean isEnabled() {
- // return true;
- // }
- //
- // public boolean isStudent() {
- // return authorities.contains(STUDENT_AUTHORITY);
- // }
- //
- // public boolean isTeacher() {
- // return authorities.contains(TEACHER_AUTHORITY);
- // }
- //
- // public boolean isAdmin() {
- // return authorities.contains(ADMIN_AUTHORITY);
- // }
- //}
|