Search in sources :

Example 21 with RoleEntity

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

the class UserConversionUtil method toUserInfo.

/**
 * To user info.
 *
 * @param userEntity the user entity
 * @return the user info
 */
public static UserInfo toUserInfo(final UserEntity userEntity) {
    UserInfo userInfo = null;
    if (userEntity != null) {
        userInfo = new UserInfo();
        userInfo.setName(userEntity.getName());
        userInfo.setEmail(userEntity.getEmail().toLowerCase());
        userInfo.setUsername(userEntity.getUsername().toLowerCase());
        userInfo.setIs2FaEnabled(userEntity.getIs2FaEnabled());
        userInfo.setStatus(userEntity.getStatusEntity().getStatus());
        userInfo.setUserId(userEntity.getUserId());
        Set<String> roles = new HashSet<>();
        if (!ValidatorUtil.isNull(userEntity.getRoles())) {
            for (RoleEntity roleEntity : userEntity.getRoles()) {
                roles.add(roleEntity.getName());
            }
            userInfo.setRoles(roles);
        }
    }
    return userInfo;
}
Also used : RoleEntity(org.usermanagement.dao.entity.RoleEntity) UserInfo(org.usermanagement.model.UserInfo) HashSet(java.util.HashSet)

Aggregations

RoleEntity (org.usermanagement.dao.entity.RoleEntity)21 Transactional (org.springframework.transaction.annotation.Transactional)12 RequestValidationException (org.usermanagement.exception.RequestValidationException)10 PermissionEntity (org.usermanagement.dao.entity.PermissionEntity)7 HashSet (java.util.HashSet)5 UserEntity (org.usermanagement.dao.entity.UserEntity)5 Role (org.usermanagement.model.Role)4 ArrayList (java.util.ArrayList)3 UserInfo (org.usermanagement.model.UserInfo)3 SamlConfigEntity (org.openkilda.saml.dao.entity.SamlConfigEntity)2 SamlConfig (org.openkilda.saml.model.SamlConfig)2 Permission (org.usermanagement.model.Permission)2 AccessDeniedException (java.nio.file.AccessDeniedException)1 HashMap (java.util.HashMap)1 InvalidOtpException (org.openkilda.exception.InvalidOtpException)1 OtpRequiredException (org.openkilda.exception.OtpRequiredException)1 TwoFaKeyNotSetException (org.openkilda.exception.TwoFaKeyNotSetException)1 NameID (org.opensaml.saml2.core.NameID)1 MetadataProviderException (org.opensaml.saml2.metadata.provider.MetadataProviderException)1 AnonymousAuthenticationToken (org.springframework.security.authentication.AnonymousAuthenticationToken)1