@Override
public Principal resolvePrincipal(Credential credential) {
//若类型匹配,则进行转换。
if (credential != null && this.supports(credential)) {
EncryCredential encryCredential = (EncryCredential) credential;
DefaultUserPrincipal principal = new DefaultUserPrincipal();
//解析加密后凭据信息。
EncryCredentialInfo encryCredentialInfo = encryCredential.getEncryCredentialInfo();
//设置用户名为唯一标识。
if (encryCredentialInfo != null) {
principal.setId(encryCredentialInfo.getUserId());
//设置参数表为用户属性。
principal.setAttributes(encryCredential.getParameters());
}
return principal;
}
return null;
}