Search in sources :

Example 6 with StatusEntity

use of org.usermanagement.dao.entity.StatusEntity in project open-kilda by telstra.

the class UserService method createSamlUser.

/**
 * Creates the saml user.
 * @param username the username
 * @param roles the user roles
 */
public void createSamlUser(String username, Set<RoleEntity> roles) {
    UserEntity userEntity = new UserEntity();
    userEntity.setUsername(username);
    userEntity.setEmail(username);
    userEntity.setName(username);
    userEntity.setRoles(roles);
    userEntity.setActiveFlag(true);
    userEntity.setLoginTime(new Timestamp(System.currentTimeMillis()));
    userEntity.setLogoutTime(new Timestamp(System.currentTimeMillis()));
    userEntity.setIsAuthorized(true);
    userEntity.setIs2FaEnabled(false);
    userEntity.setIs2FaConfigured(false);
    StatusEntity statusEntity = Status.ACTIVE.getStatusEntity();
    userEntity.setStatusEntity(statusEntity);
    String password = ValidatorUtil.randomAlphaNumeric(16);
    userEntity.setPassword(StringUtil.encodeString(password));
    userRepository.save(userEntity);
}
Also used : Timestamp(java.sql.Timestamp) StatusEntity(org.usermanagement.dao.entity.StatusEntity) UserEntity(org.usermanagement.dao.entity.UserEntity)

Aggregations

StatusEntity (org.usermanagement.dao.entity.StatusEntity)6 Timestamp (java.sql.Timestamp)2 Date (java.util.Date)2 UserEntity (org.usermanagement.dao.entity.UserEntity)2 PermissionEntity (org.usermanagement.dao.entity.PermissionEntity)1 RoleEntity (org.usermanagement.dao.entity.RoleEntity)1