首先你需要在登陆认证的过程中将获取的到的对象传入

//装配认证信息
SimpleAuthenticationInfo authenticationInfo = new SimpleAuthenticationInfo(
//用户名
userInfo,
//密码
userInfo.getPassword(),
//salt
ByteSource.Util.bytes(userInfo.getCredentialsSalt()),
//realm name
getName()
);

其次呢,你需要如下即可获取


Subject subject = SecurityUtils.getSubject();
Object principal = subject.getPrincipal();