All Downloads are FREE. Search and download functionalities are using the official Maven repository.

br.com.m4rc310.gql.security.UserPrincipal Maven / Gradle / Ivy

There is a newer version: 1.0.44
Show newest version
package br.com.m4rc310.gql.security;

import java.io.Serializable;
import java.util.Collection;
import java.util.Objects;
import java.util.stream.Collectors;

import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;

import br.com.m4rc310.gql.dto.MUser;
import lombok.Data;

/**
 * 

UserPrincipal class.

* * @author marcelo * @version $Id: $Id */ @Data public class UserPrincipal implements Serializable{ private static final long serialVersionUID = 4607336427719715274L; private String username; private String password; private Collection authorities; /** *

Constructor for UserPrincipal.

* * @param user a {@link br.com.m4rc310.gql.dto.MUser} object */ public UserPrincipal(MUser user) { this.username = user.getUsername(); this.password = user.getPassword(); if (Objects.nonNull(user.getRoles())) { this.authorities = user.getAuthorities().stream().map(role -> { return new SimpleGrantedAuthority(role.getAuthority()); }).collect(Collectors.toList()); } } /** *

create.

* * @param user a {@link br.com.m4rc310.gql.dto.MUser} object * @return a {@link br.com.m4rc310.gql.security.UserPrincipal} object */ public static UserPrincipal create(MUser user){ return new UserPrincipal(user); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy