@Inject
private PermissionService permissionService;
@Override
public AuthenticationInfo getAuthenticationInfo(UsernamePasswordToken token) {
Principal principal = permissionService.getPrincipalByUserName(token.getUsername());
if (principal == null) {
return null;
} else {
AuthenticationInfoBuilder authenticationInfoBuilder = new AuthenticationInfoBuilder();
authenticationInfoBuilder.principalId(principal.getId()).name(principal.getEmployee().getName());
authenticationInfoBuilder.password(principal.getPassword()) ;
authenticationInfoBuilder.addUserInfo(UserInfo.EMPLOYEE_ID, principal.getEmployee().getId());
if (principal.getEmployee().getDepartment() != null) {
authenticationInfoBuilder.addUserInfo(UserInfo.DEPARTMENT_ID, principal.getEmployee().getDepartment().getId());
}
if (principal.getEmployee().getManager() != null) {
authenticationInfoBuilder.addUserInfo(UserInfo.MANAGER_EMPLOYEE_ID, principal.getEmployee().getManager().getId());
}
return authenticationInfoBuilder.build();
}