use of org.summerb.users.api.dto.User in project summerb by skarpushin.
the class ElevationStrategyUserBasedImpl method getAuthentication.
private Authentication getAuthentication() {
if (authentication == null) {
try {
User user = userService.getUserByEmail(userEmail);
List<String> permissions = permissionService.findUserPermissionsForSubject(SecurityConstants.DOMAIN, user.getUuid(), null);
UserDetailsImpl userDetails = new UserDetailsImpl(user, "[NO PASSWORD]", permissions, null);
UsernamePasswordAuthenticationToken ret = new UsernamePasswordAuthenticationToken(userDetails, "[NO PASSWORD]", userDetails.getAuthorities());
// NOTE: No details for this kind of authentication
authentication = ret;
} catch (Throwable t) {
throw new RuntimeException("Failed to build Authnetication", t);
}
}
return authentication;
}
use of org.summerb.users.api.dto.User in project summerb by skarpushin.
the class LoginRestController method processPasswordChangeForm.
@Secured({ "ROLE_USER" })
@RequestMapping(method = RequestMethod.POST, value = "change")
public User processPasswordChangeForm(@RequestBody PasswordChange passwordChange) throws UserNotFoundException, FieldValidationException {
User user = securityContextResolver.getUser();
usersServiceFacade.changePassword(user.getEmail(), passwordChange);
return user;
}
use of org.summerb.users.api.dto.User in project summerb by skarpushin.
the class UserServiceImpl method getUserByEmail.
@Override
public User getUserByEmail(String userEmail) throws FieldValidationException, UserNotFoundException {
Assert.notNull(userEmail, "user email must be provided");
validateEmail(userEmail);
User foundUser;
try {
foundUser = userDao.findUserByEmail(userEmail);
} catch (Throwable t) {
String msg = String.format("Failed to find user by email '%s'", userEmail);
throw new UserServiceUnexpectedException(msg, t);
}
if (foundUser == null) {
throw new UserNotFoundException(userEmail);
}
return foundUser;
}
use of org.summerb.users.api.dto.User in project summerb by skarpushin.
the class UserServiceImpl method getUserByUuid.
@Override
public User getUserByUuid(String userUuid) throws UserNotFoundException {
Assert.hasText(userUuid, "userUuid must be provided");
User foundUser;
try {
foundUser = userDao.findUserByUuid(userUuid);
} catch (Throwable t) {
String msg = String.format("Failed to find user '%s'", userUuid);
throw new UserServiceUnexpectedException(msg, t);
}
if (foundUser == null) {
throw new UserNotFoundException(userUuid);
}
return foundUser;
}
use of org.summerb.users.api.dto.User in project summerb by skarpushin.
the class UserServiceImpl method deleteUserByUuid.
@Override
@Transactional(rollbackFor = Throwable.class)
public void deleteUserByUuid(String userUuid) throws UserNotFoundException {
Preconditions.checkArgument(userUuid != null, "User uuid required");
Preconditions.checkArgument(StringUtils.hasText(userUuid), "User uuid must be provided");
boolean isDeletedSucceessfully = false;
try {
User userToDelete = userDao.findUserByUuid(userUuid);
if (userToDelete != null) {
isDeletedSucceessfully = userDao.deleteUser(userUuid);
// NOTE: Assumed, that all related stuff will be deleted
// automatically using CASCADE DELETE in the database
eventBus.post(EntityChangedEvent.removedObject(userToDelete));
}
} catch (Throwable t) {
String msg = String.format("Failed to delete user '%s'", userUuid);
throw new UserServiceUnexpectedException(msg, t);
}
if (!isDeletedSucceessfully) {
throw new UserNotFoundException(userUuid);
}
}
Aggregations