Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
1.5 kB
2
Indexable
Never
    @Transactional
    public void loadAbrangencia(String domain, String service) {
        Boolean isSecuredResource = initCache(domain, service);
        securedResource.set(isSecuredResource);
    }
    
    @Transactional
    public Boolean initCache(String domain, String service) {
        Boolean isSecuredResource = Boolean.FALSE;
        if (providers == null) {
            return isSecuredResource;
        }
        for (AbrangenciaProvider abrangenciaProvider : providers) {
            AbrangenciaKey key = new AbrangenciaKey();
            key.setTenant(tenantSupplier.get());
            key.setUserName(userSupplier.get());
            key.setProviderName(abrangenciaProvider.getName());

            if (getCacheUsuarioAbrangencia().containsKey(key)) {
                getCacheUsuarioAbrangencia().remove(key);
            }
            
            Filter filter = abrangenciaProvider.getFilter(authorizationAdapter.getFilters(domain, service, userSupplier.get()));
            if (Objects.nonNull(filter)) {
                getCacheUsuarioAbrangencia().put(key, filter);
                log.debug("loadAbrangencia --- {} - {} - {}", key.getTenant(), key.getUserName(), key.getProviderName());
                isSecuredResource = Boolean.TRUE;
            } else {
                isSecuredResource = Boolean.FALSE;                        
            }
        }
        return isSecuredResource;
    }
Leave a Comment