use of com.synopsys.integration.alert.common.persistence.model.UserModel in project hub-alert by blackducksoftware.
the class ConfigurationOverridesStartupComponent method checkAndResetDefaultAdminPassword.
private void checkAndResetDefaultAdminPassword() throws AlertException {
boolean disable = isEnvironmentVariableActivated(ENV_VAR_ADMIN_USER_PASSWORD_RESET);
if (disable) {
UserModel userModel = userAccessor.getUser(UserAccessor.DEFAULT_ADMIN_USER_ID).orElseThrow(() -> new AlertException("The default admin user was not found."));
logger.info("Resetting the password for the user '{}'.", userModel.getName());
UserModel newModel = UserModel.existingUser(userModel.getId(), userModel.getName(), DEFAULT_ADMIN_PASSWORD, userModel.getEmailAddress(), userModel.getAuthenticationType(), userModel.getRoles(), userModel.isEnabled());
userAccessor.updateUser(newModel, true);
}
}
use of com.synopsys.integration.alert.common.persistence.model.UserModel in project hub-alert by blackducksoftware.
the class UserDetailsServiceTest method initializeAuthoritiesPopulator.
@BeforeEach
public void initializeAuthoritiesPopulator() {
Set<UserRoleModel> roles = Arrays.stream(VALID_DB_ROLES).map(UserRoleModel::of).collect(Collectors.toSet());
UserModel userModel = UserModel.newUser(USER_NAME, "password", EMAIL, AuthenticationType.SAML, roles, true);
AuthenticationDescriptorKey key = new AuthenticationDescriptorKey();
ConfigurationModelConfigurationAccessor configurationModelConfigurationAccessor = Mockito.mock(ConfigurationModelConfigurationAccessor.class);
ConfigurationModel configuration = Mockito.mock(ConfigurationModel.class);
UserAccessor userAccessor = Mockito.mock(UserAccessor.class);
Mockito.when(configuration.getField(Mockito.anyString())).thenReturn(Optional.empty());
Mockito.when(configurationModelConfigurationAccessor.getConfigurationsByDescriptorKey(Mockito.eq(key))).thenReturn(List.of(configuration));
Mockito.when(userAccessor.getUser(Mockito.anyString())).thenReturn(Optional.of(userModel));
authoritiesPopulator = new UserManagementAuthoritiesPopulator(key, configurationModelConfigurationAccessor, userAccessor);
}
Aggregations