Search in sources :

Example 1 with StatusEntity

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

the class RoleConversionUtil method toUpateRoleEntity.

/**
 * To upate role entity.
 *
 * @param role the role
 * @param roleEntity the role entity
 * @return the role entity
 */
public static RoleEntity toUpateRoleEntity(final Role role, final RoleEntity roleEntity) {
    if (!ValidatorUtil.isNull(role.getStatus())) {
        StatusEntity newStatusEntity = Status.getStatusByName(role.getStatus()).getStatusEntity();
        roleEntity.setStatusEntity(newStatusEntity);
    }
    if (!ValidatorUtil.isNull(role.getName())) {
        roleEntity.setName(role.getName());
    }
    if (!ValidatorUtil.isNull(role.getDescription())) {
        roleEntity.setDescription(role.getDescription());
    }
    roleEntity.setCreatedDate(new Date());
    roleEntity.setUpdatedDate(new Date());
    return roleEntity;
}
Also used : StatusEntity(org.usermanagement.dao.entity.StatusEntity) Date(java.util.Date)

Example 2 with StatusEntity

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

the class PermissionConversionUtil method toUpatePermissionEntity.

/**
 * To upate permission entity.
 *
 * @param permission the permission
 * @param permissionEntity the permission entity
 * @return the permission entity
 */
public static PermissionEntity toUpatePermissionEntity(final Permission permission, final PermissionEntity permissionEntity) {
    if (!ValidatorUtil.isNull(permission.getStatus())) {
        StatusEntity newStatusEntity = Status.getStatusByName(permission.getStatus()).getStatusEntity();
        permissionEntity.setStatusEntity(newStatusEntity);
    }
    if (!ValidatorUtil.isNull(permission.getName())) {
        permissionEntity.setName(permission.getName());
    }
    if (!ValidatorUtil.isNull(permission.getDescription())) {
        permissionEntity.setDescription(permission.getDescription());
    }
    if (!ValidatorUtil.isNull(permission.getIsAdminPermission())) {
        permissionEntity.setIsAdminPermission(permission.getIsAdminPermission());
    }
    permissionEntity.setCreatedDate(new Date());
    permissionEntity.setUpdatedDate(new Date());
    return permissionEntity;
}
Also used : StatusEntity(org.usermanagement.dao.entity.StatusEntity) Date(java.util.Date)

Example 3 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)

Example 4 with StatusEntity

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

the class RoleConversionUtil method toRoleEntity.

/**
 * To role entity.
 *
 * @param role the role
 * @param permissionEntitySet the permission entity set
 * @return the role entity
 */
public static RoleEntity toRoleEntity(final Role role, final Set<PermissionEntity> permissionEntitySet) {
    RoleEntity roleEntity = new RoleEntity();
    roleEntity.setName(role.getName());
    roleEntity.setPermissions(permissionEntitySet);
    roleEntity.setDescription(role.getDescription());
    StatusEntity statusEntity = Status.ACTIVE.getStatusEntity();
    roleEntity.setStatusEntity(statusEntity);
    return roleEntity;
}
Also used : RoleEntity(org.usermanagement.dao.entity.RoleEntity) StatusEntity(org.usermanagement.dao.entity.StatusEntity)

Example 5 with StatusEntity

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

the class PermissionConversionUtil method toPermissionEntity.

/**
 * To permission entity.
 *
 * @param permission the permission
 * @return the permission entity
 */
public static PermissionEntity toPermissionEntity(final Permission permission) {
    PermissionEntity permissionEntity = new PermissionEntity();
    permissionEntity.setName(permission.getName());
    permissionEntity.setDescription(permission.getDescription());
    permissionEntity.setIsEditable(permission.getIsEditable());
    permissionEntity.setIsAdminPermission(permission.getIsAdminPermission());
    StatusEntity statusEntity = Status.ACTIVE.getStatusEntity();
    permissionEntity.setStatusEntity(statusEntity);
    return permissionEntity;
}
Also used : PermissionEntity(org.usermanagement.dao.entity.PermissionEntity) StatusEntity(org.usermanagement.dao.entity.StatusEntity)

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