Search in sources :

Example 6 with AuthenticationType

use of com.synopsys.integration.alert.common.enumeration.AuthenticationType in project hub-alert by blackducksoftware.

the class DefaultUserAccessor method createModel.

private UserModel createModel(UserEntity user) {
    List<UserRoleRelation> roleRelations = userRoleRepository.findAllByUserId(user.getId());
    List<Long> roleIdsForUser = roleRelations.stream().map(UserRoleRelation::getRoleId).collect(Collectors.toList());
    Set<UserRoleModel> roles = roleAccessor.getRoles(roleIdsForUser);
    AuthenticationType authenticationType = authenticationTypeAccessor.getAuthenticationType(user.getAuthenticationType()).orElse(null);
    return UserModel.existingUser(user.getId(), user.getUserName(), user.getPassword(), user.getEmailAddress(), authenticationType, roles, user.isEnabled());
}
Also used : UserRoleRelation(com.synopsys.integration.alert.database.user.UserRoleRelation) UserRoleModel(com.synopsys.integration.alert.common.persistence.model.UserRoleModel) AuthenticationType(com.synopsys.integration.alert.common.enumeration.AuthenticationType)

Aggregations

AuthenticationType (com.synopsys.integration.alert.common.enumeration.AuthenticationType)6 UserModel (com.synopsys.integration.alert.common.persistence.model.UserModel)4 UserRoleModel (com.synopsys.integration.alert.common.persistence.model.UserRoleModel)4 UserEntity (com.synopsys.integration.alert.database.user.UserEntity)4 UserRoleRelation (com.synopsys.integration.alert.database.user.UserRoleRelation)4 Test (org.junit.jupiter.api.Test)4 AlertConfigurationException (com.synopsys.integration.alert.api.common.model.exception.AlertConfigurationException)2 AlertForbiddenOperationException (com.synopsys.integration.alert.common.exception.AlertForbiddenOperationException)2 AlertRuntimeException (com.synopsys.integration.alert.api.common.model.exception.AlertRuntimeException)1 ValidationActionResponse (com.synopsys.integration.alert.common.action.ValidationActionResponse)1 ConfigContextEnum (com.synopsys.integration.alert.common.enumeration.ConfigContextEnum)1 ValidationResponseModel (com.synopsys.integration.alert.common.rest.model.ValidationResponseModel)1 UserManagementDescriptorKey (com.synopsys.integration.alert.component.users.UserManagementDescriptorKey)1 DescriptorKey (com.synopsys.integration.alert.descriptor.api.model.DescriptorKey)1 Transactional (org.springframework.transaction.annotation.Transactional)1