@Override public Collection<User> search(String query) { return userService .search(query, new PageableImpl(1, 20)) .getContent() .stream() .filter(userEntity -> !userEntity.getSource().equalsIgnoreCase("ldap") && !userEntity.getSource().equalsIgnoreCase("memory")) .map((Function<UserEntity, User>) RepositoryUser::new) .collect(Collectors.toList()); } }
@Override public Document transform(Indexable indexable) { Document doc = new Document(); UserEntity user = (UserEntity) indexable; doc.add(new StringField(FIELD_ID, user.getId(), Field.Store.YES)); doc.add(new StringField(FIELD_TYPE, FIELD_TYPE_VALUE, Field.Store.YES)); doc.add(new StringField(FIELD_SOURCE, user.getSource(), Field.Store.NO)); doc.add(new StringField(FIELD_REFERENCE, user.getSourceId(), Field.Store.NO)); if (user.getDisplayName() != null) { doc.add(new StringField(FIELD_DISPLAYNAME, user.getDisplayName(), Field.Store.NO)); doc.add(new TextField(FIELD_DISPLAYNAME_SPLIT, user.getDisplayName(), Field.Store.NO)); } if (user.getFirstname() != null) { doc.add(new StringField(FIELD_FIRSTNAME, user.getFirstname(), Field.Store.NO)); } if (user.getLastname() != null) { doc.add(new StringField(FIELD_LASTNAME, user.getLastname(), Field.Store.NO)); } if (user.getEmail() != null) { doc.add(new StringField(FIELD_EMAIL, user.getEmail(), Field.Store.NO)); } return doc; }
@Override public Document transform(Indexable indexable) { Document doc = new Document(); UserEntity user = (UserEntity) indexable; doc.add(new StringField(FIELD_ID, user.getId(), Field.Store.YES)); doc.add(new StringField(FIELD_TYPE, FIELD_TYPE_VALUE, Field.Store.YES)); doc.add(new StringField(FIELD_SOURCE, user.getSource(), Field.Store.NO)); doc.add(new StringField(FIELD_REFERENCE, user.getSourceId(), Field.Store.NO)); if (user.getDisplayName() != null) { doc.add(new StringField(FIELD_DISPLAYNAME, user.getDisplayName(), Field.Store.NO)); doc.add(new TextField(FIELD_DISPLAYNAME_SPLIT, user.getDisplayName(), Field.Store.NO)); } if (user.getFirstname() != null) { doc.add(new StringField(FIELD_FIRSTNAME, user.getFirstname(), Field.Store.NO)); } if (user.getLastname() != null) { doc.add(new StringField(FIELD_LASTNAME, user.getLastname(), Field.Store.NO)); } if (user.getEmail() != null) { doc.add(new StringField(FIELD_EMAIL, user.getEmail(), Field.Store.NO)); } return doc; }
@Override public Collection<User> search(String query) { return userService .search(query, new PageableImpl(1, 20)) .getContent() .stream() .filter(userEntity -> !userEntity.getSource().equalsIgnoreCase("ldap") && !userEntity.getSource().equalsIgnoreCase("memory")) .map((Function<UserEntity, User>) RepositoryUser::new) .collect(Collectors.toList()); } }
userDetails.setFirstname(details.getFirstname()); userDetails.setLastname(details.getLastname()); userDetails.setSource(userEntity.getSource()); userDetails.setSourceId(userEntity.getSourceId());
@Override protected UserDetails retrieveUser(String username, UsernamePasswordAuthenticationToken authentication) throws AuthenticationException { try { UserEntity user = userService.findBySource(RepositoryIdentityProvider.PROVIDER_TYPE, username, true); if (RepositoryIdentityProvider.PROVIDER_TYPE.equals(user.getSource())) { if (user.getPassword() == null) { throw new BadCredentialsException(messages.getMessage( "AbstractUserDetailsAuthenticationProvider.badCredentials", "Bad credentials")); } return mapUserEntityToUserDetails(user); } else { throw new UserNotFoundException(username); } } catch (UserNotFoundException notFound) { throw new UsernameNotFoundException(String.format("User '%s' not found", username), notFound); } catch (Exception repositoryProblem) { LOGGER.error("Failed to retrieveUser : {}", username, repositoryProblem); throw new InternalAuthenticationServiceException(repositoryProblem.getMessage(), repositoryProblem); } }
Member member = new Member(); member.setRole(m.getRole()); member.setSource(userEntity.getSource()); member.setSourceId(userEntity.getSourceId()); members.add(member);
@Override protected UserDetails retrieveUser(String username, UsernamePasswordAuthenticationToken authentication) throws AuthenticationException { try { UserEntity user = userService.findBySource(RepositoryIdentityProvider.PROVIDER_TYPE, username, true); if (RepositoryIdentityProvider.PROVIDER_TYPE.equals(user.getSource())) { if (user.getPassword() == null) { throw new BadCredentialsException(messages.getMessage( "AbstractUserDetailsAuthenticationProvider.badCredentials", "Bad credentials")); } return mapUserEntityToUserDetails(user); } else { throw new UserNotFoundException(username); } } catch (UserNotFoundException notFound) { throw new UsernameNotFoundException(String.format("User '%s' not found", username), notFound); } catch (Exception repositoryProblem) { LOGGER.error("Failed to retrieveUser : {}", username, repositoryProblem); throw new InternalAuthenticationServiceException(repositoryProblem.getMessage(), repositoryProblem); } }
userDetails.setFirstname(details.getFirstname()); userDetails.setLastname(details.getLastname()); userDetails.setSource(userEntity.getSource()); userDetails.setSourceId(userEntity.getSourceId());
Member member = new Member(); member.setRole(m.getRole()); member.setSource(userEntity.getSource()); member.setSourceId(userEntity.getSourceId()); members.add(member);
UserEntity userEntity = userService.findById(member.getId()); if (userEntity != null) { return new MemberToImport(userEntity.getSource(), userEntity.getSourceId(), member.getRole());
UserEntity userEntity = userService.findById(member.getId()); if (userEntity != null) { return new MemberToImport(userEntity.getSource(), userEntity.getSourceId(), member.getRole());