Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

Untitled

a guest Dec 7th, 2018 63 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. package com.batul.auth;
  2.  
  3. import com.batul.domain.entity.UserEntity;
  4. import org.springframework.security.core.GrantedAuthority;
  5. import org.springframework.security.core.authority.SimpleGrantedAuthority;
  6. import org.springframework.security.core.userdetails.UserDetails;
  7.  
  8. import java.util.Collection;
  9. import java.util.Collections;
  10.  
  11. public class JdbcAuthUserDetails implements UserDetails {
  12.  
  13.     private UserEntity userEntity;
  14.  
  15.     JdbcAuthUserDetails(UserEntity userEntity) {
  16.         super();
  17.         this.userEntity = userEntity;
  18.     }
  19.  
  20.     @Override
  21.     public Collection<? extends GrantedAuthority> getAuthorities() {
  22.         SimpleGrantedAuthority authority = new SimpleGrantedAuthority(this.userEntity.getRole());
  23.         return Collections.singleton(authority);
  24.     }
  25.  
  26.     @Override
  27.     public String getPassword() {
  28.         return this.userEntity.getPassword();
  29.     }
  30.  
  31.     @Override
  32.     public String getUsername() {
  33.         return this.userEntity.getUsername();
  34.     }
  35.  
  36.     @Override
  37.     public boolean isAccountNonExpired() {
  38.         return !this.userEntity.getAccountExpired();
  39.     }
  40.  
  41.     @Override
  42.     public boolean isAccountNonLocked() {
  43.         return !this.userEntity.getAccountLocked();
  44.     }
  45.  
  46.     @Override
  47.     public boolean isCredentialsNonExpired() {
  48.         return !this.userEntity.getCredentialsExpired();
  49.     }
  50.  
  51.     @Override
  52.     public boolean isEnabled() {
  53.         return !this.userEntity.getUserEnabled();
  54.     }
  55. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top