微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

spring-Security《一》

源码介绍:
public interface UserDetailsService {
    UserDetails loadUserByUsername(String var1) throws UsernameNotFoundException;
}

 里面返回一个UserDetails,来看下UserDetails里面是什么

public interface UserDetails extends Serializable {
    Collection<? extends GrantedAuthority> getAuthorities();

    String getpassword();  密码

    String getUsername(); 用户名

    boolean isAccountNonExpired(); 账号是否被过期

    boolean isAccountNonLocked();账号是否被锁定

    boolean isCredentialsNonExpired(); 证书(密码)是否过期

    boolean isEnabled();账号是否被启用
}

 UserDetails也是个接口,那么他肯定有实现类

里面果然有个User去实现它

 

 看下User是什么小编

 

 属性是与接口对应,有两个构造函数

用户名密码,授权
    public User(String username, String password, Collection<? extends GrantedAuthority> authorities) {
        this(username, password, true, true, true, true, authorities);
    }

就是那一堆属性构造方法了
    public User(String username, String password, boolean enabled, boolean accountNonExpired, boolean credentialsNonExpired, boolean accountNonLocked, Collection<? extends GrantedAuthority> authorities) {
        if (username != null && !"".equals(username) && password != null) {
            this.username = username;
            this.password = password;
            this.enabled = enabled;
            this.accountNonExpired = accountNonExpired;
            this.credentialsNonExpired = credentialsNonExpired;
            this.accountNonLocked = accountNonLocked;
            this.authorities = Collections.unmodifiableSet(sortAuthorities(authorities));
        } else {
            throw new IllegalArgumentException("Cannot pass null or empty values to constructor");
        }
    }

 

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐