/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.l7tech.gateway.common.LicenseException
 *  com.l7tech.gateway.common.audit.AuditDetailMessage
 *  com.l7tech.gateway.common.audit.MessageProcessingMessages
 *  com.l7tech.gateway.common.audit.Messages$M
 *  com.l7tech.objectmodel.Entity
 *  com.l7tech.objectmodel.EntityType
 *  com.l7tech.objectmodel.FindException
 *  com.l7tech.objectmodel.Goid
 *  com.l7tech.objectmodel.PersistentEntity
 *  com.l7tech.objectmodel.folder.Folder
 *  com.l7tech.objectmodel.imp.PersistentEntityUtil
 *  com.l7tech.policy.CircularPolicyException
 *  com.l7tech.policy.DesignTimeEntityProvider
 *  com.l7tech.policy.InvalidPolicyException
 *  com.l7tech.policy.Policy
 *  com.l7tech.policy.PolicyDeletionForbiddenException
 *  com.l7tech.policy.PolicyHeader
 *  com.l7tech.policy.PolicyType
 *  com.l7tech.policy.PolicyVersion
 *  com.l7tech.policy.assertion.Assertion
 *  com.l7tech.policy.assertion.Include
 *  com.l7tech.policy.assertion.PolicyAssertionException
 *  com.l7tech.policy.assertion.SetsVariables
 *  com.l7tech.policy.assertion.TrueAssertion
 *  com.l7tech.policy.assertion.UnknownAssertion
 *  com.l7tech.policy.assertion.UsesVariables
 *  com.l7tech.policy.variable.PolicyVariableUtils
 *  com.l7tech.policy.variable.VariableMetadata
 *  com.l7tech.policy.wsp.WspReader$Visibility
 *  com.l7tech.util.ArrayUtils
 *  com.l7tech.util.Config
 *  com.l7tech.util.Either
 *  com.l7tech.util.EmptyIterator
 *  com.l7tech.util.ExceptionUtils
 *  com.l7tech.util.Pair
 *  com.l7tech.util.ResourceUtils
 *  org.apache.commons.lang3.mutable.MutableBoolean
 *  org.apache.commons.lang3.mutable.MutableObject
 *  org.jetbrains.annotations.NotNull
 *  org.jetbrains.annotations.Nullable
 *  org.springframework.context.ApplicationContext
 *  org.springframework.context.ApplicationContextAware
 *  org.springframework.context.ApplicationEvent
 *  org.springframework.context.ApplicationEventPublisher
 *  org.springframework.jmx.export.annotation.ManagedAttribute
 *  org.springframework.jmx.export.annotation.ManagedOperation
 *  org.springframework.jmx.export.annotation.ManagedResource
 *  org.springframework.transaction.PlatformTransactionManager
 *  org.springframework.transaction.support.TransactionCallback
 *  org.springframework.transaction.support.TransactionTemplate
 */
package com.l7tech.server.policy;

import com.l7tech.gateway.common.LicenseException;
import com.l7tech.gateway.common.audit.AuditDetailMessage;
import com.l7tech.gateway.common.audit.MessageProcessingMessages;
import com.l7tech.gateway.common.audit.Messages;
import com.l7tech.objectmodel.Entity;
import com.l7tech.objectmodel.EntityType;
import com.l7tech.objectmodel.FindException;
import com.l7tech.objectmodel.Goid;
import com.l7tech.objectmodel.PersistentEntity;
import com.l7tech.objectmodel.folder.Folder;
import com.l7tech.objectmodel.imp.PersistentEntityUtil;
import com.l7tech.policy.CircularPolicyException;
import com.l7tech.policy.DesignTimeEntityProvider;
import com.l7tech.policy.InvalidPolicyException;
import com.l7tech.policy.Policy;
import com.l7tech.policy.PolicyDeletionForbiddenException;
import com.l7tech.policy.PolicyHeader;
import com.l7tech.policy.PolicyType;
import com.l7tech.policy.PolicyVersion;
import com.l7tech.policy.assertion.Assertion;
import com.l7tech.policy.assertion.Include;
import com.l7tech.policy.assertion.PolicyAssertionException;
import com.l7tech.policy.assertion.SetsVariables;
import com.l7tech.policy.assertion.TrueAssertion;
import com.l7tech.policy.assertion.UnknownAssertion;
import com.l7tech.policy.assertion.UsesVariables;
import com.l7tech.policy.variable.PolicyVariableUtils;
import com.l7tech.policy.variable.VariableMetadata;
import com.l7tech.policy.wsp.WspReader;
import com.l7tech.server.EntitiesProcessedInBatch;
import com.l7tech.server.audit.Auditor;
import com.l7tech.server.event.EntityInvalidationEvent;
import com.l7tech.server.event.PolicyCacheEvent;
import com.l7tech.server.event.system.LicenseChangeEvent;
import com.l7tech.server.event.system.PolicyReloadEvent;
import com.l7tech.server.event.system.Started;
import com.l7tech.server.folder.FolderCache;
import com.l7tech.server.policy.PolicyCache;
import com.l7tech.server.policy.PolicyManager;
import com.l7tech.server.policy.PolicyMetadata;
import com.l7tech.server.policy.PolicyVersionManager;
import com.l7tech.server.policy.ServerPolicy;
import com.l7tech.server.policy.ServerPolicyException;
import com.l7tech.server.policy.ServerPolicyFactory;
import com.l7tech.server.policy.ServerPolicyHandle;
import com.l7tech.server.policy.ServerPolicyInstantiationException;
import com.l7tech.server.policy.aa;
import com.l7tech.server.policy.ap;
import com.l7tech.server.policy.assertion.ServerAssertion;
import com.l7tech.server.policy.aw;
import com.l7tech.server.policy.h;
import com.l7tech.server.policy.i;
import com.l7tech.server.policy.j;
import com.l7tech.server.policy.k;
import com.l7tech.server.policy.l;
import com.l7tech.server.policy.m;
import com.l7tech.server.policy.module.AssertionModuleRegistrationEvent;
import com.l7tech.server.policy.module.AssertionModuleUnregistrationEvent;
import com.l7tech.server.policy.module.BaseAssertionModule;
import com.l7tech.server.policy.module.CustomAssertionModule;
import com.l7tech.server.policy.module.ModularAssertionModule;
import com.l7tech.server.policy.n;
import com.l7tech.server.policy.o;
import com.l7tech.server.policy.p;
import com.l7tech.server.policy.q;
import com.l7tech.server.policy.r;
import com.l7tech.server.policy.s;
import com.l7tech.server.policy.t;
import com.l7tech.server.policy.u;
import com.l7tech.server.policy.v;
import com.l7tech.server.policy.w;
import com.l7tech.server.policy.x;
import com.l7tech.server.policy.y;
import com.l7tech.server.policy.z;
import com.l7tech.server.service.ServiceAndPolicyCacheSharedLock;
import com.l7tech.server.util.PostStartupApplicationListener;
import com.l7tech.util.ArrayUtils;
import com.l7tech.util.Config;
import com.l7tech.util.Either;
import com.l7tech.util.EmptyIterator;
import com.l7tech.util.ExceptionUtils;
import com.l7tech.util.Pair;
import com.l7tech.util.ResourceUtils;
import java.io.Closeable;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.function.Supplier;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.StreamSupport;
import org.apache.commons.lang3.mutable.MutableBoolean;
import org.apache.commons.lang3.mutable.MutableObject;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.jmx.export.annotation.ManagedAttribute;
import org.springframework.jmx.export.annotation.ManagedOperation;
import org.springframework.jmx.export.annotation.ManagedResource;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.support.TransactionCallback;
import org.springframework.transaction.support.TransactionTemplate;

/*
 * Exception performing whole class analysis ignored.
 */
@ManagedResource(description="Policy Cache", objectName="l7tech:type=PolicyCache")
public class PolicyCacheImpl
implements PolicyCache,
ApplicationContextAware,
PostStartupApplicationListener {
    private static final String a;
    private static final String b;
    private static final aa c;
    private static final Logger d;
    private static final WspReader.Visibility e;
    private Level f = Level.FINEST;
    private final PlatformTransactionManager g;
    private Auditor h;
    private ApplicationEventPublisher i;
    private PolicyManager j;
    private PolicyVersionManager k;
    private Config l;
    private final ServerPolicyFactory m;
    private final FolderCache n;
    private final EntitiesProcessedInBatch o;
    private DesignTimeEntityProvider p;
    private final ReadWriteLock q = ServiceAndPolicyCacheSharedLock.getLock();
    private boolean r = true;
    private boolean s = false;
    private final Set<Goid> t = new HashSet<Goid>();
    private final Map<Goid, aa> u = new HashMap<Goid, aa>();
    private final Map<String, Goid> v = new HashMap<String, Goid>();
    private final ConcurrentMap<Pair<PolicyType, String>, Set<String>> w = new ConcurrentHashMap<Pair<PolicyType, String>, Set<String>>();
    private final Map<String, RegisteredPolicy> x = new HashMap<String, RegisteredPolicy>();
    private static final String[] y;

    public PolicyCacheImpl(PlatformTransactionManager platformTransactionManager, ServerPolicyFactory serverPolicyFactory, FolderCache folderCache, EntitiesProcessedInBatch entitiesProcessedInBatch) {
        this.g = platformTransactionManager;
        this.m = serverPolicyFactory;
        this.n = folderCache;
        this.o = entitiesProcessedInBatch;
    }

    public void setEntityProvider(DesignTimeEntityProvider designTimeEntityProvider) {
        this.p = designTimeEntityProvider;
    }

    public void setConfig(Config config) {
        this.l = config;
    }

    public void setPolicyManager(PolicyManager policyManager) {
        this.j = policyManager;
    }

    public void setPolicyVersionManager(PolicyVersionManager policyVersionManager) {
        this.k = policyVersionManager;
    }

    public void setApplicationContext(ApplicationContext applicationContext) {
        this.h = new Auditor(this, applicationContext, d);
        this.i = applicationContext;
    }

    public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
        this.i = applicationEventPublisher;
    }

    @Override
    public PolicyMetadata getPolicyMetadata(Policy policy) {
        boolean bl2;
        try {
            bl2 = policy != null;
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw PolicyCacheImpl.a(illegalArgumentException);
        }
        PolicyCacheImpl.a(bl2, y[18]);
        return this.getPolicyMetadata(policy.getGoid());
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     */
    @Override
    public PolicyMetadata getPolicyMetadata(Goid goid) {
        block7: {
            boolean bl2;
            try {
                bl2 = !Goid.isDefault((Goid)goid);
            }
            catch (IllegalArgumentException illegalArgumentException) {
                throw PolicyCacheImpl.a(illegalArgumentException);
            }
            PolicyCacheImpl.a(bl2, y[17]);
            Lock lock = this.q.readLock();
            lock.lock();
            try {
                aa aa2 = this.e(goid);
                try {
                    if (aa2 == null || !aa2.isValid()) break block7;
                }
                catch (IllegalArgumentException illegalArgumentException) {
                    throw PolicyCacheImpl.a(illegalArgumentException);
                }
                PolicyMetadata policyMetadata = aa2.getPolicyMetadata();
                return policyMetadata;
            }
            finally {
                lock.unlock();
            }
        }
        return null;
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     * Loose catch block
     */
    @Override
    public PolicyMetadata getPolicyMetadataByGuid(String string) {
        block9: {
            Lock lock = this.q.readLock();
            lock.lock();
            try {
                boolean bl2;
                Goid goid;
                block11: {
                    block10: {
                        goid = this.v.get(string);
                        if (goid == null) break block9;
                        try {
                            block12: {
                                if (Goid.isDefault((Goid)goid)) break block10;
                                break block12;
                                catch (IllegalArgumentException illegalArgumentException) {
                                    throw PolicyCacheImpl.a(illegalArgumentException);
                                }
                            }
                            bl2 = true;
                            break block11;
                        }
                        catch (IllegalArgumentException illegalArgumentException) {
                            throw PolicyCacheImpl.a(illegalArgumentException);
                        }
                    }
                    bl2 = false;
                }
                PolicyCacheImpl.a(bl2, y[0]);
                aa aa2 = this.e(goid);
                try {
                    if (aa2 == null || !aa2.isValid()) break block9;
                }
                catch (IllegalArgumentException illegalArgumentException) {
                    throw PolicyCacheImpl.a(illegalArgumentException);
                }
                PolicyMetadata policyMetadata = aa2.getPolicyMetadata();
                return policyMetadata;
            }
            finally {
                lock.unlock();
            }
        }
        return null;
    }

    @Override
    public List<Folder> getFolderPath(Goid goid) {
        List<Folder> list;
        block5: {
            block4: {
                aa aa2 = this.f(goid);
                try {
                    try {
                        if (aa2 == null || aa2.b.getFolder() == null) break block4;
                    }
                    catch (IllegalArgumentException illegalArgumentException) {
                        throw PolicyCacheImpl.a(illegalArgumentException);
                    }
                    list = this.n.findPathByPrimaryKey(aa2.b.getFolder().getGoid());
                    break block5;
                }
                catch (IllegalArgumentException illegalArgumentException) {
                    throw PolicyCacheImpl.a(illegalArgumentException);
                }
            }
            list = Collections.emptyList();
        }
        return list;
    }

    @Override
    public boolean isStarted() {
        return this.s;
    }

    @Override
    public ServerPolicyHandle getServerPolicy(Policy policy) {
        boolean bl2;
        try {
            bl2 = policy != null;
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw PolicyCacheImpl.a(illegalArgumentException);
        }
        PolicyCacheImpl.a(bl2, y[29]);
        return this.getServerPolicy(policy.getGoid());
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     */
    @Override
    public ServerPolicyHandle getServerPolicy(Goid goid) {
        block7: {
            boolean bl2;
            try {
                bl2 = !Goid.isDefault((Goid)goid);
            }
            catch (IllegalArgumentException illegalArgumentException) {
                throw PolicyCacheImpl.a(illegalArgumentException);
            }
            PolicyCacheImpl.a(bl2, y[17]);
            Lock lock = this.q.readLock();
            lock.lock();
            try {
                aa aa2 = this.e(goid);
                try {
                    if (aa2 == null || !aa2.isValid()) break block7;
                }
                catch (IllegalArgumentException illegalArgumentException) {
                    throw PolicyCacheImpl.a(illegalArgumentException);
                }
                ServerPolicyHandle serverPolicyHandle = (ServerPolicyHandle)aa2.d.ref();
                return serverPolicyHandle;
            }
            finally {
                lock.unlock();
            }
        }
        return null;
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     */
    @Override
    public ServerPolicyHandle getServerPolicy(String string) {
        block7: {
            boolean bl2;
            try {
                bl2 = string != null;
            }
            catch (IllegalArgumentException illegalArgumentException) {
                throw PolicyCacheImpl.a(illegalArgumentException);
            }
            PolicyCacheImpl.a(bl2, y[17]);
            Lock lock = this.q.readLock();
            lock.lock();
            try {
                Goid goid = this.v.get(string);
                if (goid == null) break block7;
                aa aa2 = this.e(goid);
                try {
                    if (aa2 == null || !aa2.isValid()) break block7;
                }
                catch (IllegalArgumentException illegalArgumentException) {
                    throw PolicyCacheImpl.a(illegalArgumentException);
                }
                ServerPolicyHandle serverPolicyHandle = (ServerPolicyHandle)aa2.d.ref();
                return serverPolicyHandle;
            }
            finally {
                lock.unlock();
            }
        }
        return null;
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     * Unable to fully structure code
     */
    @Override
    public Set<String> getPoliciesByTypeAndTag(PolicyType var1_1, String var2_2) {
        this.d();
        var3_3 = new Pair((Object)var1_1, (Object)var2_2);
        var4_4 = (HashSet<String>)this.w.get(var3_3);
        try {
            if (var4_4 != null) {
                return var4_4;
            }
        }
        catch (IllegalArgumentException v0) {
            throw PolicyCacheImpl.a(v0);
        }
        var4_4 = new HashSet<String>();
        var5_5 = this.q.readLock();
        var5_5.lock();
        try {
            for (aa var7_7 : this.u.values()) {
                block17: {
                    block21: {
                        block20: {
                            block19: {
                                if (var1_1 == null) ** GOTO lbl22
                                if (var1_1 != var7_7.b.getType()) continue;
                                break block19;
                                catch (IllegalArgumentException v1) {
                                    throw PolicyCacheImpl.a(v1);
                                }
                            }
                            if (var2_2 == null) ** GOTO lbl34
                            break block20;
                            catch (IllegalArgumentException v2) {
                                throw PolicyCacheImpl.a(v2);
                            }
                        }
                        if (!var2_2.equals(var7_7.b.getInternalTag())) continue;
                        break block21;
                        catch (IllegalArgumentException v3) {
                            throw PolicyCacheImpl.a(v3);
                        }
                    }
                    try {
                        block22: {
                            if (!var7_7.b.isDisabled()) break block17;
                            break block22;
                            catch (IllegalArgumentException v4) {
                                throw PolicyCacheImpl.a(v4);
                            }
                        }
                        PolicyCacheImpl.d.log(Level.INFO, PolicyCacheImpl.y[8], new Object[]{var7_7.b.getType(), var7_7.b.getGoid(), var7_7.b.getName()});
                        continue;
                    }
                    catch (IllegalArgumentException v5) {
                        throw PolicyCacheImpl.a(v5);
                    }
                }
                var4_4.add(var7_7.b.getGuid());
            }
        }
        finally {
            var5_5.unlock();
        }
        this.w.putIfAbsent((Pair<PolicyType, String>)var3_3, var4_4);
        return var4_4;
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     */
    @Override
    public String registerGlobalPolicy(String string, PolicyType policyType, String string2, String string3) {
        this.d();
        RegisteredPolicy registeredPolicy = new RegisteredPolicy(string, policyType, string2, string3);
        Lock lock = this.q.writeLock();
        lock.lock();
        try {
            this.w.clear();
            this.x.put(registeredPolicy.getGuid(), registeredPolicy);
            this.d(registeredPolicy);
        }
        finally {
            lock.unlock();
        }
        return registeredPolicy.getGuid();
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     */
    @Override
    public void unregisterGlobalPolicy(String string) {
        Goid goid;
        this.d();
        Lock lock = this.q.readLock();
        lock.lock();
        try {
            this.x.remove(string);
            goid = this.v.get(string);
        }
        finally {
            lock.unlock();
        }
        try {
            if (goid != null) {
                this.g(goid);
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw PolicyCacheImpl.a(illegalArgumentException);
        }
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     */
    @Override
    public Map<Goid, Integer> getDependentVersions(Goid goid) {
        Map<Goid, Integer> map;
        block6: {
            this.d();
            Lock lock = this.q.readLock();
            lock.lock();
            try {
                block5: {
                    aa aa2 = this.e(goid);
                    try {
                        if (aa2 == null || !aa2.isValid()) break block5;
                    }
                    catch (IllegalArgumentException illegalArgumentException) {
                        throw PolicyCacheImpl.a(illegalArgumentException);
                    }
                    map = aa2.a().getDependentVersions(true);
                    break block6;
                }
                map = Collections.emptyMap();
            }
            finally {
                lock.unlock();
            }
        }
        return map;
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     */
    @Override
    public String getUniquePolicyVersionIdentifer(Goid goid) {
        String string;
        block5: {
            this.d();
            string = null;
            Lock lock = this.q.readLock();
            lock.lock();
            try {
                aa aa2 = this.e(goid);
                try {
                    if (aa2 == null || !aa2.isValid()) break block5;
                }
                catch (IllegalArgumentException illegalArgumentException) {
                    throw PolicyCacheImpl.a(illegalArgumentException);
                }
                string = aa2.a().getPolicyUniqueIdentifier();
            }
            finally {
                lock.unlock();
            }
        }
        return string;
    }

    @Override
    public void update(Policy policy) {
        boolean bl2;
        try {
            this.d();
            bl2 = !Goid.isDefault((Goid)policy.getGoid());
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw PolicyCacheImpl.a(illegalArgumentException);
        }
        PolicyCacheImpl.a(bl2, y[22]);
        this.c(this.a(policy));
    }

    @NotNull
    private Policy a(@NotNull Policy policy) {
        try {
            if (policy == null) {
                PolicyCacheImpl.a(0);
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw PolicyCacheImpl.a(illegalArgumentException);
        }
        return new Policy(policy, e, true, this.p);
    }

    /*
     * Enabled force condition propagation
     * Lifted jumps to return sites
     */
    @Override
    public void validate(Policy policy) throws CircularPolicyException {
        this.d();
        Objects.requireNonNull(policy, y[29]);
        Set<String> set = this.b(this.c(policy.getGoid()));
        try {
            if (set.isEmpty()) {
                return;
            }
        }
        catch (IOException iOException) {
            throw PolicyCacheImpl.a(iOException);
        }
        try {
            Assertion assertion = policy.getAssertion();
            if (assertion == null) return;
            Iterator iterator = assertion.preorderIterator();
            while (iterator.hasNext()) {
                Assertion assertion2 = (Assertion)iterator.next();
                if (!(assertion2 instanceof Include)) continue;
                Include include = (Include)assertion2;
                try {
                    if (!set.contains(include.getPolicyGuid())) continue;
                    throw new CircularPolicyException(policy, include.getPolicyGuid(), include.getPolicyName());
                }
                catch (IOException iOException) {
                    throw PolicyCacheImpl.a(iOException);
                    return;
                }
            }
        }
        catch (IOException iOException) {
            // empty catch block
        }
    }

    @Override
    public void validateRemove(Goid goid) throws PolicyDeletionForbiddenException {
        this.d();
        Lock lock = this.q.readLock();
        lock.lock();
        try {
            this.h(goid);
        }
        finally {
            lock.unlock();
        }
    }

    @Override
    public Set<Policy> findUsages(Goid goid) {
        this.d();
        return this.c(goid);
    }

    @Override
    public boolean remove(Goid goid) {
        this.d();
        return this.g(goid);
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     */
    @ManagedOperation(description="Rebuild Policy Cache")
    public void initializePolicyCache() {
        long l2 = System.currentTimeMillis();
        this.logAndAudit((AuditDetailMessage)MessageProcessingMessages.POLICY_CACHE_BUILD, new String[0]);
        ArrayList<PolicyCacheEvent> arrayList = new ArrayList<PolicyCacheEvent>();
        Lock lock = this.q.writeLock();
        lock.lock();
        try {
            this.s = true;
            this.t.clear();
            for (aa object : this.u.values()) {
                ResourceUtils.closeQuietly((Closeable)object);
            }
            this.u.clear();
            this.v.clear();
            this.w.clear();
            for (Policy policy : this.j.findAll()) {
                Policy policy2 = this.a(policy);
                this.a(policy2, null, new HashSet<Goid>(), new HashMap<Goid, Integer>(), arrayList);
            }
            for (RegisteredPolicy registeredPolicy : this.x.values()) {
                this.a(registeredPolicy, null, new HashSet<Goid>(), new HashMap<Goid, Integer>(), arrayList);
            }
            this.r = false;
        }
        catch (FindException findException) {
            this.a();
            d.log(Level.WARNING, y[4], findException);
        }
        finally {
            lock.unlock();
        }
        for (PolicyCacheEvent policyCacheEvent : arrayList) {
            this.a(policyCacheEvent);
        }
        this.a(new PolicyCacheEvent.Started(this));
        this.f();
        d.fine(new h(this, l2));
    }

    public void onApplicationEvent(ApplicationEvent applicationEvent) {
        block12: {
            block13: {
                block11: {
                    try {
                        try {
                            if (!(applicationEvent instanceof LicenseChangeEvent) && !(applicationEvent instanceof AssertionModuleRegistrationEvent)) break block11;
                        }
                        catch (IllegalArgumentException illegalArgumentException) {
                            throw PolicyCacheImpl.a(illegalArgumentException);
                        }
                        this.a(new s(this));
                        break block12;
                    }
                    catch (IllegalArgumentException illegalArgumentException) {
                        throw PolicyCacheImpl.a(illegalArgumentException);
                    }
                }
                try {
                    if (!(applicationEvent instanceof AssertionModuleUnregistrationEvent)) break block13;
                    this.a(new u(this, applicationEvent));
                    break block12;
                }
                catch (IllegalArgumentException illegalArgumentException) {
                    throw PolicyCacheImpl.a(illegalArgumentException);
                }
            }
            if (applicationEvent instanceof EntityInvalidationEvent) {
                EntityInvalidationEvent entityInvalidationEvent = (EntityInvalidationEvent)applicationEvent;
                this.a(entityInvalidationEvent);
            } else {
                try {
                    if (applicationEvent instanceof Started) {
                        this.a(new v(this));
                    }
                }
                catch (IllegalArgumentException illegalArgumentException) {
                    throw PolicyCacheImpl.a(illegalArgumentException);
                }
            }
        }
    }

    private void a(EntityInvalidationEvent entityInvalidationEvent) {
        block6: {
            block5: {
                try {
                    if (!Policy.class.isAssignableFrom(entityInvalidationEvent.getEntityClass())) break block5;
                    this.b(entityInvalidationEvent);
                    break block6;
                }
                catch (IllegalArgumentException illegalArgumentException) {
                    throw PolicyCacheImpl.a(illegalArgumentException);
                }
            }
            try {
                if (PolicyVersion.class.isAssignableFrom(entityInvalidationEvent.getEntityClass())) {
                    this.c(entityInvalidationEvent);
                }
            }
            catch (IllegalArgumentException illegalArgumentException) {
                throw PolicyCacheImpl.a(illegalArgumentException);
            }
        }
    }

    private void b(EntityInvalidationEvent entityInvalidationEvent) {
        this.d();
        Goid goid = Policy.DEFAULT_GOID;
        try {
            Goid[] goidArray = entityInvalidationEvent.getEntityIds();
            int n2 = goidArray.length;
            for (int i2 = 0; i2 < n2; ++i2) {
                Goid goid2;
                goid = goid2 = goidArray[i2];
                Policy policy = (Policy)this.j.findByPrimaryKey(goid2);
                try {
                    if (policy == null) {
                        this.b(goid2);
                        continue;
                    }
                }
                catch (FindException findException) {
                    throw PolicyCacheImpl.a((Exception)((Object)findException));
                }
                PolicyVersion policyVersion = this.k.findActiveVersionForPolicy(goid2);
                try {
                    if (policyVersion != null) {
                        this.a(policy, policyVersion.getOrdinal());
                        continue;
                    }
                }
                catch (FindException findException) {
                    throw PolicyCacheImpl.a((Exception)((Object)findException));
                }
                this.b(this.a(policy));
            }
        }
        catch (FindException findException) {
            this.a();
            this.logAndAudit((AuditDetailMessage)MessageProcessingMessages.POLICY_CACHE_STORAGE_ERROR, new String[]{Goid.toString((Goid)goid)}, (Exception)((Object)findException));
        }
        this.e();
    }

    /*
     * Loose catch block
     */
    private void c(EntityInvalidationEvent entityInvalidationEvent) {
        this.d();
        Goid goid = PolicyVersion.DEFAULT_GOID;
        try {
            Iterable iterable = ArrayUtils.zipI((Object[])entityInvalidationEvent.getEntityIds(), (Object[])ArrayUtils.box((char[])entityInvalidationEvent.getEntityOperations()));
            List list = StreamSupport.stream(iterable.spliterator(), false).toList();
            for (Pair pair : list) {
                Goid goid2;
                PolicyVersion policyVersion;
                block16: {
                    if ('C' == ((Character)pair.right).charValue()) break block16;
                    try {
                        if ('U' != ((Character)pair.right).charValue()) {
                            continue;
                        }
                        break block16;
                        catch (FindException findException) {
                            throw PolicyCacheImpl.a((Exception)((Object)findException));
                        }
                    }
                    catch (FindException findException) {
                        throw PolicyCacheImpl.a((Exception)((Object)findException));
                    }
                }
                if ((policyVersion = (PolicyVersion)this.k.findByPrimaryKey(goid2 = (Goid)pair.left)) == null) continue;
                try {
                    if (!policyVersion.isActive()) {
                        continue;
                    }
                }
                catch (FindException findException) {
                    throw PolicyCacheImpl.a((Exception)((Object)findException));
                }
                aa aa2 = Optional.ofNullable(this.f(policyVersion.getPolicyGoid())).orElse(c);
                PolicyHeader policyHeader = aa2.getPolicyHeader();
                try {
                    if (policyHeader == null || policyHeader.getPolicyRevision() == policyVersion.getOrdinal()) continue;
                }
                catch (FindException findException) {
                    throw PolicyCacheImpl.a((Exception)((Object)findException));
                }
                Policy policy = (Policy)this.j.findByPrimaryKey(policyVersion.getPolicyGoid());
                try {
                    if (policy == null) {
                        this.b(policyVersion.getPolicyGoid());
                        continue;
                    }
                }
                catch (FindException findException) {
                    throw PolicyCacheImpl.a((Exception)((Object)findException));
                }
                this.a(policy, policyVersion.getOrdinal());
            }
        }
        catch (FindException findException) {
            this.a();
            this.logAndAudit((AuditDetailMessage)MessageProcessingMessages.POLICY_CACHE_STORAGE_ERROR, new String[]{Goid.toString((Goid)goid)}, (Exception)((Object)findException));
        }
    }

    private void a(Policy policy, long l2) {
        block3: {
            block2: {
                try {
                    if (this.o.wasProcessed(policy.getGoid(), l2)) break block2;
                    this.o.addProcessedEntity(policy.getGoid(), l2);
                    this.b(this.a(policy));
                    break block3;
                }
                catch (IllegalArgumentException illegalArgumentException) {
                    throw PolicyCacheImpl.a(illegalArgumentException);
                }
            }
            d.fine(new w(this, policy, l2));
        }
    }

    @ManagedAttribute(description="Cache Size", currencyTimeLimit=30)
    public int getSize() {
        this.q.readLock().lock();
        try {
            int n2 = this.u.size();
            return n2;
        }
        finally {
            this.q.readLock().unlock();
        }
    }

    @ManagedAttribute(description="Cached Policies", currencyTimeLimit=30)
    public Set<Goid> getPolicies() {
        this.q.readLock().lock();
        try {
            TreeSet<Goid> treeSet = new TreeSet<Goid>(this.u.keySet());
            return treeSet;
        }
        finally {
            this.q.readLock().unlock();
        }
    }

    @ManagedAttribute(description="Unlicensed Policies", currencyTimeLimit=30)
    public Set<Goid> getUnlicensedPolicies() {
        this.q.readLock().lock();
        try {
            TreeSet<Goid> treeSet = new TreeSet<Goid>(this.t);
            return treeSet;
        }
        finally {
            this.q.readLock().unlock();
        }
    }

    void a(Level level) {
        this.f = level;
    }

    boolean a(Goid goid) {
        boolean bl2;
        try {
            bl2 = this.f(goid) != null;
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw PolicyCacheImpl.a(illegalArgumentException);
        }
        return bl2;
    }

    void a(Goid goid, boolean bl2) {
        block3: {
            block2: {
                try {
                    if (!bl2) break block2;
                    this.t.remove(goid);
                    break block3;
                }
                catch (IllegalArgumentException illegalArgumentException) {
                    throw PolicyCacheImpl.a(illegalArgumentException);
                }
            }
            this.t.add(goid);
        }
    }

    protected ServerAssertion buildServerPolicy(Policy policy) throws ServerPolicyException, InvalidPolicyException {
        ServerAssertion serverAssertion;
        boolean bl2;
        Assertion assertion = PolicyCacheImpl.e(policy);
        try {
            bl2 = policy.getVisibility() == e;
        }
        catch (LicenseException licenseException) {
            throw PolicyCacheImpl.a((Exception)((Object)licenseException));
        }
        PolicyCacheImpl.a(bl2, new x(this));
        if (assertion == null) {
            assertion = new TrueAssertion();
        }
        try {
            serverAssertion = this.m.compilePolicy(assertion, true);
            this.a(policy.getGoid(), true);
        }
        catch (LicenseException licenseException) {
            this.a(policy.getGoid(), false);
            this.logAndAudit((AuditDetailMessage)MessageProcessingMessages.POLICY_CACHE_UNLICENSED, policy.getName(), Goid.toString((Goid)policy.getGoid()), ExceptionUtils.getMessage((Throwable)licenseException));
            String string = y[26] + ExceptionUtils.getMessage((Throwable)licenseException);
            serverAssertion = new ap(this, new UnknownAssertion(), string);
        }
        return serverAssertion;
    }

    protected void logAndAudit(AuditDetailMessage auditDetailMessage, String ... stringArray) {
        this.h.logAndAudit(auditDetailMessage, stringArray);
    }

    protected void logAndAudit(AuditDetailMessage auditDetailMessage, String[] stringArray, Exception exception) {
        this.h.logAndAudit(auditDetailMessage, stringArray, exception);
    }

    private void b(Policy policy) {
        this.d(policy);
    }

    private void b(Goid goid) {
        d.log(Level.FINE, new y(this, goid));
        this.g(goid);
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     * Enabled force condition propagation
     * Lifted jumps to return sites
     */
    private Set<Policy> c(Goid goid) {
        HashSet<Policy> hashSet = new HashSet<Policy>();
        Lock lock = this.q.readLock();
        lock.lock();
        try {
            aa aa2 = this.e(goid);
            if (aa2 == null) return Collections.unmodifiableSet(hashSet);
            Set<Goid> set = aa2.f;
            for (Goid goid2 : set) {
                aa aa3 = this.e(goid2);
                try {
                    if (aa3 == null) continue;
                    hashSet.add(aa3.b);
                }
                catch (IllegalArgumentException illegalArgumentException) {
                    throw PolicyCacheImpl.a(illegalArgumentException);
                    return Collections.unmodifiableSet(hashSet);
                }
            }
        }
        finally {
            lock.unlock();
        }
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     * Enabled force condition propagation
     * Lifted jumps to return sites
     */
    private void a(Goid goid, Map<Goid, Policy> map) {
        Lock lock = this.q.readLock();
        lock.lock();
        try {
            for (Policy policy : this.c(goid)) {
                try {
                    if (map.containsKey(policy.getGoid())) continue;
                    map.put(policy.getGoid(), policy);
                    this.a(policy.getGoid(), map);
                }
                catch (IllegalArgumentException illegalArgumentException) {
                    throw PolicyCacheImpl.a(illegalArgumentException);
                    return;
                }
            }
        }
        finally {
            lock.unlock();
        }
    }

    private void a(Goid goid, boolean bl2, Set<Goid> set) {
        for (Goid goid2 : set) {
            aa aa2;
            block5: {
                aa2 = this.e(goid2);
                try {
                    try {
                        if (aa2 == null) continue;
                        if (!bl2) break block5;
                    }
                    catch (IllegalArgumentException illegalArgumentException) {
                        throw PolicyCacheImpl.a(illegalArgumentException);
                    }
                    aa2.f.add(goid);
                    continue;
                }
                catch (IllegalArgumentException illegalArgumentException) {
                    throw PolicyCacheImpl.a(illegalArgumentException);
                }
            }
            aa2.f.remove(goid);
        }
    }

    private void a(aa aa2) {
        try {
            if (!PersistentEntityUtil.isLocked((PersistentEntity)aa2.b)) {
                throw new IllegalArgumentException(y[9]);
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw PolicyCacheImpl.a(illegalArgumentException);
        }
        aa aa3 = this.u.put(aa2.a, aa2);
        try {
            if (aa3 != null) {
                ResourceUtils.closeQuietly((Closeable)aa3);
                this.v.remove(aa3.b.getGuid());
                aa2.f.addAll(aa3.f);
                this.a(aa2.a, false, aa3.b());
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw PolicyCacheImpl.a(illegalArgumentException);
        }
        this.v.put(aa2.b.getGuid(), aa2.a);
        this.a(aa2.a, true, aa2.b());
    }

    private aa d(Goid goid) {
        aa aa2 = this.u.remove(goid);
        if (aa2 != null) {
            ResourceUtils.closeQuietly((Closeable)aa2);
            this.v.remove(aa2.b.getGuid());
            this.a(goid, false, aa2.b());
            HashSet<Goid> hashSet = new HashSet<Goid>();
            for (Goid goid2 : aa2.b()) {
                aa aa3 = this.e(goid2);
                try {
                    try {
                        try {
                            if (aa3 == null || aa3.isValid()) continue;
                        }
                        catch (IllegalArgumentException illegalArgumentException) {
                            throw PolicyCacheImpl.a(illegalArgumentException);
                        }
                        if (!aa3.f.isEmpty()) continue;
                    }
                    catch (IllegalArgumentException illegalArgumentException) {
                        throw PolicyCacheImpl.a(illegalArgumentException);
                    }
                    hashSet.add(goid2);
                }
                catch (IllegalArgumentException illegalArgumentException) {
                    throw PolicyCacheImpl.a(illegalArgumentException);
                }
            }
            for (Goid goid2 : hashSet) {
                this.d(goid2);
            }
        }
        return aa2;
    }

    private aa e(Goid goid) {
        return this.u.get(goid);
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     */
    private aa f(Goid goid) {
        aa aa2;
        Lock lock = this.q.readLock();
        lock.lock();
        try {
            aa2 = this.e(goid);
        }
        finally {
            lock.unlock();
        }
        return aa2;
    }

    private void c(Policy policy) {
        block11: {
            aa aa2 = this.f(policy.getGoid());
            try {
                block10: {
                    try {
                        try {
                            try {
                                try {
                                    if (aa2 == null || aa2.c()) break block10;
                                }
                                catch (IllegalArgumentException illegalArgumentException) {
                                    throw PolicyCacheImpl.a(illegalArgumentException);
                                }
                                if (!aa2.isValid()) break block10;
                            }
                            catch (IllegalArgumentException illegalArgumentException) {
                                throw PolicyCacheImpl.a(illegalArgumentException);
                            }
                            if (aa2.b.getVersion() != policy.getVersion()) break block10;
                        }
                        catch (IllegalArgumentException illegalArgumentException) {
                            throw PolicyCacheImpl.a(illegalArgumentException);
                        }
                        if (aa2.b.getXml().equals(policy.getXml())) break block11;
                    }
                    catch (IllegalArgumentException illegalArgumentException) {
                        throw PolicyCacheImpl.a(illegalArgumentException);
                    }
                }
                this.d(policy);
            }
            catch (IllegalArgumentException illegalArgumentException) {
                throw PolicyCacheImpl.a(illegalArgumentException);
            }
        }
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     */
    private void d(Policy policy) {
        d.log(Level.FINE, new z(this, policy));
        ArrayList<PolicyCacheEvent> arrayList = new ArrayList<PolicyCacheEvent>();
        Lock lock = this.q.writeLock();
        lock.lock();
        try {
            this.w.clear();
            HashMap<Goid, Policy> hashMap = new HashMap<Goid, Policy>();
            this.a(policy.getGoid(), hashMap);
            this.a(Collections.singleton(policy.getGoid()));
            this.a(hashMap.keySet());
            this.b(policy, null, new HashSet<Goid>(), new HashMap<Goid, Integer>(), arrayList);
            for (Policy policy2 : hashMap.values()) {
                this.a(policy2, null, new HashSet<Goid>(), new HashMap<Goid, Integer>(), arrayList);
                this.b(this.e(policy2.getGoid()));
            }
            this.b(this.e(policy.getGoid()));
        }
        finally {
            lock.unlock();
        }
        for (PolicyCacheEvent policyCacheEvent : arrayList) {
            this.a(policyCacheEvent);
        }
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     */
    private boolean g(Goid goid) {
        Policy policy;
        HashSet<Goid> hashSet;
        boolean bl2;
        block10: {
            bl2 = false;
            hashSet = new HashSet<Goid>();
            Lock lock = this.q.writeLock();
            lock.lock();
            try {
                Policy policy2;
                block12: {
                    HashMap<Goid, Policy> hashMap;
                    block11: {
                        this.w.clear();
                        aa aa2 = this.e(goid);
                        if (aa2 == null) {
                            policy = null;
                            String[] stringArray = y;
                            d.log(Level.FINE, stringArray[24], goid);
                            break block10;
                        }
                        bl2 = true;
                        policy2 = aa2.b;
                        hashMap = new HashMap<Goid, Policy>();
                        try {
                            this.a(goid, hashMap);
                            this.a(hashMap.keySet());
                            d.log(Level.FINE, y[32], goid);
                            if (!hashMap.isEmpty()) break block11;
                            this.d(goid);
                            break block12;
                        }
                        catch (IllegalArgumentException illegalArgumentException) {
                            throw PolicyCacheImpl.a(illegalArgumentException);
                        }
                    }
                    d.log(Level.FINE, y[1], new Object[]{goid, hashMap.keySet()});
                    this.a(policy2, null, hashMap.keySet(), hashSet);
                }
                policy = policy2;
                this.b(this.e(goid));
            }
            finally {
                lock.unlock();
            }
        }
        try {
            if (policy != null) {
                this.a(new PolicyCacheEvent.Deleted(this, policy));
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw PolicyCacheImpl.a(illegalArgumentException);
        }
        for (Goid goid2 : hashSet) {
            this.a(new PolicyCacheEvent.Invalid(this, goid2, null));
        }
        return bl2;
    }

    private void a(Policy policy, @Nullable Goid goid, Set<Goid> set, Set<Goid> set2) {
        Goid goid2 = policy.getGoid();
        aa aa2 = this.e(goid2);
        try {
            if (aa2 != null) {
                set2.add(goid2);
                this.a(new aa(aa2.b, goid));
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw PolicyCacheImpl.a(illegalArgumentException);
        }
        Set<Policy> set3 = this.c(goid2);
        for (Policy policy2 : set3) {
            Goid goid3 = policy2.getGoid();
            try {
                if (!set.contains(goid3)) continue;
                set.remove(goid3);
                this.a(policy2, goid2, set, set2);
            }
            catch (IllegalArgumentException illegalArgumentException) {
                throw PolicyCacheImpl.a(illegalArgumentException);
            }
        }
    }

    private void a(Policy policy, @Nullable Policy policy2, Set<Goid> set, Map<Goid, Integer> map, List<PolicyCacheEvent> list) {
        block4: {
            aa aa2 = this.e(policy.getGoid());
            try {
                try {
                    if (aa2 != null && !aa2.c()) break block4;
                }
                catch (IllegalArgumentException illegalArgumentException) {
                    throw PolicyCacheImpl.a(illegalArgumentException);
                }
                this.b(policy, policy2, set, map, list);
            }
            catch (IllegalArgumentException illegalArgumentException) {
                throw PolicyCacheImpl.a(illegalArgumentException);
            }
        }
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     */
    aa b(Policy policy, @Nullable Policy policy2, Set<Goid> set, Map<Goid, Integer> map, List<PolicyCacheEvent> list) {
        Object object;
        Goid goid = policy.getGoid();
        map.put(goid, policy.getVersion());
        HashSet<Goid> hashSet = new HashSet<Goid>();
        d.log(Level.FINE, new i(this, goid, policy));
        PolicyMetadata policyMetadata = null;
        ServerAssertion serverAssertion = null;
        Object object2 = null;
        MutableObject mutableObject = new MutableObject();
        try {
            Object object3;
            try {
                PolicyCacheImpl.a(set.add(goid), new j(this, policy2, policy));
                Assertion assertion = PolicyCacheImpl.e(policy);
                object3 = Optional.ofNullable(assertion.preorderIterator()).orElse((Iterator)new EmptyIterator());
                while (object3.hasNext()) {
                    boolean bl2;
                    Assertion assertion2 = (Assertion)object3.next();
                    try {
                        if (!(assertion2 instanceof Include)) {
                            continue;
                        }
                    }
                    catch (ServerPolicyException serverPolicyException) {
                        throw PolicyCacheImpl.a((Exception)((Object)serverPolicyException));
                    }
                    Include include = (Include)assertion2;
                    String string = include.getPolicyGuid();
                    try {
                        d.log(Level.FINE, new k(this, goid, policy, string, include));
                        bl2 = string != null;
                    }
                    catch (ServerPolicyException serverPolicyException) {
                        throw PolicyCacheImpl.a((Exception)((Object)serverPolicyException));
                    }
                    PolicyCacheImpl.a(bl2, new l(this, policy));
                    this.a(policy, policy2, include, set, hashSet, map, list, (MutableObject<Goid>)mutableObject);
                }
                policyMetadata = this.a(policy, assertion, hashSet);
                serverAssertion = this.buildServerPolicy(policy);
            }
            catch (ServerPolicyException serverPolicyException) {
                boolean bl3 = true;
                if (ExceptionUtils.causedBy((Throwable)((Object)serverPolicyException), PolicyAssertionException.class)) {
                    bl3 = false;
                }
                this.a(policy, (Exception)((Object)serverPolicyException), bl3);
                object2 = serverPolicyException;
            }
            catch (CircularPolicyException | InvalidPolicyException | ServerPolicyInstantiationException throwable) {
                this.a(policy, (Exception)throwable, false);
                object2 = throwable;
            }
            catch (FindException findException) {
                this.a();
                this.logAndAudit((AuditDetailMessage)MessageProcessingMessages.POLICY_CACHE_STORAGE_ERROR, new String[]{Goid.toString((Goid)goid)}, (Exception)((Object)findException));
                object2 = findException;
            }
            set.remove(goid);
            object3 = this.a(goid, policy, map, hashSet, policyMetadata, serverAssertion, (Goid)mutableObject.getValue());
            this.a((aa)object3);
            serverAssertion = null;
            this.a(goid, policy, (Exception)object2, list, (aa)object3);
            object = object3;
        }
        catch (Throwable throwable) {
            ResourceUtils.closeQuietly(serverAssertion);
            throw throwable;
        }
        ResourceUtils.closeQuietly((Closeable)serverAssertion);
        return object;
    }

    private void a(Policy policy, @Nullable Policy policy2, Include include, Set<Goid> set, Set<Goid> set2, Map<Goid, Integer> map, List<PolicyCacheEvent> list, MutableObject<Goid> mutableObject) throws FindException, ServerPolicyInstantiationException, CircularPolicyException {
        Goid goid;
        aa aa2;
        block11: {
            block10: {
                boolean bl2;
                String string = include.getPolicyGuid();
                aa2 = null;
                if (this.v.containsKey(string)) {
                    aa2 = this.e(this.v.get(string));
                }
                try {
                    if (aa2 != null && !aa2.c()) break block10;
                }
                catch (FindException findException) {
                    throw PolicyCacheImpl.a((Exception)((Object)findException));
                }
                d.log(Level.FINE, new m(this, string, include));
                Policy policy3 = this.j.findByGuid(string);
                try {
                    bl2 = policy3 != null;
                }
                catch (FindException findException) {
                    throw PolicyCacheImpl.a((Exception)((Object)findException));
                }
                PolicyCacheImpl.a(bl2, new n(this, policy, string));
                goid = policy3.getGoid();
                set2.add(goid);
                aa2 = this.b(this.a(policy3), policy, set, map, list);
                break block11;
            }
            goid = aa2.a;
            set2.add(goid);
        }
        if (aa2.isValid()) {
            d.log(Level.FINE, new o(this, goid, include));
            map.putAll(aa2.a().getDependentVersions(true));
            set2.addAll(aa2.a().getUsedPolicyIds(false));
            for (Goid goid2 : aa2.a().getUsedPolicyIds(false)) {
                boolean bl3;
                try {
                    bl3 = !set.contains(goid2);
                }
                catch (FindException findException) {
                    throw PolicyCacheImpl.a((Exception)((Object)findException));
                }
                PolicyCacheImpl.a(bl3, new p(this, policy2, policy));
            }
        } else {
            d.log(Level.FINE, new q(this, goid, include));
            aa2.f.add(policy.getGoid());
            mutableObject.setValue((Object)aa2.a);
            String[] stringArray = y;
            throw new ServerPolicyInstantiationException(stringArray[25] + String.valueOf(policy.getGoid()) + stringArray[19] + String.valueOf(goid) + stringArray[7]);
        }
    }

    private static Assertion e(Policy policy) throws InvalidPolicyException {
        Assertion assertion;
        try {
            assertion = policy.getAssertion();
        }
        catch (IOException iOException) {
            String[] stringArray = y;
            throw new InvalidPolicyException(stringArray[10] + String.valueOf(policy.getGoid()) + stringArray[27] + ExceptionUtils.getMessage((Throwable)iOException), (Throwable)iOException);
        }
        return assertion;
    }

    @NotNull
    private aa a(Goid goid, Policy policy, Map<Goid, Integer> map, Set<Goid> set, PolicyMetadata policyMetadata, ServerAssertion serverAssertion, Goid goid2) {
        aa aa2;
        aa aa3;
        if (serverAssertion != null) {
            ServerPolicy serverPolicy = new ServerPolicy(policy, policyMetadata, set, map, serverAssertion, new r(this, goid));
            aa3 = new aa(this.a(policy), serverPolicy, null);
        } else {
            aa3 = new aa(this.a(policy), goid2);
        }
        try {
            aa2 = aa3;
            if (aa2 == null) {
                PolicyCacheImpl.a(1);
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw PolicyCacheImpl.a(illegalArgumentException);
        }
        return aa2;
    }

    private void a(Goid goid, Policy policy, Exception exception, List<PolicyCacheEvent> list, aa aa2) {
        block3: {
            block2: {
                try {
                    if (!aa2.isValid()) break block2;
                    list.add(new PolicyCacheEvent.Updated(this, policy));
                    break block3;
                }
                catch (IllegalArgumentException illegalArgumentException) {
                    throw PolicyCacheImpl.a(illegalArgumentException);
                }
            }
            list.add(new PolicyCacheEvent.Invalid(this, goid, exception));
        }
    }

    private void a(Policy policy, Exception exception, boolean bl2) {
        Exception exception2;
        String[] stringArray;
        Messages.M m2;
        PolicyCacheImpl policyCacheImpl;
        try {
            policyCacheImpl = this;
            m2 = MessageProcessingMessages.POLICY_CACHE_INVALID;
            String[] stringArray2 = new String[3];
            stringArray2[0] = policy.getName();
            stringArray2[1] = policy.getId();
            stringArray = stringArray2;
            stringArray2[2] = ExceptionUtils.getMessage((Throwable)exception);
            exception2 = bl2 ? exception : (Exception)ExceptionUtils.getDebugException((Throwable)exception);
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw PolicyCacheImpl.a(illegalArgumentException);
        }
        policyCacheImpl.logAndAudit((AuditDetailMessage)m2, stringArray, exception2);
    }

    private void a() {
        Lock lock = this.q.writeLock();
        lock.lock();
        try {
            this.w.clear();
            this.r = true;
        }
        finally {
            lock.unlock();
        }
    }

    private void a(Set<Goid> set) {
        for (Goid goid : set) {
            aa aa2 = this.e(goid);
            try {
                if (aa2 == null) continue;
                aa2.d();
            }
            catch (IllegalArgumentException illegalArgumentException) {
                throw PolicyCacheImpl.a(illegalArgumentException);
            }
        }
    }

    private void h(Goid goid) throws PolicyDeletionForbiddenException {
        block5: {
            aa aa2 = this.e(goid);
            try {
                if (aa2 == null || aa2.f.isEmpty()) break block5;
            }
            catch (PolicyDeletionForbiddenException policyDeletionForbiddenException) {
                throw PolicyCacheImpl.a((Exception)((Object)policyDeletionForbiddenException));
            }
            for (Goid goid2 : aa2.f) {
                aa aa3 = this.e(goid2);
                try {
                    if (aa3 == null) continue;
                    throw new PolicyDeletionForbiddenException(aa2.b, EntityType.POLICY, (Entity)aa3.b);
                }
                catch (PolicyDeletionForbiddenException policyDeletionForbiddenException) {
                    throw PolicyCacheImpl.a((Exception)((Object)policyDeletionForbiddenException));
                }
            }
        }
    }

    private Set<String> b(Set<Policy> set) {
        HashSet<String> hashSet = new HashSet<String>();
        for (Policy policy : set) {
            hashSet.add(policy.getGuid());
        }
        return hashSet;
    }

    private PolicyMetadata a(Policy policy, @Nullable Assertion assertion, Set<Goid> set) throws FindException {
        Iterator iterator;
        long l2 = 0L;
        PolicyVersion policyVersion = this.k.findActiveVersionForPolicy(policy.getGoid());
        if (policyVersion != null) {
            l2 = policyVersion.getOrdinal();
        }
        MutableBoolean mutableBoolean = new MutableBoolean(false);
        MutableBoolean mutableBoolean2 = new MutableBoolean(false);
        TreeSet<String> treeSet = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
        TreeMap<String, VariableMetadata> treeMap = new TreeMap<String, VariableMetadata>(String.CASE_INSENSITIVE_ORDER);
        try {
            Iterator iterator2 = iterator = assertion != null ? assertion.preorderIterator() : new EmptyIterator();
        }
        catch (FindException findException) {
            throw PolicyCacheImpl.a((Exception)((Object)findException));
        }
        while (iterator.hasNext()) {
            Assertion assertion2 = (Assertion)iterator.next();
            try {
                if (!assertion2.isEnabled()) {
                    continue;
                }
            }
            catch (FindException findException) {
                throw PolicyCacheImpl.a((Exception)((Object)findException));
            }
            PolicyCacheImpl.a(assertion2, mutableBoolean, mutableBoolean2);
            PolicyCacheImpl.a(treeSet, treeMap, assertion2);
        }
        for (Goid goid : set) {
            this.a(goid, mutableBoolean, mutableBoolean2, treeSet, treeMap);
        }
        boolean bl2 = mutableBoolean.booleanValue();
        boolean bl3 = mutableBoolean2.booleanValue();
        String[] stringArray = treeSet.toArray(new String[treeSet.size()]);
        VariableMetadata[] variableMetadataArray = treeMap.values().toArray(new VariableMetadata[0]);
        PolicyHeader policyHeader = new PolicyHeader(policy, l2);
        return new t(this, bl2, bl3, stringArray, variableMetadataArray, policyHeader);
    }

    private void a(Goid goid, MutableBoolean mutableBoolean, MutableBoolean mutableBoolean2, Set<String> set, Map<String, VariableMetadata> map) {
        block13: {
            boolean bl2;
            MutableBoolean mutableBoolean3;
            PolicyMetadata policyMetadata;
            block17: {
                block16: {
                    boolean bl3;
                    MutableBoolean mutableBoolean4;
                    block15: {
                        block14: {
                            aa aa2 = this.e(goid);
                            try {
                                if (aa2 == null || !aa2.isValid()) break block13;
                            }
                            catch (IllegalArgumentException illegalArgumentException) {
                                throw PolicyCacheImpl.a(illegalArgumentException);
                            }
                            policyMetadata = aa2.c.getPolicyMetadata();
                            try {
                                try {
                                    mutableBoolean4 = mutableBoolean;
                                    if (!mutableBoolean.booleanValue() && !policyMetadata.isWssInPolicy()) break block14;
                                }
                                catch (IllegalArgumentException illegalArgumentException) {
                                    throw PolicyCacheImpl.a(illegalArgumentException);
                                }
                                bl3 = true;
                                break block15;
                            }
                            catch (IllegalArgumentException illegalArgumentException) {
                                throw PolicyCacheImpl.a(illegalArgumentException);
                            }
                        }
                        bl3 = false;
                    }
                    try {
                        try {
                            mutableBoolean4.setValue(bl3);
                            mutableBoolean3 = mutableBoolean2;
                            if (!mutableBoolean2.booleanValue() && !policyMetadata.isMultipart()) break block16;
                        }
                        catch (IllegalArgumentException illegalArgumentException) {
                            throw PolicyCacheImpl.a(illegalArgumentException);
                        }
                        bl2 = true;
                        break block17;
                    }
                    catch (IllegalArgumentException illegalArgumentException) {
                        throw PolicyCacheImpl.a(illegalArgumentException);
                    }
                }
                bl2 = false;
            }
            mutableBoolean3.setValue(bl2);
            String[] stringArray = policyMetadata.getVariablesUsed();
            try {
                if (stringArray != null) {
                    set.addAll(Arrays.asList(stringArray));
                }
            }
            catch (IllegalArgumentException illegalArgumentException) {
                throw PolicyCacheImpl.a(illegalArgumentException);
            }
            PolicyCacheImpl.a(map, PolicyVariableUtils.getVariablesSetNoThrow((SetsVariables)policyMetadata));
        }
    }

    private static void a(Assertion assertion, MutableBoolean mutableBoolean, MutableBoolean mutableBoolean2) {
        block9: {
            block8: {
                try {
                    try {
                        if (!Assertion.isRequest((Assertion)assertion) || !Assertion.isWSSecurity((Assertion)assertion)) break block8;
                    }
                    catch (IllegalArgumentException illegalArgumentException) {
                        throw PolicyCacheImpl.a(illegalArgumentException);
                    }
                    mutableBoolean.setValue(true);
                    break block9;
                }
                catch (IllegalArgumentException illegalArgumentException) {
                    throw PolicyCacheImpl.a(illegalArgumentException);
                }
            }
            try {
                try {
                    if (!Assertion.isMultipart((Assertion)assertion) || !Assertion.isRequest((Assertion)assertion)) break block9;
                }
                catch (IllegalArgumentException illegalArgumentException) {
                    throw PolicyCacheImpl.a(illegalArgumentException);
                }
                mutableBoolean2.setValue(true);
            }
            catch (IllegalArgumentException illegalArgumentException) {
                throw PolicyCacheImpl.a(illegalArgumentException);
            }
        }
    }

    private static void a(Set<String> set, Map<String, VariableMetadata> map, Assertion assertion) {
        String[] stringArray;
        if (assertion instanceof UsesVariables) {
            stringArray = PolicyVariableUtils.getVariablesUsedNoThrow((UsesVariables)((UsesVariables)assertion));
            try {
                if (stringArray != null) {
                    set.addAll(Arrays.asList(stringArray));
                }
            }
            catch (IllegalArgumentException illegalArgumentException) {
                throw PolicyCacheImpl.a(illegalArgumentException);
            }
        }
        if (assertion instanceof SetsVariables) {
            stringArray = PolicyVariableUtils.getVariablesSetNoThrow((SetsVariables)((SetsVariables)assertion));
            PolicyCacheImpl.a(map, (VariableMetadata[])stringArray);
        }
    }

    private static void a(Map<String, VariableMetadata> map, VariableMetadata[] variableMetadataArray) {
        if (variableMetadataArray != null) {
            for (VariableMetadata variableMetadata : variableMetadataArray) {
                map.put(variableMetadata.getName(), variableMetadata);
            }
        }
    }

    private void b() {
        HashSet<Goid> hashSet;
        Lock lock = this.q.readLock();
        lock.lock();
        try {
            hashSet = new HashSet<Goid>(this.t);
        }
        finally {
            lock.unlock();
        }
        int n2 = hashSet.size();
        try {
            if (n2 < 1) {
                return;
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw PolicyCacheImpl.a(illegalArgumentException);
        }
        this.logAndAudit((AuditDetailMessage)MessageProcessingMessages.POLICY_CACHE_RESETTING_POLICIES, Integer.toString(n2));
        this.c(hashSet);
    }

    private void c() {
        HashSet<Goid> hashSet;
        Lock lock = this.q.readLock();
        lock.lock();
        try {
            hashSet = new HashSet<Goid>(this.u.keySet());
        }
        finally {
            lock.unlock();
        }
        this.logAndAudit((AuditDetailMessage)MessageProcessingMessages.POLICY_CACHE_MODULE_UNLOAD, new String[0]);
        this.c(hashSet);
    }

    private boolean a(Either<ModularAssertionModule, CustomAssertionModule> either) {
        boolean bl2;
        try {
            bl2 = either.isLeft() ? this.a((BaseAssertionModule)either.left()) : this.a((BaseAssertionModule)either.right());
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw PolicyCacheImpl.a(illegalArgumentException);
        }
        return bl2;
    }

    private boolean a(BaseAssertionModule<?> baseAssertionModule) {
        String[] stringArray;
        try {
            if (!baseAssertionModule.isFromDb()) {
                return true;
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw PolicyCacheImpl.a(illegalArgumentException);
        }
        String[] stringArray2 = y;
        for (String string : stringArray = this.l.getProperty(stringArray2[2], "").split(stringArray2[14])) {
            try {
                if (!string.equals(baseAssertionModule.getEntityName())) continue;
                return false;
            }
            catch (IllegalArgumentException illegalArgumentException) {
                throw PolicyCacheImpl.a(illegalArgumentException);
            }
        }
        return true;
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     */
    private void c(Set<Goid> set) {
        Lock lock = this.q.writeLock();
        lock.lock();
        try {
            this.w.clear();
            this.a(set);
            for (Goid goid : set) {
                aa aa2 = this.e(goid);
                try {
                    if (aa2 == null) {
                        continue;
                    }
                }
                catch (FindException findException) {
                    throw PolicyCacheImpl.a((Exception)((Object)findException));
                }
                Policy policy = null;
                try {
                    policy = (Policy)this.j.findByPrimaryKey(goid);
                }
                catch (FindException findException) {
                    this.a();
                    this.logAndAudit((AuditDetailMessage)MessageProcessingMessages.POLICY_CACHE_STORAGE_ERROR, new String[]{goid.toString()}, (Exception)((Object)findException));
                }
                try {
                    if (policy != null) {
                        this.d(this.a(policy));
                        continue;
                    }
                }
                catch (FindException findException) {
                    throw PolicyCacheImpl.a((Exception)((Object)findException));
                }
                this.g(goid);
            }
        }
        finally {
            lock.unlock();
        }
        this.a(new PolicyCacheEvent.Reset(this));
    }

    private void d() {
        boolean bl2;
        Lock lock = this.q.readLock();
        lock.lock();
        try {
            boolean bl3;
            block10: {
                block9: {
                    if (this.s) {
                        try {
                            if (!this.r) break block9;
                            bl3 = true;
                            break block10;
                        }
                        catch (IllegalArgumentException illegalArgumentException) {
                            throw PolicyCacheImpl.a(illegalArgumentException);
                        }
                    }
                }
                bl3 = false;
            }
            bl2 = bl3;
        }
        finally {
            lock.unlock();
        }
        try {
            if (bl2) {
                this.initializePolicyCache();
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw PolicyCacheImpl.a(illegalArgumentException);
        }
    }

    private void a(Runnable runnable) {
        block3: {
            block2: {
                try {
                    if (this.g == null) break block2;
                    new TransactionTemplate(this.g).execute((TransactionCallback)new aw(this, runnable));
                    break block3;
                }
                catch (IllegalArgumentException illegalArgumentException) {
                    throw PolicyCacheImpl.a(illegalArgumentException);
                }
            }
            runnable.run();
        }
    }

    private void a(PolicyCacheEvent policyCacheEvent) {
        this.i.publishEvent((ApplicationEvent)policyCacheEvent);
    }

    private void e() {
        this.i.publishEvent((ApplicationEvent)new PolicyReloadEvent(this));
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     */
    private void f() {
        if (d.isLoggable(this.f)) {
            Lock lock = this.q.readLock();
            lock.lock();
            try {
                for (aa aa2 : this.u.values()) {
                    this.b(aa2);
                }
            }
            finally {
                lock.unlock();
            }
        }
    }

    private void b(aa aa2) {
        block4: {
            String[] stringArray;
            StringBuilder stringBuilder;
            block6: {
                block5: {
                    try {
                        if (aa2 == null || !d.isLoggable(this.f)) break block4;
                    }
                    catch (IllegalArgumentException illegalArgumentException) {
                        throw PolicyCacheImpl.a(illegalArgumentException);
                    }
                    stringBuilder = new StringBuilder();
                    try {
                        stringBuilder.append(y[12]);
                        stringBuilder.append(aa2.b.getVersion());
                        stringBuilder.append('\n');
                        if (!aa2.isValid()) break block5;
                        stringBuilder.append(y[30]);
                        stringBuilder.append(aa2.a().getPolicyUniqueIdentifier());
                        stringBuilder.append('\n');
                        stringBuilder.append(y[16]);
                        stringBuilder.append(aa2.a().getUsedPolicyIds(false));
                        stringBuilder.append('\n');
                        break block6;
                    }
                    catch (IllegalArgumentException illegalArgumentException) {
                        throw PolicyCacheImpl.a(illegalArgumentException);
                    }
                }
                stringArray = y;
                stringBuilder.append(stringArray[33]);
            }
            stringArray = y;
            stringBuilder.append(stringArray[23]);
            stringBuilder.append(aa2.f);
            stringBuilder.append('\n');
            d.log(this.f, stringArray[15] + String.valueOf(aa2.a) + "\n" + stringBuilder.toString());
        }
    }

    private static <T extends Exception> void a(boolean bl2, @NotNull Supplier<T> supplier) throws T {
        try {
            if (supplier == null) {
                PolicyCacheImpl.a(2);
            }
        }
        catch (Exception exception) {
            throw PolicyCacheImpl.a(exception);
        }
        try {
            if (!bl2) {
                throw (Exception)supplier.get();
            }
        }
        catch (Exception exception) {
            throw PolicyCacheImpl.a(exception);
        }
    }

    private static void a(boolean bl2, String string) {
        try {
            if (!bl2) {
                throw new IllegalArgumentException(string);
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw PolicyCacheImpl.a(illegalArgumentException);
        }
    }

    /*
     * Unable to fully structure code
     */
    static {
        block10: {
            block9: {
                var5 = new String[34];
                var3_1 = 0;
                var2_2 = "I\u001bsvG\u0013\u0013e\u0017m8_VPkZ\u007f#R]\u0014'\u0014x&\u0013C\u001ff\u0013~(\u001e\u001e\u0019~Zp$@GPh\u001f=\"RE\u0015nZ{8A@\u0004-I\u001b~9Z]\u0017**r=ZP\t*YfaN\u0013\u0011yZt?ER\u001cc\u001e=7\\AP\u007f\tx#@\tPqK`Hy\u001fo'VA=e\u001eh=Vu\u0019f\u001f3\u0001\\_\u0019i\u0003^0P[\u0015C\u0014k0_Z\u0014k\u000et>]|\u001e_\u0014o4TZ\u0003~\b|%Z\\\u001e$\u001fe2_F\u0014o\u001eP>WF\u001co\t\u000ez\bx!RA\u0015n*r=ZP\t\u0018O\bo>A\u0013\u0011i\u0019x\"@Z\u001emZm>_Z\u0013c\u001fn\u0011o\u0002~4CG\u0019e\u0014N$CC\u001cc\u001fo\ni\u0012x2Xe\u0011f\u000fx\u0012-Zj9ZP\u0018*\u0013nqZ]\u0006k\u0016t5&C\u001ds>AZ\u001emZy8@R\u0012f\u001fyq\u0014\u0014\u000b:\u0007:v\u0013\tP)\u0001,,\u0013\u001b\u000b8\u000747_\u0014q>PX\u0015nZm>_Z\u0013sZp0J\u0013\u001ee\u000e=3V\u0013\u0000f\u001b~4W\u0013\u0019d\u000erqG[\u0015*\nr=ZP\t*\u0019|2[V\u0017C\u0014k0_Z\u0014*\nr=ZP\t*\rt%[\u0013\u0019nZ(i\u0015p~_\u0004\u0004o\u0019u~@V\u0002|\u001fo~C\\\u001cc\u0019d~c\\\u001cc\u0019d\u0012RP\u0018o3p!_\t\\\u001fo\"Z\\\u001e0Z>K\bz$^V\u001e~Z{>A\u00130D\u0015i\u001fF_\u001c*\n|#R^\u0015~\u001foq\u0014\u0016\u0003-Zr7\u0013\u0016\u0003$_nq^F\u0003~Zs>G\u0013\u0012oZs$__\u0007V\t7}o@Z\u001bN\u001fm4]W\u0015d\u0019dqZ]\u0016eZ{>A\u0013\u0000e\u0016t2J\u0013\u0006_\tx\"\t\u00138I\u001bsvG\u0013\u0013e\u0017m8_VPkZ\u007f#R]\u0014'\u0014x&\u0013C\u001ff\u0013~(\u001e\u001e\u0019~Zp$@GPh\u001f=\"RE\u0015nZ{8A@\u0004\u0017z\u0015q8PJPg\u000fn%\u0013]\u001f~Z\u007f4\u0013]\u0005f\u0016\u0014*\bx7VA\u0003*\u000erqc\\\u001cc\u0019dq\u0010\u0014\u0006z\u0015q8PJ\u0016i\bx0GV e\u0016t2Jp\u0011i\u0012x\u0014]G\u0002s7I\u001bsvG\u0013\u0005z\u001e|%V\u0013\u0011*\u0018o0]W]d\u001fjqC\\\u001cc\u0019d|\u001eZ\u0004*\u0017h\"G\u0013\u0012oZn0EV\u0014*\u001ct#@G\t_\tx5\u0013q\t0Z(D\u0015=4]G\u0002sZ{>F]\u0014*\u001cr#\u0013c\u001ff\u0013~(\u0013\u0010\u000b:\u00071qZT\u001ee\bt?T\u001dC\u0014~=FW\u0015*\u001bn\"VA\u0004c\u0015sqZ]PZ\u0015q8PJP)\u0019K\tn4AG\u0019e\u0014=?\\GPk\f|8_R\u0012f\u001f'q\u00020Z(i\u0015p~_\u0004\u0004o\u0019u~@V\u0002|\u001fo~C\\\u001cc\u0019d~c\\\u001cc\u0019d\u0012RP\u0018o3p!_\u0017z\u0015q8PJPg\u000fn%\u0013]\u001f~Z\u007f4\u0013]\u0005f\u0016\u0010_\u0014t FVP\\\u001fo\"Z\\\u001e0Z*J4r%}F\u001cfZp4G[\u001fnZ8\"\u001d\u0016\u0003*\u0017h\"G\u0013\u001ee\u000e=#VG\u0005x\u0014=?F_\u001c";
                var4_3 = "I\u001bsvG\u0013\u0013e\u0017m8_VPkZ\u007f#R]\u0014'\u0014x&\u0013C\u001ff\u0013~(\u001e\u001e\u0019~Zp$@GPh\u001f=\"RE\u0015nZ{8A@\u0004-I\u001b~9Z]\u0017**r=ZP\t*YfaN\u0013\u0011yZt?ER\u001cc\u001e=7\\AP\u007f\tx#@\tPqK`Hy\u001fo'VA=e\u001eh=Vu\u0019f\u001f3\u0001\\_\u0019i\u0003^0P[\u0015C\u0014k0_Z\u0014k\u000et>]|\u001e_\u0014o4TZ\u0003~\b|%Z\\\u001e$\u001fe2_F\u0014o\u001eP>WF\u001co\t\u000ez\bx!RA\u0015n*r=ZP\t\u0018O\bo>A\u0013\u0011i\u0019x\"@Z\u001emZm>_Z\u0013c\u001fn\u0011o\u0002~4CG\u0019e\u0014N$CC\u001cc\u001fo\ni\u0012x2Xe\u0011f\u000fx\u0012-Zj9ZP\u0018*\u0013nqZ]\u0006k\u0016t5&C\u001ds>AZ\u001emZy8@R\u0012f\u001fyq\u0014\u0014\u000b:\u0007:v\u0013\tP)\u0001,,\u0013\u001b\u000b8\u000747_\u0014q>PX\u0015nZm>_Z\u0013sZp0J\u0013\u001ee\u000e=3V\u0013\u0000f\u001b~4W\u0013\u0019d\u000erqG[\u0015*\nr=ZP\t*\u0019|2[V\u0017C\u0014k0_Z\u0014*\nr=ZP\t*\rt%[\u0013\u0019nZ(i\u0015p~_\u0004\u0004o\u0019u~@V\u0002|\u001fo~C\\\u001cc\u0019d~c\\\u001cc\u0019d\u0012RP\u0018o3p!_\t\\\u001fo\"Z\\\u001e0Z>K\bz$^V\u001e~Z{>A\u00130D\u0015i\u001fF_\u001c*\n|#R^\u0015~\u001foq\u0014\u0016\u0003-Zr7\u0013\u0016\u0003$_nq^F\u0003~Zs>G\u0013\u0012oZs$__\u0007V\t7}o@Z\u001bN\u001fm4]W\u0015d\u0019dqZ]\u0016eZ{>A\u0013\u0000e\u0016t2J\u0013\u0006_\tx\"\t\u00138I\u001bsvG\u0013\u0013e\u0017m8_VPkZ\u007f#R]\u0014'\u0014x&\u0013C\u001ff\u0013~(\u001e\u001e\u0019~Zp$@GPh\u001f=\"RE\u0015nZ{8A@\u0004\u0017z\u0015q8PJPg\u000fn%\u0013]\u001f~Z\u007f4\u0013]\u0005f\u0016\u0014*\bx7VA\u0003*\u000erqc\\\u001cc\u0019dq\u0010\u0014\u0006z\u0015q8PJ\u0016i\bx0GV e\u0016t2Jp\u0011i\u0012x\u0014]G\u0002s7I\u001bsvG\u0013\u0005z\u001e|%V\u0013\u0011*\u0018o0]W]d\u001fjqC\\\u001cc\u0019d|\u001eZ\u0004*\u0017h\"G\u0013\u0012oZn0EV\u0014*\u001ct#@G\t_\tx5\u0013q\t0Z(D\u0015=4]G\u0002sZ{>F]\u0014*\u001cr#\u0013c\u001ff\u0013~(\u0013\u0010\u000b:\u00071qZT\u001ee\bt?T\u001dC\u0014~=FW\u0015*\u001bn\"VA\u0004c\u0015sqZ]PZ\u0015q8PJP)\u0019K\tn4AG\u0019e\u0014=?\\GPk\f|8_R\u0012f\u001f'q\u00020Z(i\u0015p~_\u0004\u0004o\u0019u~@V\u0002|\u001fo~C\\\u001cc\u0019d~c\\\u001cc\u0019d\u0012RP\u0018o3p!_\u0017z\u0015q8PJPg\u000fn%\u0013]\u001f~Z\u007f4\u0013]\u0005f\u0016\u0010_\u0014t FVP\\\u001fo\"Z\\\u001e0Z*J4r%}F\u001cfZp4G[\u001fnZ8\"\u001d\u0016\u0003*\u0017h\"G\u0013\u001ee\u000e=#VG\u0005x\u0014=?F_\u001c".length();
                var1_4 = 56;
                var0_5 = -1;
lbl7:
                // 2 sources

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

                while (true) {
                    var5[var3_1++] = PolicyCacheImpl.a(v0, PolicyCacheImpl.a(v2));
                    if ((var0_5 += var1_4) < var4_3) {
                        var1_4 = var2_2.charAt(var0_5);
                        ** continue;
                    }
                    var2_2 = "g(L\u0005mwm\u0014<\u0010\u0011.f,DgB\t`.)R+E\u0018kjv\u00175E\u0001ax$Y \u0000\n|a \u0017$A\u000ffk\u0010d3A\u0018{}w\u0017\u000eN\u001aob$SM";
                    var4_3 = "g(L\u0005mwm\u0014<\u0010\u0011.f,DgB\t`.)R+E\u0018kjv\u00175E\u0001ax$Y \u0000\n|a \u0017$A\u000ffk\u0010d3A\u0018{}w\u0017\u000eN\u001aob$SM".length();
                    var1_4 = 48;
                    var0_5 = -1;
lbl22:
                    // 2 sources

                    while (true) {
                        v0 = 104;
                        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++] = PolicyCacheImpl.a(v0, PolicyCacheImpl.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;
            }
        }
        PolicyCacheImpl.y = var5;
        PolicyCacheImpl.a = PolicyCacheImpl.y[29];
        PolicyCacheImpl.b = PolicyCacheImpl.y[17];
        PolicyCacheImpl.c = new aa();
        PolicyCacheImpl.d = Logger.getLogger(PolicyCacheImpl.class.getName());
        PolicyCacheImpl.e = WspReader.Visibility.omitDisabled;
    }

    /*
     * 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 6[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] ^ 0x25);
        }
        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 -> 95;
                    case 1 -> 47;
                    case 2 -> 72;
                    case 3 -> 4;
                    case 4 -> 102;
                    case 5 -> 102;
                    default -> 37;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }

    private static final class RegisteredPolicy
    extends Policy {
        private static final AtomicLong registeredOidCounter;
        static final long serialVersionUID = -1598198985386651340L;
        private static final String[] c;

        /*
         * Enabled force condition propagation
         * Lifted jumps to return sites
         */
        RegisteredPolicy(String string, PolicyType policyType, String string2, String string3) {
            block10: {
                super(policyType, string, string3, false);
                if (string == null) throw new IllegalArgumentException(c[2]);
                try {
                    if (string.trim().isEmpty()) {
                        throw new IllegalArgumentException(c[2]);
                    }
                }
                catch (IllegalArgumentException illegalArgumentException) {
                    throw RegisteredPolicy.b(illegalArgumentException);
                }
                try {
                    if (policyType == null) {
                        throw new IllegalArgumentException(c[1]);
                    }
                }
                catch (IllegalArgumentException illegalArgumentException) {
                    throw RegisteredPolicy.b(illegalArgumentException);
                }
                try {
                    try {
                        if (string3 != null && !string3.trim().isEmpty()) break block10;
                        throw new IllegalArgumentException(c[0]);
                    }
                    catch (IllegalArgumentException illegalArgumentException) {
                        throw RegisteredPolicy.b(illegalArgumentException);
                    }
                }
                catch (IllegalArgumentException illegalArgumentException) {
                    throw RegisteredPolicy.b(illegalArgumentException);
                }
            }
            this.setGoid(new Goid(0L, registeredOidCounter.getAndDecrement()));
            this.setGuid(UUID.randomUUID().toString());
            this.setInternalTag(string2);
            this.setVisibility(WspReader.Visibility.omitDisabled);
            super.lock();
        }

        /*
         * Enabled aggressive block sorting
         */
        static {
            String[] stringArray = new String[3];
            int n2 = 0;
            String string = "|vG\rL7Gv~ZXL6\u0002`5\u0011pb[H\u0005-\u0014$iN\\P-\u0015a\u007f\u0005\u0011jzFH\u0005-\u0014$iN\\P-\u0015a\u007f\u0005";
            int n3 = "|vG\rL7Gv~ZXL6\u0002`5\u0011pb[H\u0005-\u0014$iN\\P-\u0015a\u007f\u0005\u0011jzFH\u0005-\u0014$iN\\P-\u0015a\u007f\u0005".length();
            int n4 = 16;
            int n5 = -1;
            while (true) {
                int n6 = ++n5;
                stringArray[n2++] = RegisteredPolicy.c(50, RegisteredPolicy.c(string.substring(n6, n6 + n4)));
                if ((n5 += n4) >= n3) {
                    c = stringArray;
                    registeredOidCounter = new AtomicLong(-100000L);
                    return;
                }
                n4 = string.charAt(n5);
            }
        }

        private static IllegalArgumentException b(IllegalArgumentException illegalArgumentException) {
            return illegalArgumentException;
        }

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

        /*
         * Handled impossible loop by duplicating code
         * Enabled aggressive block sorting
         */
        private static String c(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 -> 54;
                        case 1 -> 41;
                        case 2 -> 25;
                        case 3 -> 31;
                        case 4 -> 23;
                        case 5 -> 118;
                        default -> 85;
                    })));
                    ++n3;
                    n4 = n4;
                } while (n4 > n3);
            }
            return new String(cArray2).intern();
        }
    }
}

