/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.l7tech.gateway.common.security.rbac.EntityFolderAncestryPredicate
 *  com.l7tech.gateway.common.security.rbac.OperationType
 *  com.l7tech.gateway.common.security.rbac.Permission
 *  com.l7tech.gateway.common.security.rbac.Role
 *  com.l7tech.gateway.common.security.rbac.ScopeEvaluator
 *  com.l7tech.gateway.common.security.rbac.ScopePredicate
 *  com.l7tech.identity.IdentityProvider
 *  com.l7tech.identity.User
 *  com.l7tech.objectmodel.Entity
 *  com.l7tech.objectmodel.EntityHeader
 *  com.l7tech.objectmodel.EntityType
 *  com.l7tech.objectmodel.FindException
 *  com.l7tech.objectmodel.Goid
 *  com.l7tech.objectmodel.OrganizationHeader
 *  com.l7tech.util.ExceptionUtils
 *  com.l7tech.util.Pair
 *  org.jetbrains.annotations.NotNull
 *  org.springframework.beans.BeansException
 *  org.springframework.beans.factory.InitializingBean
 *  org.springframework.context.ApplicationContext
 *  org.springframework.context.ApplicationContextAware
 *  org.springframework.context.ApplicationEvent
 */
package com.l7tech.server.security.rbac;

import com.l7tech.gateway.common.security.rbac.EntityFolderAncestryPredicate;
import com.l7tech.gateway.common.security.rbac.OperationType;
import com.l7tech.gateway.common.security.rbac.Permission;
import com.l7tech.gateway.common.security.rbac.Role;
import com.l7tech.gateway.common.security.rbac.ScopeEvaluator;
import com.l7tech.gateway.common.security.rbac.ScopePredicate;
import com.l7tech.identity.IdentityProvider;
import com.l7tech.identity.User;
import com.l7tech.objectmodel.Entity;
import com.l7tech.objectmodel.EntityHeader;
import com.l7tech.objectmodel.EntityType;
import com.l7tech.objectmodel.FindException;
import com.l7tech.objectmodel.Goid;
import com.l7tech.objectmodel.OrganizationHeader;
import com.l7tech.server.EntityFinder;
import com.l7tech.server.event.EntityInvalidationEvent;
import com.l7tech.server.identity.HasDefaultRole;
import com.l7tech.server.identity.IdentityProviderFactory;
import com.l7tech.server.security.rbac.ProtectedEntityTracker;
import com.l7tech.server.security.rbac.RbacServices;
import com.l7tech.server.security.rbac.RoleManager;
import com.l7tech.server.security.rbac.ScopeEvaluatorFactory;
import com.l7tech.server.security.rbac.c;
import com.l7tech.server.util.PostStartupApplicationListener;
import com.l7tech.util.ExceptionUtils;
import com.l7tech.util.Pair;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.ApplicationEvent;

/*
 * Exception performing whole class analysis ignored.
 */
public class RbacServicesImpl
implements RbacServices,
InitializingBean,
PostStartupApplicationListener,
ApplicationContextAware {
    private static final Logger a;
    private final Map<Class<? extends ScopePredicate>, ScopeEvaluatorFactory> b = new HashMap<Class<? extends ScopePredicate>, ScopeEvaluatorFactory>(){
        static final long serialVersionUID = -3362687384747444434L;
        {
            this.put(EntityFolderAncestryPredicate.class, new c(RbacServicesImpl.this));
        }
    };
    private final Map<ScopePredicate, ScopeEvaluator> c = new ConcurrentHashMap<ScopePredicate, ScopeEvaluator>();
    private RoleManager d;
    private EntityFinder e;
    private ProtectedEntityTracker f;
    private ApplicationContext g;
    private static final String[] h;

    public RbacServicesImpl(RoleManager roleManager, EntityFinder entityFinder, ProtectedEntityTracker protectedEntityTracker) {
        this.d = roleManager;
        this.e = entityFinder;
        this.f = protectedEntityTracker;
    }

    public RbacServicesImpl() {
    }

    @Override
    public boolean isPermittedForEntitiesOfTypes(User user, OperationType operationType, Set<EntityType> set) throws FindException {
        block31: {
            block30: {
                try {
                    if (user == null) {
                        throw new IllegalArgumentException();
                    }
                }
                catch (FindException findException) {
                    throw RbacServicesImpl.a((Exception)((Object)findException));
                }
                try {
                    try {
                        if (set != null && !set.isEmpty()) break block30;
                    }
                    catch (FindException findException) {
                        throw RbacServicesImpl.a((Exception)((Object)findException));
                    }
                    throw new IllegalArgumentException();
                }
                catch (FindException findException) {
                    throw RbacServicesImpl.a((Exception)((Object)findException));
                }
            }
            try {
                try {
                    if (operationType != null && OperationType.ALL_CRUD.contains(operationType)) break block31;
                }
                catch (FindException findException) {
                    throw RbacServicesImpl.a((Exception)((Object)findException));
                }
                throw new IllegalArgumentException();
            }
            catch (FindException findException) {
                throw RbacServicesImpl.a((Exception)((Object)findException));
            }
        }
        HashMap<EntityType, Boolean> hashMap = new HashMap<EntityType, Boolean>();
        for (Role role : this.getAssignedRoles(RbacServicesImpl.a(user), user)) {
            for (Permission permission : role.getPermissions()) {
                try {
                    try {
                        if (permission.getScope() != null && !permission.getScope().isEmpty()) {
                            continue;
                        }
                    }
                    catch (FindException findException) {
                        throw RbacServicesImpl.a((Exception)((Object)findException));
                    }
                }
                catch (FindException findException) {
                    throw RbacServicesImpl.a((Exception)((Object)findException));
                }
                try {
                    if (permission.getOperation() != operationType) {
                        continue;
                    }
                }
                catch (FindException findException) {
                    throw RbacServicesImpl.a((Exception)((Object)findException));
                }
                EntityType entityType = permission.getEntityType();
                try {
                    if (entityType == EntityType.ANY) {
                        return true;
                    }
                }
                catch (FindException findException) {
                    throw RbacServicesImpl.a((Exception)((Object)findException));
                }
                hashMap.put(entityType, true);
            }
        }
        try {
            if (hashMap.isEmpty()) {
                return false;
            }
        }
        catch (FindException findException) {
            throw RbacServicesImpl.a((Exception)((Object)findException));
        }
        for (EntityType entityType : set) {
            Boolean bl2 = (Boolean)hashMap.get(entityType);
            try {
                if (bl2 != null) continue;
                return false;
            }
            catch (FindException findException) {
                throw RbacServicesImpl.a((Exception)((Object)findException));
            }
        }
        return true;
    }

    @Override
    public boolean isPermittedForAnyEntityOfType(User user, OperationType operationType, EntityType entityType) throws FindException {
        block4: {
            try {
                try {
                    if (user != null && entityType != null) break block4;
                }
                catch (FindException findException) {
                    throw RbacServicesImpl.a((Exception)((Object)findException));
                }
                throw new NullPointerException();
            }
            catch (FindException findException) {
                throw RbacServicesImpl.a((Exception)((Object)findException));
            }
        }
        a.log(Level.FINE, h[7], new Object[]{operationType.getName(), entityType.getName()});
        return this.a(user, operationType, entityType, true);
    }

    @Override
    public boolean isPermittedForSomeEntityOfType(User user, OperationType operationType, EntityType entityType) throws FindException {
        block4: {
            try {
                try {
                    if (user != null && entityType != null) break block4;
                }
                catch (FindException findException) {
                    throw RbacServicesImpl.a((Exception)((Object)findException));
                }
                throw new NullPointerException();
            }
            catch (FindException findException) {
                throw RbacServicesImpl.a((Exception)((Object)findException));
            }
        }
        a.log(Level.FINE, h[22], new Object[]{operationType.getName(), entityType.getName()});
        return this.a(user, operationType, entityType, false);
    }

    private boolean a(User user, OperationType operationType, EntityType entityType, boolean bl2) throws FindException {
        for (Role role : this.getAssignedRoles(RbacServicesImpl.a(user), user)) {
            for (Permission permission : role.getPermissions()) {
                block16: {
                    try {
                        try {
                            try {
                                if (!bl2 || permission.getScope() == null) break block16;
                            }
                            catch (FindException findException) {
                                throw RbacServicesImpl.a((Exception)((Object)findException));
                            }
                            if (!permission.getScope().isEmpty()) {
                                continue;
                            }
                        }
                        catch (FindException findException) {
                            throw RbacServicesImpl.a((Exception)((Object)findException));
                        }
                    }
                    catch (FindException findException) {
                        throw RbacServicesImpl.a((Exception)((Object)findException));
                    }
                }
                try {
                    if (permission.getOperation() != operationType) {
                        continue;
                    }
                }
                catch (FindException findException) {
                    throw RbacServicesImpl.a((Exception)((Object)findException));
                }
                EntityType entityType2 = permission.getEntityType();
                try {
                    try {
                        if (entityType2 != EntityType.ANY && entityType2 != entityType) continue;
                    }
                    catch (FindException findException) {
                        throw RbacServicesImpl.a((Exception)((Object)findException));
                    }
                    return true;
                }
                catch (FindException findException) {
                    throw RbacServicesImpl.a((Exception)((Object)findException));
                }
            }
        }
        return false;
    }

    @Override
    public boolean isPermittedForEntity(User user, Entity entity, OperationType operationType, String string) throws FindException {
        block12: {
            block11: {
                try {
                    block10: {
                        try {
                            try {
                                if (user == null || entity == null) break block10;
                            }
                            catch (FindException findException) {
                                throw RbacServicesImpl.a((Exception)((Object)findException));
                            }
                            if (operationType != null) break block11;
                        }
                        catch (FindException findException) {
                            throw RbacServicesImpl.a((Exception)((Object)findException));
                        }
                    }
                    throw new NullPointerException();
                }
                catch (FindException findException) {
                    throw RbacServicesImpl.a((Exception)((Object)findException));
                }
            }
            try {
                try {
                    if (operationType != OperationType.OTHER || string != null) break block12;
                }
                catch (FindException findException) {
                    throw RbacServicesImpl.a((Exception)((Object)findException));
                }
                throw new IllegalArgumentException(h[13]);
            }
            catch (FindException findException) {
                throw RbacServicesImpl.a((Exception)((Object)findException));
            }
        }
        a.log(Level.FINE, String.format(h[17], operationType.getName(), entity.getClass().getSimpleName(), entity.getId()));
        return this.a(this.getAssignedRoles(RbacServicesImpl.a(user), user), entity, operationType, string);
    }

    /*
     * Loose catch block
     * Enabled force condition propagation
     * Lifted jumps to return sites
     */
    @Override
    public <T extends OrganizationHeader> Iterable<T> filterPermittedHeaders(User user, OperationType operationType, Iterable<T> iterable, EntityFinder entityFinder) throws FindException {
        block21: {
            block20: {
                try {
                    if (user == null) {
                        throw new IllegalArgumentException();
                    }
                }
                catch (FindException findException) {
                    throw RbacServicesImpl.a((Exception)((Object)findException));
                }
                if (operationType == null) throw new IllegalArgumentException();
                try {
                    if (OperationType.ALL_CRUD.contains(operationType)) break block20;
                    throw new IllegalArgumentException();
                    catch (FindException findException) {
                        throw RbacServicesImpl.a((Exception)((Object)findException));
                    }
                }
                catch (FindException findException) {
                    throw RbacServicesImpl.a((Exception)((Object)findException));
                }
            }
            if (!this.isPermittedForAnyEntityOfType(user, operationType, EntityType.SERVICE)) break block21;
            try {
                if (!this.isPermittedForAnyEntityOfType(user, operationType, EntityType.POLICY)) break block21;
                return iterable;
                catch (FindException findException) {
                    throw RbacServicesImpl.a((Exception)((Object)findException));
                }
            }
            catch (FindException findException) {
                throw RbacServicesImpl.a((Exception)((Object)findException));
            }
        }
        Collection<Role> collection = this.getAssignedRoles(RbacServicesImpl.a(user), user);
        try {
            if (collection.isEmpty()) {
                return Collections.emptyList();
            }
        }
        catch (FindException findException) {
            throw RbacServicesImpl.a((Exception)((Object)findException));
        }
        LinkedList<OrganizationHeader> linkedList = new LinkedList<OrganizationHeader>();
        for (OrganizationHeader organizationHeader : iterable) {
            Entity entity;
            block22: {
                try {
                    entity = entityFinder.find((EntityHeader)organizationHeader);
                    if (entity == null) {
                    }
                    break block22;
                }
                catch (FindException findException) {
                    a.log(Level.WARNING, MessageFormat.format(h[2], organizationHeader), findException);
                }
                continue;
            }
            try {
                if (!this.a(collection, entity, operationType, null)) continue;
                linkedList.add(organizationHeader);
            }
            catch (FindException findException) {
                throw RbacServicesImpl.a((Exception)((Object)findException));
            }
        }
        return linkedList;
    }

    @Override
    public boolean isAdministrativeUser(@NotNull Pair<Goid, String> pair, @NotNull User user) throws FindException {
        boolean bl2;
        block26: {
            boolean bl3;
            block28: {
                block27: {
                    block25: {
                        try {
                            if (pair == null) {
                                RbacServicesImpl.a(0);
                            }
                        }
                        catch (RoleManager.DisabledGroupRolesException disabledGroupRolesException) {
                            throw RbacServicesImpl.a((Exception)((Object)disabledGroupRolesException));
                        }
                        try {
                            if (user == null) {
                                RbacServicesImpl.a(1);
                            }
                        }
                        catch (RoleManager.DisabledGroupRolesException disabledGroupRolesException) {
                            throw RbacServicesImpl.a((Exception)((Object)disabledGroupRolesException));
                        }
                        try {
                            if (user.getId() == null) {
                                throw new NullPointerException(h[27]);
                            }
                        }
                        catch (RoleManager.DisabledGroupRolesException disabledGroupRolesException) {
                            throw RbacServicesImpl.a((Exception)((Object)disabledGroupRolesException));
                        }
                        try {
                            if (!user.getId().equals(pair.right)) {
                                throw new IllegalArgumentException(h[6]);
                            }
                        }
                        catch (RoleManager.DisabledGroupRolesException disabledGroupRolesException) {
                            throw RbacServicesImpl.a((Exception)((Object)disabledGroupRolesException));
                        }
                        try {
                            if (!user.getProviderId().equals(pair.left)) {
                                throw new IllegalArgumentException(h[19]);
                            }
                        }
                        catch (RoleManager.DisabledGroupRolesException disabledGroupRolesException) {
                            throw RbacServicesImpl.a((Exception)((Object)disabledGroupRolesException));
                        }
                        bl2 = false;
                        try {
                            Collection<Role> collection = this.d.getAssignedRoles(user, false, true);
                            for (Role role : collection) {
                                for (Permission permission : role.getPermissions()) {
                                    try {
                                        if (permission.getEntityType() == null || permission.getOperation() == OperationType.NONE) continue;
                                    }
                                    catch (RoleManager.DisabledGroupRolesException disabledGroupRolesException) {
                                        throw RbacServicesImpl.a((Exception)((Object)disabledGroupRolesException));
                                    }
                                    bl2 = true;
                                    break block25;
                                }
                            }
                        }
                        catch (RoleManager.DisabledGroupRolesException disabledGroupRolesException) {
                            String[] stringArray = h;
                            a.log(Level.INFO, stringArray[10] + user.getLogin() + stringArray[29] + ExceptionUtils.getMessage((Throwable)((Object)disabledGroupRolesException)), ExceptionUtils.getDebugException((Throwable)((Object)disabledGroupRolesException)));
                        }
                    }
                    try {
                        try {
                            if (bl2) break block26;
                            if (this.a(user.getProviderId()) == null) break block27;
                        }
                        catch (RoleManager.DisabledGroupRolesException disabledGroupRolesException) {
                            throw RbacServicesImpl.a((Exception)((Object)disabledGroupRolesException));
                        }
                        bl3 = true;
                        break block28;
                    }
                    catch (RoleManager.DisabledGroupRolesException disabledGroupRolesException) {
                        throw RbacServicesImpl.a((Exception)((Object)disabledGroupRolesException));
                    }
                }
                bl3 = false;
            }
            bl2 = bl3;
        }
        return bl2;
    }

    private Role a(Goid goid) throws FindException {
        try {
            if (this.g == null) {
                return null;
            }
        }
        catch (FindException findException) {
            throw RbacServicesImpl.a((Exception)((Object)findException));
        }
        IdentityProviderFactory identityProviderFactory = (IdentityProviderFactory)this.g.getBean(h[15], IdentityProviderFactory.class);
        IdentityProvider identityProvider = identityProviderFactory.getProvider(goid);
        if (identityProvider instanceof HasDefaultRole) {
            HasDefaultRole hasDefaultRole = (HasDefaultRole)identityProvider;
            Goid goid2 = hasDefaultRole.getDefaultRoleId();
            try {
                if (goid2 != null) {
                    return (Role)this.d.findByPrimaryKey(goid2);
                }
            }
            catch (FindException findException) {
                throw RbacServicesImpl.a((Exception)((Object)findException));
            }
        }
        return null;
    }

    @Override
    public Collection<Role> getAssignedRoles(@NotNull Pair<Goid, String> pair, @NotNull User user) throws FindException {
        try {
            if (pair == null) {
                RbacServicesImpl.a(2);
            }
        }
        catch (FindException findException) {
            throw RbacServicesImpl.a((Exception)((Object)findException));
        }
        try {
            if (user == null) {
                RbacServicesImpl.a(3);
            }
        }
        catch (FindException findException) {
            throw RbacServicesImpl.a((Exception)((Object)findException));
        }
        try {
            if (user.getId() == null) {
                throw new NullPointerException(h[3]);
            }
        }
        catch (FindException findException) {
            throw RbacServicesImpl.a((Exception)((Object)findException));
        }
        try {
            if (!user.getId().equals(pair.right)) {
                throw new IllegalArgumentException(h[0]);
            }
        }
        catch (FindException findException) {
            throw RbacServicesImpl.a((Exception)((Object)findException));
        }
        try {
            if (!user.getProviderId().equals(pair.left)) {
                throw new IllegalArgumentException(h[12]);
            }
        }
        catch (FindException findException) {
            throw RbacServicesImpl.a((Exception)((Object)findException));
        }
        ArrayList<Role> arrayList = new ArrayList<Role>();
        arrayList.addAll(this.d.getAssignedRoles(user));
        if (arrayList.isEmpty()) {
            Role role = this.a(user.getProviderId());
            try {
                if (role != null) {
                    arrayList.add(role);
                }
            }
            catch (FindException findException) {
                throw RbacServicesImpl.a((Exception)((Object)findException));
            }
        }
        return Collections.unmodifiableCollection(arrayList);
    }

    private static Pair<Goid, String> a(User user) {
        return new Pair((Object)user.getProviderId(), (Object)user.getId());
    }

    private boolean a(Collection<Role> collection, Entity entity, OperationType operationType, String string) {
        block28: {
            block29: {
                Object object;
                Level level;
                Logger logger;
                block31: {
                    block30: {
                        try {
                            try {
                                try {
                                    try {
                                        try {
                                            try {
                                                try {
                                                    if (entity == null || this.f == null) break block28;
                                                }
                                                catch (IllegalArgumentException illegalArgumentException) {
                                                    throw RbacServicesImpl.a(illegalArgumentException);
                                                }
                                                if (OperationType.READ.equals((Object)operationType)) break block28;
                                            }
                                            catch (IllegalArgumentException illegalArgumentException) {
                                                throw RbacServicesImpl.a(illegalArgumentException);
                                            }
                                            if (!this.f.isEntityProtectionEnabled()) break block28;
                                        }
                                        catch (IllegalArgumentException illegalArgumentException) {
                                            throw RbacServicesImpl.a(illegalArgumentException);
                                        }
                                        if (!this.f.isReadOnlyEntity(entity)) break block28;
                                    }
                                    catch (IllegalArgumentException illegalArgumentException) {
                                        throw RbacServicesImpl.a(illegalArgumentException);
                                    }
                                    if (!a.isLoggable(Level.FINEST)) break block29;
                                }
                                catch (IllegalArgumentException illegalArgumentException) {
                                    throw RbacServicesImpl.a(illegalArgumentException);
                                }
                                logger = a;
                                level = Level.FINEST;
                                if (!OperationType.OTHER.equals((Object)operationType)) break block30;
                            }
                            catch (IllegalArgumentException illegalArgumentException) {
                                throw RbacServicesImpl.a(illegalArgumentException);
                            }
                            object = OperationType.OTHER.name() + h[20] + string + "]";
                            break block31;
                        }
                        catch (IllegalArgumentException illegalArgumentException) {
                            throw RbacServicesImpl.a(illegalArgumentException);
                        }
                    }
                    object = operationType.name();
                }
                String string2 = EntityType.findTypeByEntity((Class)entity.getClass()).name();
                String string3 = entity.getId();
                Object object2 = object;
                String[] stringArray = h;
                logger.log(level, stringArray[26] + (String)object2 + stringArray[8] + string3 + stringArray[18] + string2);
            }
            return false;
        }
        for (Role role : collection) {
            for (Permission permission : role.getPermissions()) {
                block32: {
                    if (!permission.matches(entity)) continue;
                    try {
                        if (permission.getOperation() != operationType) {
                            continue;
                        }
                    }
                    catch (IllegalArgumentException illegalArgumentException) {
                        throw RbacServicesImpl.a(illegalArgumentException);
                    }
                    try {
                        if (!this.a(entity, permission)) {
                            continue;
                        }
                    }
                    catch (IllegalArgumentException illegalArgumentException) {
                        throw RbacServicesImpl.a(illegalArgumentException);
                    }
                    try {
                        try {
                            try {
                                if (operationType != OperationType.OTHER && operationType != OperationType.NONE) break block32;
                            }
                            catch (IllegalArgumentException illegalArgumentException) {
                                throw RbacServicesImpl.a(illegalArgumentException);
                            }
                            if (!string.equals(permission.getOtherOperationName())) continue;
                        }
                        catch (IllegalArgumentException illegalArgumentException) {
                            throw RbacServicesImpl.a(illegalArgumentException);
                        }
                        return true;
                    }
                    catch (IllegalArgumentException illegalArgumentException) {
                        throw RbacServicesImpl.a(illegalArgumentException);
                    }
                }
                return true;
            }
        }
        return false;
    }

    private boolean a(Entity entity, Permission permission) {
        try {
            if (permission.getScope().isEmpty()) {
                return true;
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw RbacServicesImpl.a(illegalArgumentException);
        }
        boolean bl2 = true;
        for (ScopePredicate scopePredicate : permission.getScope()) {
            bl2 &= this.a(scopePredicate, entity);
        }
        return bl2;
    }

    private boolean a(ScopePredicate scopePredicate, Entity entity) {
        ScopeEvaluator scopeEvaluator;
        if (scopePredicate instanceof ScopeEvaluator) {
            scopeEvaluator = (ScopeEvaluator)scopePredicate;
        } else {
            scopeEvaluator = this.c.get(scopePredicate);
            if (scopeEvaluator == null) {
                ScopeEvaluatorFactory scopeEvaluatorFactory = this.b.get(scopePredicate.getClass());
                try {
                    if (scopeEvaluatorFactory == null) {
                        throw new IllegalStateException(h[25] + scopePredicate.getClass().getName());
                    }
                }
                catch (IllegalArgumentException illegalArgumentException) {
                    throw RbacServicesImpl.a(illegalArgumentException);
                }
                scopeEvaluator = scopeEvaluatorFactory.makeEvaluator(scopePredicate);
                try {
                    if (scopeEvaluator == null) {
                        throw new IllegalStateException(scopeEvaluatorFactory.getClass().getName() + h[1]);
                    }
                }
                catch (IllegalArgumentException illegalArgumentException) {
                    throw RbacServicesImpl.a(illegalArgumentException);
                }
                this.c.put(scopePredicate, scopeEvaluator);
            }
        }
        try {
            if (scopeEvaluator.matches(entity)) {
                return true;
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw RbacServicesImpl.a(illegalArgumentException);
        }
        a.fine(String.format(h[23], scopeEvaluator.getClass().getSimpleName()));
        return false;
    }

    public void setRoleManager(RoleManager roleManager) {
        this.d = roleManager;
    }

    public void setEntityFinder(EntityFinder entityFinder) {
        this.e = entityFinder;
    }

    public void setProtectedEntityTracker(ProtectedEntityTracker protectedEntityTracker) {
        this.f = protectedEntityTracker;
    }

    public void afterPropertiesSet() throws Exception {
        try {
            if (this.d == null) {
                throw new IllegalStateException(h[5]);
            }
        }
        catch (Exception exception) {
            throw RbacServicesImpl.a(exception);
        }
        try {
            if (this.e == null) {
                throw new IllegalStateException(h[24]);
            }
        }
        catch (Exception exception) {
            throw RbacServicesImpl.a(exception);
        }
    }

    public void onApplicationEvent(ApplicationEvent applicationEvent) {
        EntityInvalidationEvent entityInvalidationEvent;
        if (applicationEvent instanceof EntityInvalidationEvent && Role.class.isAssignableFrom((entityInvalidationEvent = (EntityInvalidationEvent)applicationEvent).getEntityClass())) {
            for (Goid goid : entityInvalidationEvent.getEntityIds()) {
                try {
                    this.d.getCachedEntity(goid, 0);
                }
                catch (Exception exception) {
                    a.log(Level.WARNING, h[28], exception);
                }
            }
        }
    }

    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.g = applicationContext;
    }

    /*
     * Unable to fully structure code
     */
    static {
        block10: {
            block9: {
                var5 = new String[30];
                var3_1 = 0;
                var2_2 = "Hh\u0018KsT\u0012\u001dv\u0014J>|\"^s\u001a\u001dk\u000fV7h5X\u007f]Xss#Qw]\\%|:Hz\tV!/hu\u001c[?xvIt]_:s2\u001d~\u0013M:i/\u001d}\u0012Ksu3\\\u007f\u0018Ki=-\rfF\u0019 v?Mk\u0014W4\u0007Hh\u0018KsT\u0012\u0014Th<]>t8Th\tK2i?K~(J6o\u0017ot\u0011\\\u001e|8\\|\u0018Kst%\u001di\u0018H&t$X\u007f\u0010Hh\u0018KsT\u0012\u001dv\u0014J>|\"^s&~s\u0018Z8t8Z;\u001bV!=&Xi\u0010P n?Ru]M<=-\rf]X=dvF*\u0000\u001d\u001dz\u001eZ6n%\u001do\u0012\u0019\u0001x7Y62W?dvxu\tP'dl\u001d\u0004Hh\u0018K\u001b|\u007f\u0010P=t%Ii\u001cM:k3\u001dz\u001eZ6n%\u001d}\u0012Ks:\u0010Z~\tx n?Zu\u0018]\u0001r:Xh\u0014Mi\u0012O:y3O;4}sp?Nv\u001cM0u<Ro\u0015\\!R&Xi\u001cM:r8sz\u0010\\sp#No][6=%M~\u001eP5t3Y;\nQ6svRk\u0018K2i?Ru]\u0004n=\u0019iS8k0^t\u0010\u0016?*\"Xx\u0015\u0016 x$K~\u000f\u0016 x5Hi\u0014M*2$_z\u001e\u0016\u0001\u007f7^H\u0018K%t5Xh4T#q\u0017T\u007f\u0018W't\"DK\u000fV%t2Xi;X0i9Ob>|i\u001aL>x8I;\u001bV!=\u0016st\tw&q:\u001dk\u001cK2p3I~\u000f\u0019t8%\u001a;\u0012_s8%\u0013>\u000e\u0019>h%I;\u0013V'=4X;\u0013L?q$~s\u0018Z8t8Z;\u001bV!=&Xi\u0010P n?Ru]M<=sN;XJs>sN\n\u001dt\u001b\u0019\u0007d&X!]\u0014Mi\u0012O:y3O;4}sp?Nv\u001cM0u\u0002\u0007@\u0011Mi\u0012O:y3OZ\u0013]\u0006n3OR\u0019'~s\u0018Z8t8Z;\u001bV!=&Xi\u0010P n?Ru]M<=-\rf]J<p3\u001d`LD\u001b\u0018h]]:yvSt\t\u0019>|\"^s]M;xvXu\tP'd\u0018xu\tP'd\u0010Tu\u0019\\!=?N;\u000f\\\"h?O~\u0019\u0019st]\\%|:Hz\tV!=0\\x\tV!dv[t\u000f\u0019\by~\u0013@:s1\u001d\u0007Hh\u0018KsT\u0012";
                var4_3 = "Hh\u0018KsT\u0012\u001dv\u0014J>|\"^s\u001a\u001dk\u000fV7h5X\u007f]Xss#Qw]\\%|:Hz\tV!/hu\u001c[?xvIt]_:s2\u001d~\u0013M:i/\u001d}\u0012Ksu3\\\u007f\u0018Ki=-\rfF\u0019 v?Mk\u0014W4\u0007Hh\u0018KsT\u0012\u0014Th<]>t8Th\tK2i?K~(J6o\u0017ot\u0011\\\u001e|8\\|\u0018Kst%\u001di\u0018H&t$X\u007f\u0010Hh\u0018KsT\u0012\u001dv\u0014J>|\"^s&~s\u0018Z8t8Z;\u001bV!=&Xi\u0010P n?Ru]M<=-\rf]X=dvF*\u0000\u001d\u001dz\u001eZ6n%\u001do\u0012\u0019\u0001x7Y62W?dvxu\tP'dl\u001d\u0004Hh\u0018K\u001b|\u007f\u0010P=t%Ii\u001cM:k3\u001dz\u001eZ6n%\u001d}\u0012Ks:\u0010Z~\tx n?Zu\u0018]\u0001r:Xh\u0014Mi\u0012O:y3O;4}sp?Nv\u001cM0u<Ro\u0015\\!R&Xi\u001cM:r8sz\u0010\\sp#No][6=%M~\u001eP5t3Y;\nQ6svRk\u0018K2i?Ru]\u0004n=\u0019iS8k0^t\u0010\u0016?*\"Xx\u0015\u0016 x$K~\u000f\u0016 x5Hi\u0014M*2$_z\u001e\u0016\u0001\u007f7^H\u0018K%t5Xh4T#q\u0017T\u007f\u0018W't\"DK\u000fV%t2Xi;X0i9Ob>|i\u001aL>x8I;\u001bV!=\u0016st\tw&q:\u001dk\u001cK2p3I~\u000f\u0019t8%\u001a;\u0012_s8%\u0013>\u000e\u0019>h%I;\u0013V'=4X;\u0013L?q$~s\u0018Z8t8Z;\u001bV!=&Xi\u0010P n?Ru]M<=sN;XJs>sN\n\u001dt\u001b\u0019\u0007d&X!]\u0014Mi\u0012O:y3O;4}sp?Nv\u001cM0u\u0002\u0007@\u0011Mi\u0012O:y3OZ\u0013]\u0006n3OR\u0019'~s\u0018Z8t8Z;\u001bV!=&Xi\u0010P n?Ru]M<=-\rf]J<p3\u001d`LD\u001b\u0018h]]:yvSt\t\u0019>|\"^s]M;xvXu\tP'd\u0018xu\tP'd\u0010Tu\u0019\\!=?N;\u000f\\\"h?O~\u0019\u0019st]\\%|:Hz\tV!=0\\x\tV!dv[t\u000f\u0019\by~\u0013@:s1\u001d\u0007Hh\u0018KsT\u0012".length();
                var1_4 = 16;
                var0_5 = -1;
lbl7:
                // 2 sources

                while (true) {
                    v0 = 43;
                    v1 = ++var0_5;
                    v2 = var2_2.substring(v1, v1 + var1_4);
                    v3 = -1;
                    break block9;
                    break;
                }
lbl13:
                // 1 sources

                while (true) {
                    var5[var3_1++] = RbacServicesImpl.a(v0, RbacServicesImpl.a(v2));
                    if ((var0_5 += var1_4) < var4_3) {
                        var1_4 = var2_2.charAt(var0_5);
                        ** continue;
                    }
                    var2_2 = "q{\u0007Z8|~F4\u0000S:`<A|RU=q1WpRd3~<\u0011\u00154\u0016S2{<V4\u0016C92-].R";
                    var4_3 = "q{\u0007Z8|~F4\u0000S:`<A|RU=q1WpRd3~<\u0011\u00154\u0016S2{<V4\u0016C92-].R".length();
                    var1_4 = 28;
                    var0_5 = -1;
lbl22:
                    // 2 sources

                    while (true) {
                        v0 = 36;
                        v4 = ++var0_5;
                        v2 = var2_2.substring(v4, v4 + var1_4);
                        v3 = 0;
                        break block9;
                        break;
                    }
                    break;
                }
lbl28:
                // 1 sources

                while (true) {
                    var5[var3_1++] = RbacServicesImpl.a(v0, RbacServicesImpl.a(v2));
                    if ((var0_5 += var1_4) < var4_3) {
                        var1_4 = var2_2.charAt(var0_5);
                        ** continue;
                    }
                    break block10;
                    break;
                }
            }
            switch (v3) {
                default: {
                    ** continue;
                }
                ** case 0:
lbl39:
                // 1 sources

                ** continue;
            }
        }
        RbacServicesImpl.h = var5;
        RbacServicesImpl.a = Logger.getLogger(RbacServicesImpl.class.getName());
    }

    /*
     * Exception decompiling
     */
    private static /* synthetic */ void a(int var0) {
        /*
         * This method has failed to decompile.  When submitting a bug report, please provide this stack trace, and (if you hold appropriate legal rights) the relevant class file.
         * 
         * org.benf.cfr.reader.util.ConfusedCFRException: Tried to end blocks [0[TRYBLOCK]], but top level block is 2[SWITCH]
         *     at org.benf.cfr.reader.bytecode.analysis.opgraph.Op04StructuredStatement.processEndingBlocks(Op04StructuredStatement.java:435)
         *     at org.benf.cfr.reader.bytecode.analysis.opgraph.Op04StructuredStatement.buildNestedBlocks(Op04StructuredStatement.java:484)
         *     at org.benf.cfr.reader.bytecode.analysis.opgraph.Op03SimpleStatement.createInitialStructuredBlock(Op03SimpleStatement.java:736)
         *     at org.benf.cfr.reader.bytecode.CodeAnalyser.getAnalysisInner(CodeAnalyser.java:850)
         *     at org.benf.cfr.reader.bytecode.CodeAnalyser.getAnalysisOrWrapFail(CodeAnalyser.java:278)
         *     at org.benf.cfr.reader.bytecode.CodeAnalyser.getAnalysis(CodeAnalyser.java:201)
         *     at org.benf.cfr.reader.entities.attributes.AttributeCode.analyse(AttributeCode.java:94)
         *     at org.benf.cfr.reader.entities.Method.analyse(Method.java:531)
         *     at org.benf.cfr.reader.entities.ClassFile.analyseMid(ClassFile.java:1050)
         *     at org.benf.cfr.reader.entities.ClassFile.analyseTop(ClassFile.java:942)
         *     at org.benf.cfr.reader.Driver.doJarVersionTypes(Driver.java:257)
         *     at org.benf.cfr.reader.Driver.doJar(Driver.java:139)
         *     at org.benf.cfr.reader.CfrDriverImpl.analyse(CfrDriverImpl.java:76)
         *     at org.benf.cfr.reader.Main.main(Main.java:54)
         */
        throw new IllegalStateException("Decompilation failed");
    }

    private static Exception a(Exception exception) {
        return exception;
    }

    private static char[] a(String string) {
        char[] cArray = string.toCharArray();
        if (cArray.length < 2) {
            cArray = cArray;
            cArray[0] = (char)(cArray[0] ^ 0x7D);
        }
        return cArray;
    }

    /*
     * Handled impossible loop by duplicating code
     * Enabled aggressive block sorting
     */
    private static String a(int n2, char[] cArray) {
        char[] cArray2;
        block11: {
            int n3;
            int n4;
            int n5;
            block10: {
                n5 = n2;
                cArray2 = cArray;
                n4 = cArray.length;
                n3 = 0;
                if (!true) break block10;
                n4 = n4;
                if (n4 <= n3) break block11;
            }
            do {
                n5 = n5;
                cArray2 = cArray2;
                int n6 = n3;
                cArray2[n6] = (char)(cArray2[n6] ^ (n5 ^ (switch (n3 % 7) {
                    case 0 -> 22;
                    case 1 -> 48;
                    case 2 -> 86;
                    case 3 -> 18;
                    case 4 -> 120;
                    case 5 -> 54;
                    default -> 125;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }
}

