use of org.summerb.microservices.users.api.dto.AuthToken in project summerb by skarpushin.
the class AuthTokenServiceDbImplTest method testIsAuthTokenValid_whitebox_expectFalseForUnmatchedAuthTOken.
@Test
public void testIsAuthTokenValid_whitebox_expectFalseForUnmatchedAuthTOken() throws Exception {
AuthTokenServiceImpl fixture = AuthTokenServiceDbImplFactory.createAuthTokenServiceDbImpl();
AuthToken result = fixture.isAuthTokenValid(UserFactory.EXISTENT_USER, AuthTokenFactory.AUTH_TOKEN_EXPIRED, "...");
assertNull(result);
}
use of org.summerb.microservices.users.api.dto.AuthToken in project summerb by skarpushin.
the class AuthTokenServiceDbImplTest method testIsAuthTokenValid_blackbox_expectFalseEvenForNonExistentToken.
@Test
public void testIsAuthTokenValid_blackbox_expectFalseEvenForNonExistentToken() throws Exception {
AuthTokenServiceImpl fixture = AuthTokenServiceDbImplFactory.createAuthTokenServiceDbImpl();
AuthToken result = fixture.isAuthTokenValid(UserFactory.EXISTENT_USER, AuthTokenFactory.AUTH_TOKEN_NOT_EXISTENT, "...");
assertNull(result);
}
use of org.summerb.microservices.users.api.dto.AuthToken in project summerb by skarpushin.
the class AuthTokenServiceDbImplTest method testCreateAuthToken_blackbox_expectNewAuthToken.
@Test
public void testCreateAuthToken_blackbox_expectNewAuthToken() throws Exception {
AuthTokenService fixture = AuthTokenServiceDbImplFactory.createAuthTokenServiceDbImpl();
AuthToken result = fixture.authenticate(UserFactory.EXISTENT_USER_EMAIL, PasswordFactory.RIGHT_PASSWORD_FOR_EXISTENT_USER, "0.0.0.0");
assertNotNull(result);
}
use of org.summerb.microservices.users.api.dto.AuthToken in project summerb by skarpushin.
the class PersistentTokenRepositoryDefaultImpl method getTokenForSeries.
@Override
public PersistentRememberMeToken getTokenForSeries(String seriesId) {
try {
AuthToken authToken = authTokenService.getAuthTokenByUuid(seriesId);
User user = userService.getUserByUuid(authToken.getUserUuid());
return new PersistentRememberMeToken(user.getEmail(), authToken.getUuid(), authToken.getTokenValue(), new Date(authToken.getLastVerifiedAt()));
} catch (Throwable e) {
log.info("Persistent auth token wasn't found for seriesId " + seriesId);
return null;
}
}
use of org.summerb.microservices.users.api.dto.AuthToken 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);
}
}
Aggregations