public SimpleAuthenticationInfo(Object principal, Object hashedCredentials, ByteSource credentialsSalt, String realmName) {
        this.principals = new SimplePrincipalCollection(principal, realmName);
        this.credentials = hashedCredentials;
        this.credentialsSalt = credentialsSalt;
    }

realm中使用这个构造方法时,第一个参数principal传入的值和subject.getPrincipal()获取的值一致。

这里传入userEntity(实体),subject.getPrincipal()得到的是userEntity(实体);

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。

这里传入username(字符串),subject.getPrincipal()得到的是字符串。

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄