use of de.symeda.sormas.api.AuthProvider in project SORMAS-Project by hzi-braunschweig.
the class StartupShutdownService method syncUsers.
/**
* Synchronizes all active users with the external Authentication Provider if User Sync at startup is enabled and supported.
*
* @see AuthProvider#isUserSyncSupported()
* @see AuthProvider#isUserSyncAtStartupEnabled()
*/
private void syncUsers() {
AuthProvider authProvider = AuthProvider.getProvider(configFacade);
if (!authProvider.isUserSyncSupported()) {
logger.info("Active Authentication Provider {} doesn't support user sync", authProvider.getName());
return;
}
if (!authProvider.isUserSyncAtStartupEnabled()) {
logger.info("User sync at startup is disabled. Enable this in SORMAS properties if the active Authentication Provider supports it");
return;
}
List<User> users = userService.getAllActive();
for (User user : users) {
syncUser(user);
}
logger.info("User synchronization finalized");
}
use of de.symeda.sormas.api.AuthProvider in project SORMAS-Project by hzi-braunschweig.
the class UserFacadeEjbTest method testGetValidLoginRoles.
@Test
public void testGetValidLoginRoles() {
AuthProvider authProvider = mock(AuthProvider.class);
MockedStatic<AuthProvider> mockAuthProvider = mockStatic(AuthProvider.class);
Mockito.when(AuthProvider.getProvider(any())).thenReturn(authProvider);
RDCF rdcf = creator.createRDCF();
UserDto user = creator.createUser(rdcf, SURVEILLANCE_SUPERVISOR);
String password = getUserFacade().resetPassword(user.getUuid());
Set<UserRole> validLoginRoles = getUserFacade().getValidLoginRoles(user.getUserName(), password);
assertThat(validLoginRoles, containsInAnyOrder(SURVEILLANCE_SUPERVISOR));
user.setActive(false);
getUserFacade().saveUser(user);
validLoginRoles = getUserFacade().getValidLoginRoles(user.getUserName(), password);
assertThat(validLoginRoles, nullValue());
// Important: release static mock.
mockAuthProvider.closeOnDemand();
}
use of de.symeda.sormas.api.AuthProvider in project SORMAS-Project by hzi-braunschweig.
the class UserServiceTest method beforeClass.
@BeforeClass
public static void beforeClass() {
AuthProvider authProvider = mock(AuthProvider.class);
mockAuthProvider = mockStatic(AuthProvider.class);
assertNotNull(mockAuthProvider);
Mockito.when(AuthProvider.getProvider(any())).thenReturn(authProvider);
}
Aggregations