|
|
@ -19,13 +19,28 @@ public class WdcyUserDetails implements UserDetails {
|
|
|
|
|
|
|
|
|
|
|
|
private static final long serialVersionUID = 3957586021470480642L;
|
|
|
|
private static final long serialVersionUID = 3957586021470480642L;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 角色权限 前缀
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @see org.springframework.security.access.vote.RoleVoter
|
|
|
|
|
|
|
|
*/
|
|
|
|
protected static final String ROLE_PREFIX = "ROLE_";
|
|
|
|
protected static final String ROLE_PREFIX = "ROLE_";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 默认的 用户角色
|
|
|
|
|
|
|
|
* ROLE_USER
|
|
|
|
|
|
|
|
*/
|
|
|
|
protected static final GrantedAuthority DEFAULT_USER_ROLE = new SimpleGrantedAuthority(ROLE_PREFIX + Privilege.USER.name());
|
|
|
|
protected static final GrantedAuthority DEFAULT_USER_ROLE = new SimpleGrantedAuthority(ROLE_PREFIX + Privilege.USER.name());
|
|
|
|
|
|
|
|
|
|
|
|
protected User user;
|
|
|
|
protected User user;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 用户的授权集合
|
|
|
|
|
|
|
|
*/
|
|
|
|
protected List<GrantedAuthority> grantedAuthorities = new ArrayList<>();
|
|
|
|
protected List<GrantedAuthority> grantedAuthorities = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public WdcyUserDetails() {
|
|
|
|
public WdcyUserDetails() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -34,6 +49,9 @@ public class WdcyUserDetails implements UserDetails {
|
|
|
|
initialAuthorities();
|
|
|
|
initialAuthorities();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 初始化用户角色,权限
|
|
|
|
|
|
|
|
*/
|
|
|
|
private void initialAuthorities() {
|
|
|
|
private void initialAuthorities() {
|
|
|
|
//Default, everyone have it
|
|
|
|
//Default, everyone have it
|
|
|
|
this.grantedAuthorities.add(DEFAULT_USER_ROLE);
|
|
|
|
this.grantedAuthorities.add(DEFAULT_USER_ROLE);
|
|
|
@ -69,21 +87,25 @@ public class WdcyUserDetails implements UserDetails {
|
|
|
|
return user.username();
|
|
|
|
return user.username();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 账户是否未过期 */
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean isAccountNonExpired() {
|
|
|
|
public boolean isAccountNonExpired() {
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*账户是否未锁定 */
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean isAccountNonLocked() {
|
|
|
|
public boolean isAccountNonLocked() {
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 密码是否未过期 */
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean isCredentialsNonExpired() {
|
|
|
|
public boolean isCredentialsNonExpired() {
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*账户是否启用,默认true (启用)*/
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean isEnabled() {
|
|
|
|
public boolean isEnabled() {
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
@ -96,9 +118,9 @@ public class WdcyUserDetails implements UserDetails {
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public String toString() {
|
|
|
|
public String toString() {
|
|
|
|
final StringBuilder sb = new StringBuilder();
|
|
|
|
return "{" +
|
|
|
|
sb.append("{user=").append(user);
|
|
|
|
"user=" + user +
|
|
|
|
sb.append('}');
|
|
|
|
", grantedAuthorities=" + grantedAuthorities +
|
|
|
|
return sb.toString();
|
|
|
|
'}';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|