/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.l7tech.gateway.common.siteminder.SiteMinderConfiguration
 *  com.l7tech.objectmodel.EntityHeader
 *  com.l7tech.objectmodel.EntityManager$UniqueType
 *  com.l7tech.objectmodel.FindException
 *  com.l7tech.objectmodel.Goid
 *  com.l7tech.objectmodel.PersistentEntity
 *  jakarta.inject.Inject
 *  org.springframework.beans.factory.InitializingBean
 *  org.springframework.transaction.annotation.Propagation
 *  org.springframework.transaction.annotation.Transactional
 */
package com.l7tech.server.siteminder;

import com.l7tech.gateway.common.siteminder.SiteMinderConfiguration;
import com.l7tech.objectmodel.EntityHeader;
import com.l7tech.objectmodel.EntityManager;
import com.l7tech.objectmodel.FindException;
import com.l7tech.objectmodel.Goid;
import com.l7tech.objectmodel.PersistentEntity;
import com.l7tech.server.HibernateEntityManager;
import com.l7tech.server.siteminder.SiteMinderConfigurationManager;
import com.l7tech.server.siteminder.a;
import com.l7tech.server.util.ApplicationEventProxy;
import jakarta.inject.Inject;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Transactional(propagation=Propagation.REQUIRED, rollbackFor={Throwable.class})
public class SiteMinderConfigurationManagerImpl
extends HibernateEntityManager<SiteMinderConfiguration, EntityHeader>
implements SiteMinderConfigurationManager,
InitializingBean {
    @Inject
    private ApplicationEventProxy applicationEventProxy;
    private static final Logger m;
    private final Map<Goid, SiteMinderConfiguration> n = new ConcurrentHashMap<Goid, SiteMinderConfiguration>();
    private static final String[] o;

    public Class<? extends PersistentEntity> getImpClass() {
        return SiteMinderConfiguration.class;
    }

    @Override
    protected EntityManager.UniqueType getUniqueType() {
        return EntityManager.UniqueType.NAME;
    }

    @Override
    public SiteMinderConfiguration getSiteMinderConfiguration(String string) throws FindException {
        return (SiteMinderConfiguration)this.findByUniqueName(string);
    }

    @Override
    public SiteMinderConfiguration getSiteMinderConfiguration(Goid goid) throws FindException {
        SiteMinderConfiguration siteMinderConfiguration = this.n.computeIfAbsent(goid, this::a);
        try {
            if (siteMinderConfiguration == null) {
                throw new FindException(o[1] + String.valueOf(goid));
            }
        }
        catch (FindException findException) {
            throw SiteMinderConfigurationManagerImpl.a((Exception)((Object)findException));
        }
        return siteMinderConfiguration;
    }

    private SiteMinderConfiguration a(Goid goid) {
        try {
            m.log(Level.FINE, o[0]);
            return (SiteMinderConfiguration)this.findByPrimaryKey(goid);
        }
        catch (FindException findException) {
            return null;
        }
    }

    protected void initDao() throws Exception {
        try {
            if (this.applicationEventProxy != null) {
                this.applicationEventProxy.addApplicationListener(new a(this));
            }
        }
        catch (Exception exception) {
            throw SiteMinderConfigurationManagerImpl.a(exception);
        }
    }

    /*
     * Enabled aggressive block sorting
     */
    static {
        String[] stringArray = new String[2];
        int n2 = 0;
        String string = "'gl\u0002:TP\u0006\"K\b&Xs\bl|\u0004 ~Q\u000fdq\u0006'OJ\bmvA4OQ\f\"\\#4\"mm\r6\u001dP\u000ev8\u0007;SZAQq\u00157\u001ds\bl|\u0004 \u001d}\u000el~\b5HL\u0000vq\u000e<\u001dI\bvpA\u0015RW\u000588";
        int n3 = "'gl\u0002:TP\u0006\"K\b&Xs\bl|\u0004 ~Q\u000fdq\u0006'OJ\bmvA4OQ\f\"\\#4\"mm\r6\u001dP\u000ev8\u0007;SZAQq\u00157\u001ds\bl|\u0004 \u001d}\u000el~\b5HL\u0000vq\u000e<\u001dI\bvpA\u0015RW\u000588".length();
        int n4 = 39;
        int n5 = -1;
        while (true) {
            int n6 = ++n5;
            stringArray[n2++] = SiteMinderConfigurationManagerImpl.b(77, SiteMinderConfigurationManagerImpl.a(string.substring(n6, n6 + n4)));
            if ((n5 += n4) >= n3) {
                o = stringArray;
                m = Logger.getLogger(SiteMinderConfigurationManagerImpl.class.getName());
                return;
            }
            n4 = string.charAt(n5);
        }
    }

    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] ^ 0x73);
        }
        return cArray;
    }

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

