Search in sources :

Example 21 with UserEntity

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

the class UserConversionUtil method toUserEntity.

/**
 * To user entity.
 *
 * @param userInfo the user info
 * @param roleEntities the role entities
 * @return the user entity
 */
public static UserEntity toUserEntity(final UserInfo userInfo, final Set<RoleEntity> roleEntities) {
    UserEntity userEntity = new UserEntity();
    userEntity.setUsername(userInfo.getUsername().toLowerCase());
    userEntity.setPassword(StringUtil.encodeString(password));
    userEntity.setEmail(userInfo.getEmail().toLowerCase());
    userEntity.setName(userInfo.getName());
    userEntity.setRoles(roleEntities);
    userEntity.setActiveFlag(true);
    userEntity.setLoginTime(new Timestamp(System.currentTimeMillis()));
    userEntity.setLogoutTime(new Timestamp(System.currentTimeMillis()));
    userEntity.setIsAuthorized(true);
    userEntity.setIs2FaEnabled(true);
    userEntity.setIs2FaConfigured(false);
    StatusEntity statusEntity = Status.ACTIVE.getStatusEntity();
    userEntity.setStatusEntity(statusEntity);
    return userEntity;
}
Also used : Timestamp(java.sql.Timestamp) StatusEntity(org.usermanagement.dao.entity.StatusEntity) UserEntity(org.usermanagement.dao.entity.UserEntity)

Aggregations

UserEntity (org.usermanagement.dao.entity.UserEntity)21 Transactional (org.springframework.transaction.annotation.Transactional)10 RequestValidationException (org.usermanagement.exception.RequestValidationException)8 InvalidOtpException (org.openkilda.exception.InvalidOtpException)6 OtpRequiredException (org.openkilda.exception.OtpRequiredException)6 TwoFaKeyNotSetException (org.openkilda.exception.TwoFaKeyNotSetException)6 UsernameNotFoundException (org.springframework.security.core.userdetails.UsernameNotFoundException)5 RoleEntity (org.usermanagement.dao.entity.RoleEntity)5 AccessDeniedException (java.nio.file.AccessDeniedException)4 HashMap (java.util.HashMap)4 HashSet (java.util.HashSet)4 UserInfo (org.usermanagement.model.UserInfo)4 Timestamp (java.sql.Timestamp)3 Authentication (org.springframework.security.core.Authentication)3 ArrayList (java.util.ArrayList)2 BadCredentialsException (org.springframework.security.authentication.BadCredentialsException)2 UsernamePasswordAuthenticationToken (org.springframework.security.authentication.UsernamePasswordAuthenticationToken)2 PermissionEntity (org.usermanagement.dao.entity.PermissionEntity)2 StatusEntity (org.usermanagement.dao.entity.StatusEntity)2 Permission (org.usermanagement.model.Permission)2