package at.gv.egiz.eaaf.utils.springboot.security; import java.util.List; import org.apache.commons.lang3.StringUtils; import lombok.Builder; import lombok.Getter; import lombok.Singular; /** * Simple user configuration object. * * @author tlenz * */ @Builder @Getter public class BasicAuthUser { /** * Username of an entity. */ private final String username; /** * Password of an entity. */ private final String password; /** * Roles of an entity. */ @Singular private List roles; /** * Get roles as Array. * * @return Array of roles */ public String[] getRolesArray() { return roles.stream().toArray(String[]::new); } /** * Check if username, password are not blank and roles is not empty. * * @return true if it looks like a valid user */ public boolean isValid() { return StringUtils.isNotBlank(username) && StringUtils.isNotBlank(password) && !roles.isEmpty(); } }