use of org.summerb.users.api.exceptions.UserNotFoundException in project summerb by skarpushin.
the class AuthTokenServiceImpl method validateAndGetUser.
private User validateAndGetUser(String userEmail, String passwordPlain) throws UserNotFoundException, FieldValidationException, InvalidPasswordException {
try {
User user = userService.getUserByEmail(userEmail);
boolean isPasswordValid = passwordService.isUserPasswordValid(user.getUuid(), passwordPlain);
if (!isPasswordValid) {
throw new InvalidPasswordException();
}
return user;
} catch (Throwable t) {
Throwables.throwIfInstanceOf(t, UserNotFoundException.class);
Throwables.throwIfInstanceOf(t, FieldValidationException.class);
Throwables.throwIfInstanceOf(t, InvalidPasswordException.class);
String msg = String.format("Failed to validate user '%s' and password '%s'", userEmail, passwordPlain);
throw new UserServiceUnexpectedException(msg, t);
}
}
use of org.summerb.users.api.exceptions.UserNotFoundException in project summerb by skarpushin.
the class UserCachedTest method testDeleteUser_expectUserNotFoundException.
// (expected=UserNotFoundException.class)
@Test
public void testDeleteUser_expectUserNotFoundException() throws Exception {
User userToCreate = UserFactory.createNewUserTemplate();
userToCreate = userService.createUser(userToCreate);
userService.getUserByUuid(userToCreate.getUuid());
userService.deleteUserByUuid(userToCreate.getUuid());
try {
userService.getUserByUuid(userToCreate.getUuid());
fail();
} catch (UserNotFoundException e) {
}
}
use of org.summerb.users.api.exceptions.UserNotFoundException in project summerb by skarpushin.
the class UserDetailsServiceDefaultImpl method loadUserByUsername.
@Override
public UserDetails loadUserByUsername(String userEmail) throws UsernameNotFoundException {
try {
User user = userService.getUserByEmail(userEmail);
List<String> permissions = permissionService.findUserPermissionsForSubject(SecurityConstants.DOMAIN, user.getUuid(), null);
AuthToken authToken = null;
UserDetailsImpl ret = new UserDetailsImpl(user, null, permissions, authToken);
return ret;
} catch (UserNotFoundException e) {
throw new UsernameNotFoundException("User not found", e);
} catch (FieldValidationException e) {
throw new UsernameNotFoundException("Email provided in invalid format", e);
} catch (Throwable t) {
throw new UsernameNotFoundException("Failed to get user by email", t);
}
}
use of org.summerb.users.api.exceptions.UserNotFoundException in project summerb by skarpushin.
the class UsersServiceFacadeImpl method getUserStatusByEmail.
@Override
public UserStatus getUserStatusByEmail(String email) throws FieldValidationException {
ValidationContext ctx = new ValidationContext();
ctx.validateNotEmpty(email, LoginParams.FN_EMAIL);
ctx.throwIfHasErrors();
// Check if user have record
User user = null;
try {
user = userService.getUserByEmail(email);
} catch (UserNotFoundException nfe) {
return UserStatus.NotExists;
}
// Check if user has ROLE_USER
List<String> permissions = permissionService.findUserPermissionsForSubject(SecurityConstants.DOMAIN, user.getUuid(), null);
if (permissions.contains(SecurityConstants.ROLE_USER)) {
return UserStatus.NormalUser;
}
if (permissions.contains(SecurityConstants.MARKER_AWAITING_ACTIVATION)) {
return UserStatus.AwaitingActivation;
}
return UserStatus.Provisioned;
}
Aggregations