Search in sources :

Example 1 with NewUser

use of org.simbasecurity.core.service.communication.reset.password.NewUser in project simba-os by cegeka.

the class UserFactory method createRestUser.

public String createRestUser(String username) {
    UserEntity temporaryUser = UserEntity.restUser(username, Language.nl_NL);
    User newUser = createRestUser(temporaryUser);
    User attachedUser = userRepository.persist(newUser);
    String password = passwordGenerator.generatePassword();
    attachedUser.changePassword(password, password);
    managementAudit.log("REST User ''{0}'' created", username);
    return password;
}
Also used : User(org.simbasecurity.core.domain.User) NewUser(org.simbasecurity.core.service.communication.reset.password.NewUser) UserEntity(org.simbasecurity.core.domain.UserEntity)

Example 2 with NewUser

use of org.simbasecurity.core.service.communication.reset.password.NewUser in project simba-os by cegeka.

the class UserFactory method create.

public User create(User user) {
    User newUser = createUser(user);
    managementAudit.log("User ''{0}'' created", user.getUserName());
    return newUser;
}
Also used : User(org.simbasecurity.core.domain.User) NewUser(org.simbasecurity.core.service.communication.reset.password.NewUser)

Example 3 with NewUser

use of org.simbasecurity.core.service.communication.reset.password.NewUser in project simba-os by cegeka.

the class UserFactory method createWithRoles.

public User createWithRoles(User user, List<String> roleNames) {
    User newUser = createUser(user);
    roleNames.stream().map(n -> roleRepository.findByName(n)).filter(Objects::nonNull).forEach(newUser::addRole);
    managementAudit.log("User ''{0}'' created with roles ''{1}''", newUser.getUserName(), join(roleNames, r -> r));
    return newUser;
}
Also used : UserEntity(org.simbasecurity.core.domain.UserEntity) StringUtils(org.apache.commons.lang.StringUtils) RoleRepository(org.simbasecurity.core.domain.repository.RoleRepository) USER_ALREADY_EXISTS(org.simbasecurity.core.exception.SimbaMessageKey.USER_ALREADY_EXISTS) SimbaConfigurationParameter(org.simbasecurity.core.config.SimbaConfigurationParameter) Autowired(org.springframework.beans.factory.annotation.Autowired) EmailFactory(org.simbasecurity.core.domain.user.EmailFactory) User(org.simbasecurity.core.domain.User) UserEntity.user(org.simbasecurity.core.domain.UserEntity.user) StringUtil.join(org.simbasecurity.common.util.StringUtil.join) Service(org.springframework.stereotype.Service) Status(org.simbasecurity.core.domain.Status) CoreConfigurationService(org.simbasecurity.core.service.config.CoreConfigurationService) SimbaMessageKey(org.simbasecurity.core.exception.SimbaMessageKey) Language(org.simbasecurity.core.domain.Language) NewUser(org.simbasecurity.core.service.communication.reset.password.NewUser) ResetPasswordService(org.simbasecurity.core.service.communication.reset.password.ResetPasswordService) USER_ALREADY_EXISTS_WITH_EMAIL(org.simbasecurity.core.exception.SimbaMessageKey.USER_ALREADY_EXISTS_WITH_EMAIL) ManagementAudit(org.simbasecurity.core.audit.ManagementAudit) SimbaException(org.simbasecurity.core.exception.SimbaException) UserRepository(org.simbasecurity.core.domain.repository.UserRepository) Objects(java.util.Objects) List(java.util.List) PasswordGenerator(org.simbasecurity.core.domain.generator.PasswordGenerator) Transactional(org.springframework.transaction.annotation.Transactional) User(org.simbasecurity.core.domain.User) NewUser(org.simbasecurity.core.service.communication.reset.password.NewUser)

Example 4 with NewUser

use of org.simbasecurity.core.service.communication.reset.password.NewUser in project simba-os by cegeka.

the class UserFactory method createEIDUserWithRoles.

public User createEIDUserWithRoles(User user, List<String> roleNames) {
    validateUniqueUsername(user);
    User newUser = userRepository.persist(user);
    roleNames.stream().map(n -> roleRepository.findByName(n)).filter(Objects::nonNull).forEach(newUser::addRole);
    managementAudit.log("User ''{0}'' created with roles ''{1}''", newUser.getUserName(), join(roleNames, r -> r));
    return newUser;
}
Also used : UserEntity(org.simbasecurity.core.domain.UserEntity) StringUtils(org.apache.commons.lang.StringUtils) RoleRepository(org.simbasecurity.core.domain.repository.RoleRepository) USER_ALREADY_EXISTS(org.simbasecurity.core.exception.SimbaMessageKey.USER_ALREADY_EXISTS) SimbaConfigurationParameter(org.simbasecurity.core.config.SimbaConfigurationParameter) Autowired(org.springframework.beans.factory.annotation.Autowired) EmailFactory(org.simbasecurity.core.domain.user.EmailFactory) User(org.simbasecurity.core.domain.User) UserEntity.user(org.simbasecurity.core.domain.UserEntity.user) StringUtil.join(org.simbasecurity.common.util.StringUtil.join) Service(org.springframework.stereotype.Service) Status(org.simbasecurity.core.domain.Status) CoreConfigurationService(org.simbasecurity.core.service.config.CoreConfigurationService) SimbaMessageKey(org.simbasecurity.core.exception.SimbaMessageKey) Language(org.simbasecurity.core.domain.Language) NewUser(org.simbasecurity.core.service.communication.reset.password.NewUser) ResetPasswordService(org.simbasecurity.core.service.communication.reset.password.ResetPasswordService) USER_ALREADY_EXISTS_WITH_EMAIL(org.simbasecurity.core.exception.SimbaMessageKey.USER_ALREADY_EXISTS_WITH_EMAIL) ManagementAudit(org.simbasecurity.core.audit.ManagementAudit) SimbaException(org.simbasecurity.core.exception.SimbaException) UserRepository(org.simbasecurity.core.domain.repository.UserRepository) Objects(java.util.Objects) List(java.util.List) PasswordGenerator(org.simbasecurity.core.domain.generator.PasswordGenerator) Transactional(org.springframework.transaction.annotation.Transactional) User(org.simbasecurity.core.domain.User) NewUser(org.simbasecurity.core.service.communication.reset.password.NewUser)

Example 5 with NewUser

use of org.simbasecurity.core.service.communication.reset.password.NewUser in project simba-os by cegeka.

the class UserFactory method cloneUser.

public User cloneUser(User user, String clonedUsername) {
    User newUser = createUser(user);
    newUser.addRoles(userRepository.findByName(clonedUsername).getRoles());
    managementAudit.log("User ''{0}'' created as clone of ''{1}''", newUser.getUserName(), clonedUsername);
    return newUser;
}
Also used : User(org.simbasecurity.core.domain.User) NewUser(org.simbasecurity.core.service.communication.reset.password.NewUser)

Aggregations

User (org.simbasecurity.core.domain.User)5 NewUser (org.simbasecurity.core.service.communication.reset.password.NewUser)5 UserEntity (org.simbasecurity.core.domain.UserEntity)3 List (java.util.List)2 Objects (java.util.Objects)2 StringUtils (org.apache.commons.lang.StringUtils)2 StringUtil.join (org.simbasecurity.common.util.StringUtil.join)2 ManagementAudit (org.simbasecurity.core.audit.ManagementAudit)2 SimbaConfigurationParameter (org.simbasecurity.core.config.SimbaConfigurationParameter)2 Language (org.simbasecurity.core.domain.Language)2 Status (org.simbasecurity.core.domain.Status)2 UserEntity.user (org.simbasecurity.core.domain.UserEntity.user)2 PasswordGenerator (org.simbasecurity.core.domain.generator.PasswordGenerator)2 RoleRepository (org.simbasecurity.core.domain.repository.RoleRepository)2 UserRepository (org.simbasecurity.core.domain.repository.UserRepository)2 EmailFactory (org.simbasecurity.core.domain.user.EmailFactory)2 SimbaException (org.simbasecurity.core.exception.SimbaException)2 SimbaMessageKey (org.simbasecurity.core.exception.SimbaMessageKey)2 USER_ALREADY_EXISTS (org.simbasecurity.core.exception.SimbaMessageKey.USER_ALREADY_EXISTS)2 USER_ALREADY_EXISTS_WITH_EMAIL (org.simbasecurity.core.exception.SimbaMessageKey.USER_ALREADY_EXISTS_WITH_EMAIL)2