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

net.n2oapp.security.admin.impl.userinfo.RolesEnricher Maven / Gradle / Ivy

There is a newer version: 8.0.1
Show newest version
package net.n2oapp.security.admin.impl.userinfo;

import net.n2oapp.security.admin.api.oauth.UserInfoEnricher;
import net.n2oapp.security.admin.impl.entity.AccountEntity;
import net.n2oapp.security.admin.impl.entity.RoleEntity;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.stream.Collectors;

@Component
public class RolesEnricher implements UserInfoEnricher {
    @Override
    public Object buildValue(AccountEntity source) {
        List roles = source.getRoleList();
        if (roles == null || roles.isEmpty())
            return null;
        return source.getRoleList().stream().map(RoleEntity::getCode).collect(Collectors.toList());
    }

    @Override
    public String getAlias() {
        return "roles";
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy