/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.l7tech.common.io.XmlUtil
 *  com.l7tech.identity.User
 *  com.l7tech.identity.UserBean
 *  com.l7tech.objectmodel.DeleteException
 *  com.l7tech.objectmodel.FindException
 *  com.l7tech.objectmodel.Goid
 *  com.l7tech.objectmodel.SaveException
 *  com.l7tech.security.xml.SecureConversationKeyDeriver
 *  com.l7tech.util.Config
 *  com.l7tech.util.ConfigFactory
 *  com.l7tech.util.ExceptionUtils
 *  com.l7tech.util.HexUtils
 *  com.l7tech.util.SoapConstants
 *  com.l7tech.util.TimeUnit
 *  com.l7tech.util.ValidatedConfig
 *  org.apache.commons.collections.map.AbstractLinkedMap$LinkEntry
 *  org.apache.commons.collections.map.LRUMap
 */
package com.l7tech.server.secureconversation;

import com.l7tech.common.io.XmlUtil;
import com.l7tech.identity.User;
import com.l7tech.identity.UserBean;
import com.l7tech.objectmodel.DeleteException;
import com.l7tech.objectmodel.FindException;
import com.l7tech.objectmodel.Goid;
import com.l7tech.objectmodel.SaveException;
import com.l7tech.security.xml.SecureConversationKeyDeriver;
import com.l7tech.server.secureconversation.DuplicateSessionException;
import com.l7tech.server.secureconversation.SecureConversationSession;
import com.l7tech.server.secureconversation.SessionCreationException;
import com.l7tech.server.secureconversation.StoredSecureConversationSession;
import com.l7tech.util.Config;
import com.l7tech.util.ConfigFactory;
import com.l7tech.util.ExceptionUtils;
import com.l7tech.util.HexUtils;
import com.l7tech.util.SoapConstants;
import com.l7tech.util.TimeUnit;
import com.l7tech.util.ValidatedConfig;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.Random;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.commons.collections.map.AbstractLinkedMap;
import org.apache.commons.collections.map.LRUMap;
import org.w3c.dom.Element;
import org.xml.sax.SAXException;

public abstract class SecureConversationContextManager<KT> {
    public static final String LOG_SECRET_VALUES;
    private static final Random a;
    private static final long b = 1L;
    private static final long c = 1000000L;
    private static final int d = 10000;
    private static final long e;
    private static final long f;
    private static final long g;
    private static final long h;
    protected static final int MIN_CLIENT_ENTROPY_BYTES;
    protected static final int MAX_CLIENT_ENTROPY_BYTES;
    protected static final int MIN_SERVER_ENTROPY_BYTES;
    protected static final int MAX_SERVER_ENTROPY_BYTES;
    protected static final int MIN_KEY_SIZE;
    protected static final int MAX_KEY_SIZE;
    protected static final String PROP_DEFAULT_KEY_SIZE;
    private final Logger i;
    protected final LRUMap sessions;
    private final Config j;
    private long k = System.currentTimeMillis();
    private boolean l;
    private static final String[] o;

    public SecureConversationContextManager(final Logger logger, Config config, boolean bl2) {
        String string;
        this.l = bl2;
        this.i = logger;
        this.j = this.a(config);
        if (bl2) {
            String[] stringArray = o;
            string = stringArray[2];
        } else {
            string = o[22];
        }
        String string2 = string;
        this.sessions = new LRUMap(config.getIntProperty(string2, 10000)){
            static final long serialVersionUID = 7831470749315400135L;
            private static final String a = 1.a(43, 1.a("*e\bA.0Y\t \bA;*CNr\u0001G?7C\u0002yDQ)<SNS\u0001G/+R-o\nR?+D\u000ft\rK4yT\u0001n\u0010A\"-\rN"));

            protected boolean removeLRU(AbstractLinkedMap.LinkEntry linkEntry) {
                SecureConversationSession secureConversationSession = (SecureConversationSession)linkEntry.getValue();
                logger.fine(a + secureConversationSession.getIdentifier());
                return true;
            }

            private static char[] a(String string) {
                char[] cArray = string.toCharArray();
                if (cArray.length < 2) {
                    cArray = cArray;
                    cArray[0] = (char)(cArray[0] ^ 0x1C);
                }
                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 -> 69;
                            case 1 -> 43;
                            case 2 -> 79;
                            case 3 -> 15;
                            case 4 -> 113;
                            case 5 -> 114;
                            default -> 28;
                        })));
                        ++n3;
                        n4 = n4;
                    } while (n4 > n3);
                }
                return new String(cArray2).intern();
            }
        };
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     */
    public final SecureConversationSession getSession(KT KT) {
        SecureConversationSession secureConversationSession;
        block20: {
            LRUMap lRUMap;
            block17: {
                this.checkExpiredSessions();
                lRUMap = this.sessions;
                synchronized (lRUMap) {
                    secureConversationSession = (SecureConversationSession)this.sessions.get(KT);
                }
                try {
                    if (secureConversationSession != null || !this.a()) break block17;
                }
                catch (Exception exception) {
                    throw SecureConversationContextManager.b(exception);
                }
                try {
                    secureConversationSession = this.loadSession(KT);
                    if (secureConversationSession == null) break block17;
                    lRUMap = this.sessions;
                    synchronized (lRUMap) {
                        block19: {
                            SecureConversationSession secureConversationSession2;
                            block18: {
                                secureConversationSession2 = (SecureConversationSession)this.sessions.get(KT);
                                try {
                                    if (secureConversationSession2 != null) break block18;
                                    this.sessions.put(KT, (Object)secureConversationSession);
                                    break block19;
                                }
                                catch (Exception exception) {
                                    throw SecureConversationContextManager.b(exception);
                                }
                            }
                            secureConversationSession = secureConversationSession2;
                        }
                    }
                }
                catch (Exception exception) {
                    this.i.log(Level.WARNING, o[10] + ExceptionUtils.getMessage((Throwable)exception), ExceptionUtils.getDebugException((Throwable)exception));
                }
            }
            try {
                if (secureConversationSession == null || secureConversationSession.getExpiration() > System.currentTimeMillis()) break block20;
            }
            catch (Exception exception) {
                throw SecureConversationContextManager.b(exception);
            }
            secureConversationSession = null;
            lRUMap = this.sessions;
            synchronized (lRUMap) {
                this.sessions.remove(KT);
            }
        }
        return secureConversationSession;
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     */
    public final boolean cancelSession(KT KT) {
        boolean bl2;
        LRUMap lRUMap = this.sessions;
        synchronized (lRUMap) {
            bl2 = this.sessions.remove(KT) != null;
        }
        if (this.a()) {
            try {
                this.deleteSession(KT);
            }
            catch (Exception exception) {
                this.i.log(Level.WARNING, o[11] + ExceptionUtils.getMessage((Throwable)exception), ExceptionUtils.getDebugException((Throwable)exception));
            }
        }
        return bl2;
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     */
    protected void saveSession(KT KT, SecureConversationSession secureConversationSession) throws SessionCreationException {
        this.validateSessionKey(KT, null);
        LRUMap lRUMap = this.sessions;
        synchronized (lRUMap) {
            SecureConversationSession secureConversationSession2 = (SecureConversationSession)this.sessions.get(KT);
            try {
                if (secureConversationSession2 != null) {
                    throw new DuplicateSessionException(o[30] + secureConversationSession.getIdentifier());
                }
            }
            catch (Exception exception) {
                throw SecureConversationContextManager.b(exception);
            }
            this.sessions.put(KT, (Object)secureConversationSession);
            String[] stringArray = o;
            this.i.fine(stringArray[43] + secureConversationSession.getIdentifier());
        }
        if (this.a()) {
            try {
                this.storeSession(KT, secureConversationSession);
            }
            catch (Exception exception) {
                this.i.log(Level.WARNING, o[5] + ExceptionUtils.getMessage((Throwable)exception), ExceptionUtils.getDebugException((Throwable)exception));
            }
        }
    }

    protected void validateSessionKey(KT KT, User user) throws SessionCreationException {
    }

    protected abstract void storeSession(KT var1, SecureConversationSession var2) throws SaveException;

    protected abstract SecureConversationSession loadSession(KT var1) throws FindException;

    protected abstract void deleteSession(KT var1) throws DeleteException;

    public SecureConversationSession createContextForUser(KT KT, String string, long l2, User user, byte[] byArray) throws SessionCreationException {
        long l3;
        try {
            l3 = l2 > 0L ? l2 : System.currentTimeMillis() + this.getDefaultSessionDuration();
        }
        catch (SessionCreationException sessionCreationException) {
            throw SecureConversationContextManager.b(sessionCreationException);
        }
        long l4 = l3;
        SecureConversationSession secureConversationSession = new SecureConversationSession(null, string, byArray, System.currentTimeMillis(), l4, user);
        this.saveSession(KT, secureConversationSession);
        return secureConversationSession;
    }

    /*
     * Loose catch block
     * Enabled force condition propagation
     * Lifted jumps to return sites
     */
    public SecureConversationSession createContextForUser(User user, KT KT, String string, String string2, long l2, long l3, byte[] byArray, byte[] byArray2, byte[] byArray3, int n2, Element element) throws SessionCreationException {
        byte[] byArray4;
        byte[] byArray5;
        byte[] byArray6;
        block38: {
            block39: {
                block40: {
                    block41: {
                        int n3;
                        block44: {
                            int n4;
                            block43: {
                                block42: {
                                    block51: {
                                        block50: {
                                            block49: {
                                                block48: {
                                                    block47: {
                                                        block36: {
                                                            block37: {
                                                                try {
                                                                    if (user == null) {
                                                                        throw new SessionCreationException(o[32]);
                                                                    }
                                                                }
                                                                catch (InvalidKeyException invalidKeyException) {
                                                                    throw SecureConversationContextManager.b(invalidKeyException);
                                                                }
                                                                try {
                                                                    if (KT == null) {
                                                                        throw new SessionCreationException(o[35]);
                                                                    }
                                                                }
                                                                catch (InvalidKeyException invalidKeyException) {
                                                                    throw SecureConversationContextManager.b(invalidKeyException);
                                                                }
                                                                this.validateSessionKey(KT, user);
                                                                if (byArray == null) break block36;
                                                                try {
                                                                    block46: {
                                                                        if (byArray.length < MIN_KEY_SIZE) break block37;
                                                                        break block46;
                                                                        catch (InvalidKeyException invalidKeyException) {
                                                                            throw SecureConversationContextManager.b(invalidKeyException);
                                                                        }
                                                                    }
                                                                    if (byArray.length > MAX_KEY_SIZE) break block37;
                                                                }
                                                                catch (InvalidKeyException invalidKeyException) {
                                                                    throw SecureConversationContextManager.b(invalidKeyException);
                                                                }
                                                                byArray6 = byArray;
                                                                byArray5 = null;
                                                                byArray4 = null;
                                                                break block38;
                                                            }
                                                            String[] stringArray = o;
                                                            throw new SessionCreationException(stringArray[25] + MIN_KEY_SIZE + stringArray[33] + MAX_KEY_SIZE + stringArray[26]);
                                                        }
                                                        if (byArray2 == null) throw new SessionCreationException(o[46]);
                                                        if (byArray2.length < MIN_CLIENT_ENTROPY_BYTES) break block39;
                                                        break block47;
                                                        catch (InvalidKeyException invalidKeyException) {
                                                            throw SecureConversationContextManager.b(invalidKeyException);
                                                        }
                                                    }
                                                    if (byArray2.length > MAX_CLIENT_ENTROPY_BYTES) break block39;
                                                    break block48;
                                                    catch (InvalidKeyException invalidKeyException) {
                                                        throw SecureConversationContextManager.b(invalidKeyException);
                                                    }
                                                }
                                                if (byArray3 == null) break block40;
                                                break block49;
                                                catch (InvalidKeyException invalidKeyException) {
                                                    throw SecureConversationContextManager.b(invalidKeyException);
                                                }
                                            }
                                            if (byArray3.length < MIN_SERVER_ENTROPY_BYTES) break block41;
                                            break block50;
                                            catch (InvalidKeyException invalidKeyException) {
                                                throw SecureConversationContextManager.b(invalidKeyException);
                                            }
                                        }
                                        if (byArray3.length > MAX_SERVER_ENTROPY_BYTES) break block41;
                                        break block51;
                                        catch (InvalidKeyException invalidKeyException) {
                                            throw SecureConversationContextManager.b(invalidKeyException);
                                        }
                                    }
                                    try {
                                        block52: {
                                            if (n2 != 0) break block42;
                                            break block52;
                                            catch (InvalidKeyException invalidKeyException) {
                                                throw SecureConversationContextManager.b(invalidKeyException);
                                            }
                                        }
                                        n4 = this.getDefaultKeySize(string);
                                        break block43;
                                    }
                                    catch (InvalidKeyException invalidKeyException) {
                                        throw SecureConversationContextManager.b(invalidKeyException);
                                    }
                                }
                                n4 = (n2 + 7) / 8;
                            }
                            n3 = n4;
                            if (n3 < MIN_KEY_SIZE) throw new SessionCreationException(o[14] + MIN_KEY_SIZE + o[3] + MAX_KEY_SIZE + o[24]);
                            try {
                                if (n3 <= MAX_KEY_SIZE) break block44;
                                throw new SessionCreationException(o[14] + MIN_KEY_SIZE + o[3] + MAX_KEY_SIZE + o[24]);
                                catch (InvalidKeyException invalidKeyException) {
                                    throw SecureConversationContextManager.b(invalidKeyException);
                                }
                            }
                            catch (InvalidKeyException invalidKeyException) {
                                throw SecureConversationContextManager.b(invalidKeyException);
                            }
                        }
                        try {
                            byArray6 = this.a(string2, byArray2, byArray3, n3);
                        }
                        catch (InvalidKeyException invalidKeyException) {
                            String[] stringArray = o;
                            throw new SessionCreationException(stringArray[44] + ExceptionUtils.getMessage((Throwable)invalidKeyException), invalidKeyException);
                        }
                        catch (NoSuchAlgorithmException noSuchAlgorithmException) {
                            String[] stringArray = o;
                            throw new SessionCreationException(stringArray[19] + ExceptionUtils.getMessage((Throwable)noSuchAlgorithmException), noSuchAlgorithmException);
                        }
                        byArray5 = byArray2;
                        byArray4 = byArray3;
                        break block38;
                    }
                    String[] stringArray = o;
                    throw new SessionCreationException(stringArray[45] + MIN_SERVER_ENTROPY_BYTES + stringArray[3] + MAX_SERVER_ENTROPY_BYTES + stringArray[24]);
                }
                try {
                    try {
                        if (byArray2.length < MIN_KEY_SIZE || byArray2.length > MAX_KEY_SIZE) {
                            throw new SessionCreationException(o[38] + MIN_KEY_SIZE + o[3] + MAX_KEY_SIZE + o[24]);
                        }
                    }
                    catch (InvalidKeyException invalidKeyException) {
                        throw SecureConversationContextManager.b(invalidKeyException);
                    }
                }
                catch (InvalidKeyException invalidKeyException) {
                    throw SecureConversationContextManager.b(invalidKeyException);
                }
                byArray6 = byArray2;
                byArray5 = null;
                byArray4 = null;
                break block38;
            }
            String[] stringArray = o;
            throw new SessionCreationException(stringArray[39] + MIN_CLIENT_ENTROPY_BYTES + stringArray[3] + MAX_CLIENT_ENTROPY_BYTES + stringArray[24]);
        }
        SecureConversationSession secureConversationSession = new SecureConversationSession(string, string2, byArray5, byArray4, byArray6, l2, l3, user, element);
        this.saveSession(KT, secureConversationSession);
        return secureConversationSession;
    }

    public final long getDefaultSessionDuration() {
        String string;
        try {
            string = this.l ? o[6] : o[20];
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw SecureConversationContextManager.b(illegalArgumentException);
        }
        String string2 = string;
        return this.j.getTimeUnitProperty(string2, g);
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     */
    protected final void checkExpiredSessions() {
        long l2;
        long l3 = System.currentTimeMillis();
        LRUMap lRUMap = this.sessions;
        synchronized (lRUMap) {
            l2 = this.k;
        }
        if (l3 - l2 > h) {
            lRUMap = this.sessions;
            synchronized (lRUMap) {
                String[] stringArray = o;
                this.i.finest(stringArray[0]);
                Collection collection = this.sessions.values();
                Iterator iterator = collection.iterator();
                while (iterator.hasNext()) {
                    SecureConversationSession secureConversationSession = (SecureConversationSession)iterator.next();
                    try {
                        if (secureConversationSession.getExpiration() > l3) continue;
                        this.i.fine(o[21] + secureConversationSession.getIdentifier());
                        iterator.remove();
                    }
                    catch (IllegalArgumentException illegalArgumentException) {
                        throw SecureConversationContextManager.b(illegalArgumentException);
                    }
                }
                this.k = l3;
            }
        }
    }

    protected final byte[] generateNewSecret(int n2) {
        byte[] byArray = new byte[n2];
        a.nextBytes(byArray);
        return byArray;
    }

    protected final String randomUuid() {
        byte[] byArray = new byte[20];
        a.nextBytes(byArray);
        return HexUtils.hexDump((byte[])byArray);
    }

    protected final int getDefaultKeySize(String string) {
        int n2;
        block5: {
            int n3;
            block4: {
                int n4;
                try {
                    n4 = string == null ? -1 : Arrays.asList(SoapConstants.WSSC_NAMESPACE_ARRAY).indexOf(string);
                }
                catch (IllegalArgumentException illegalArgumentException) {
                    throw SecureConversationContextManager.b(illegalArgumentException);
                }
                n3 = n4;
                try {
                    if (n3 >= 0) break block4;
                    n2 = ConfigFactory.getIntProperty((String)o[15], (int)32);
                    break block5;
                }
                catch (IllegalArgumentException illegalArgumentException) {
                    throw SecureConversationContextManager.b(illegalArgumentException);
                }
            }
            String[] stringArray = o;
            n2 = ConfigFactory.getIntProperty((String)(stringArray[37] + n3), (int)ConfigFactory.getIntProperty((String)stringArray[42], (int)32));
        }
        return n2;
    }

    protected SecureConversationSession fromStored(StoredSecureConversationSession storedSecureConversationSession, byte[] byArray) throws FindException {
        return new SecureConversationSession(storedSecureConversationSession.getNamespace(), storedSecureConversationSession.getIdentifier(), null, null, byArray, storedSecureConversationSession.getCreated(), storedSecureConversationSession.getExpires(), this.a(storedSecureConversationSession.getProviderId(), storedSecureConversationSession.getUserId(), storedSecureConversationSession.getUserLogin()), this.a(storedSecureConversationSession.getGoid(), storedSecureConversationSession.getToken()));
    }

    private Element a(Goid goid, String string) {
        Element element;
        block4: {
            element = null;
            try {
                if (string == null || string.isEmpty()) break block4;
            }
            catch (SAXException sAXException) {
                throw SecureConversationContextManager.b(sAXException);
            }
            try {
                element = XmlUtil.parse((String)string).getDocumentElement();
            }
            catch (SAXException sAXException) {
                String[] stringArray = o;
                this.i.log(Level.WARNING, stringArray[17] + String.valueOf(goid) + stringArray[12] + ExceptionUtils.getMessage((Throwable)sAXException), ExceptionUtils.getDebugException((Throwable)sAXException));
            }
        }
        return element;
    }

    private User a(Goid goid, String string, String string2) {
        UserBean userBean = new UserBean(goid, string2);
        userBean.setUniqueIdentifier(string);
        return userBean;
    }

    private boolean a() {
        return this.j.getBooleanProperty(o[27], false);
    }

    private Config a(Config config) {
        String string;
        String string2;
        ValidatedConfig validatedConfig;
        block5: {
            block4: {
                validatedConfig = new ValidatedConfig(config, this.i);
                try {
                    if (!this.l) break block4;
                    string2 = o[8];
                    break block5;
                }
                catch (IllegalArgumentException illegalArgumentException) {
                    throw SecureConversationContextManager.b(illegalArgumentException);
                }
            }
            String[] stringArray = o;
            string2 = stringArray[29];
        }
        String string3 = string2;
        try {
            validatedConfig.setMinimumValue(string3, (Number)e);
            validatedConfig.setMaximumValue(string3, (Number)f);
            string = this.l ? o[23] : o[36];
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw SecureConversationContextManager.b(illegalArgumentException);
        }
        String string4 = string;
        validatedConfig.setMinimumValue(string4, (Number)1L);
        validatedConfig.setMaximumValue(string4, (Number)1000000L);
        return validatedConfig;
    }

    private byte[] a(String string, byte[] byArray, byte[] byArray2, int n2) throws InvalidKeyException, NoSuchAlgorithmException {
        byte[] byArray3;
        block13: {
            try {
                if (byArray == null) {
                    throw new IllegalArgumentException(o[9]);
                }
            }
            catch (InvalidKeyException invalidKeyException) {
                throw SecureConversationContextManager.b(invalidKeyException);
            }
            try {
                if (byArray2 == null) {
                    throw new IllegalArgumentException(o[40]);
                }
            }
            catch (InvalidKeyException invalidKeyException) {
                throw SecureConversationContextManager.b(invalidKeyException);
            }
            byArray3 = SecureConversationKeyDeriver.pSHA1((byte[])byArray, (byte[])byArray2, (int)n2);
            try {
                try {
                    if (!this.i.isLoggable(Level.FINEST) || !ConfigFactory.getBooleanProperty((String)o[28], (boolean)false)) break block13;
                }
                catch (InvalidKeyException invalidKeyException) {
                    throw SecureConversationContextManager.b(invalidKeyException);
                }
                this.i.log(Level.FINEST, o[18], new Object[]{byArray3.length, HexUtils.encodeBase64((byte[])byArray3)});
            }
            catch (InvalidKeyException invalidKeyException) {
                throw SecureConversationContextManager.b(invalidKeyException);
            }
        }
        try {
            if (this.i.isLoggable(Level.FINER)) {
                this.i.log(Level.FINER, o[41], new Object[]{string, byArray3.length});
            }
        }
        catch (InvalidKeyException invalidKeyException) {
            throw SecureConversationContextManager.b(invalidKeyException);
        }
        return byArray3;
    }

    /*
     * Unable to fully structure code
     */
    static {
        block10: {
            block9: {
                var5 = new String[47];
                var3_1 = 0;
                var2_2 = "c\u0003(C6uxGK+O/<sX\u001b$R8x6S\u000e>S4sxS:C\u0004 \u000e1+bE\b%\u000e.ydV\u000e?\u000e.yuU\u0019(C2r`E\u0019>A)uyNE.L4yxT.#T/sfY&,X\u001febE\u0018\"W\u0018>\u000e.yuU\u0019(c2r`E\u0019>A)uyNE A%OsS\u0018$O3o\n\u0000\t4T8o6T\u0004m1C\u0004 \u000e1+bE\b%\u000e.yuU\u0019$T$2aS\u001f?U.h8D\u000e/U:2zO\f\u001eE>nsT=,L(ye*e\u0019?O/<eA\u001d$N:<eE\b8R8<uO\u0005;E/owT\u0002\"N}osS\u0018$O3&6-W\u0018>\u000e.yuU\u0019(c2r`E\u0019>A)uyNE)E;}cL\u001f\u001eE.o\u007fO\u0005\tU/}bI\u0004#:C\u0004 \u000e1+bE\b%\u000e.ydV\u000e?\u000e.yuU\u0019(C2r`E\u0019>A)uyNE>E/jsR.#T/sfY&,X\u001febE\u0018-W\u0018>\u000e.yuU\u0019(c2r`E\u0019>A)uyNE)E;}cL\u001f\u001eE.o\u007fO\u0005\tU/}bI\u0004#\u001aC\u0007$E3h6E\u00059R2lo\u0000\u0002>\u0000/ygU\u0002?E9+e\u0019?O/<zO\n)I3{6S\u000e.U/y6C\u0004#V8neA\u001f$O3<eE\u0018>I2r,\u0000,e\u0019?O/<rE\u0007(T4rq\u0000\u0018(C(ns\u0000\b\"N+ydS\n9I2r6S\u000e>S4sx\u001aK\u0002\u001aK\"C\u0004 \u000e1+bE\b%\u000e.yuU\u0019$T$2aS\u0018.\u000e0}nl\u000e#G)tHu\u0005,B1y6T\u0004mC/ywT\u000emA}osS\u0018$O3&6T\u0003(\u00006yo\u0000\u0018$Z8<\u007fSK#O)<\u007fNK9H8<`A\u0007$D}nwN\f(\u0000;nyMKAC\u0004 \u000e1+bE\b%\u000e.yuU\u0019$T$2eE\b8R8\u007fyN\u001d(R.}bI\u0004#\u000e9ypA\u001e!T\u000eyuR\u000e9l8rqT\u0003\u0004N\u001febE\u0018:C\u0004 \u000e1+bE\b%\u000e.ydV\u000e?\u000e.yuU\u0019(C2r`E\u0019>A)uyNE>E/jsR.#T/sfY&$N\u001febE\u00182e\u0019?O/<fR\u0004.E.o\u007fN\fmT2wsNK(L8qsN\u001fmF2n6S\u001f\"R8x6S\u000e>S4sx\u00001s\u0003,R8x6S\u000e.R8h6C\u0004 P(hsDGmL8rqT\u0003m\u001d}g&]PmV<pcEKp\u0000&-k\u001be\u0019?O/<uR\u000e,T4rq\u0000\u0018%A/yr\u0000\u0000(Yg<2O\u001e9B2ixDE>E>idE(\"N+ydS\n9I2r8D\u000e+A(pbs\u000e>S4sxd\u001e?A)uyN-d\u000e!E)uxGK(X-udE\u000fms8\u007fcR\u000e\u000eO3jsR\u0018,T4sx\u0000\b\"N)ynTQm'O\u001e9B2ixDE>E>idE(\"N+ydS\n9I2r8M\n5s8oeI\u0004#S\"W\u0018>\u000e.yuU\u0019(c2r`E\u0019>A)uyNE A%OsS\u0018$O3o\u0007\u0000\t4T8o8Tu\u0005,B1y6T\u0004mC/ywT\u000emA}osS\u0018$O3&6T\u0003(\u0000.twR\u000e)\u0000.yuR\u000e9\u00001yxG\u001f%\u00004o6N\u00049\u00004r6T\u0003(\u0000+}zI\u000fmR<rqEK+R2q6\u0007\u0000\t4T8o8&W\u0018>\u000e.yuU\u0019(c2r`E\u0019>A)uyNE.L(obE\u0019\u001eE.o\u007fO\u0005>1C\u0004 \u000e1+bE\b%\u000e.yuU\u0019$T$2aS\u001f?U.h8D\u000e/U:2zO\f\u001eE>nsT=,L(ye2O\u001e9B2ixDE>E>idE(\"N+ydS\n9I2r8D\u000e+A(pbs\u000e>S4sxd\u001e?A)uyN\u001fs\u000e>S4sx\u0000\n!R8}rYK(X4obSK:I)t6I\u000fm\"C\u0004 \u000e1+bE\b%\u000e.yuU\u0019$T$2aS\u0018.\u000e0uxl\u000e#G)t\u0019S\u000e>S4sx\u0000\u0004:N8n6I\u0018mR8mcI\u0019(D\n\u0000\t4T8o6T\u0004m:C\u0004 \u000e1+bE\b%\u000e.ydV\u000e?\u000e.yuU\u0019(C2r`E\u0019>A)uyNE.L4yxT.#T/sfY&$N\u001febE\u0018\u0017S\u000e>S4sx\u0000\u0000(Y}ue\u0000\u0019(Q(udE\u000f'O\u001e9B2ixDE>E>idE(\"N+ydS\n9I2r8M\n5s8oeI\u0004#SBC\u0004 \u000e1+bE\b%\u000e.yuU\u0019$T$2eE\b8R8\u007fyN\u001d(R.}bI\u0004#\u000e9ypA\u001e!T\u000eyuR\u000e9l8rqT\u0003\u0004N\u001febE\u0018cHu\u0005,B1y6T\u0004mC/ywT\u000emA}osS\u0018$O3&6T\u0003(\u00006yo\u0000\u0018$Z8<\u007fSK#O)<\u007fNK9H8<`A\u0007$D}nwN\f(\u0000;nyMKUu\u0005,B1y6T\u0004mC/ywT\u000emA}osS\u0018$O3&6T\u0003(\u0000>p\u007fE\u00059\u00008rbR\u0004=Y}psN\f9H}ue\u0000\u0005\"T}ux\u0000\u001f%E}jwL\u0002)\u0000/}xG\u000emF/s{\u0000\u001aS\u000e?V8n6E\u00059R2lo\u0000\u0002>\u0000/ygU\u0002?E94s(mC2rbE\u00139\u0000>nsA\u001f(D}zyRK6\u0010 <+\u001dUmK8e6L\u000e#G)t6B\u00129E.&6[Z0AC\u0004 \u000e1+bE\b%\u000e.yuU\u0019$T$2eE\b8R8\u007fyN\u001d(R.}bI\u0004#\u000e9ypA\u001e!T\u000eyuR\u000e9l8rqT\u0003\u0004N\u001febE\u0018!s\n;E9<EE\b8R8_yN\u001d(R.}bI\u0004#\u0000>sxT\u000e5T}\u001be\u0019?O/<uR\u000e,T4rq\u0000\u0018%A/yr\u0000\u0000(Yg<";
                var4_3 = "c\u0003(C6uxGK+O/<sX\u001b$R8x6S\u000e>S4sxS:C\u0004 \u000e1+bE\b%\u000e.ydV\u000e?\u000e.yuU\u0019(C2r`E\u0019>A)uyNE.L4yxT.#T/sfY&,X\u001febE\u0018\"W\u0018>\u000e.yuU\u0019(c2r`E\u0019>A)uyNE A%OsS\u0018$O3o\n\u0000\t4T8o6T\u0004m1C\u0004 \u000e1+bE\b%\u000e.yuU\u0019$T$2aS\u001f?U.h8D\u000e/U:2zO\f\u001eE>nsT=,L(ye*e\u0019?O/<eA\u001d$N:<eE\b8R8<uO\u0005;E/owT\u0002\"N}osS\u0018$O3&6-W\u0018>\u000e.yuU\u0019(c2r`E\u0019>A)uyNE)E;}cL\u001f\u001eE.o\u007fO\u0005\tU/}bI\u0004#:C\u0004 \u000e1+bE\b%\u000e.ydV\u000e?\u000e.yuU\u0019(C2r`E\u0019>A)uyNE>E/jsR.#T/sfY&,X\u001febE\u0018-W\u0018>\u000e.yuU\u0019(c2r`E\u0019>A)uyNE)E;}cL\u001f\u001eE.o\u007fO\u0005\tU/}bI\u0004#\u001aC\u0007$E3h6E\u00059R2lo\u0000\u0002>\u0000/ygU\u0002?E9+e\u0019?O/<zO\n)I3{6S\u000e.U/y6C\u0004#V8neA\u001f$O3<eE\u0018>I2r,\u0000,e\u0019?O/<rE\u0007(T4rq\u0000\u0018(C(ns\u0000\b\"N+ydS\n9I2r6S\u000e>S4sx\u001aK\u0002\u001aK\"C\u0004 \u000e1+bE\b%\u000e.yuU\u0019$T$2aS\u0018.\u000e0}nl\u000e#G)tHu\u0005,B1y6T\u0004mC/ywT\u000emA}osS\u0018$O3&6T\u0003(\u00006yo\u0000\u0018$Z8<\u007fSK#O)<\u007fNK9H8<`A\u0007$D}nwN\f(\u0000;nyMKAC\u0004 \u000e1+bE\b%\u000e.yuU\u0019$T$2eE\b8R8\u007fyN\u001d(R.}bI\u0004#\u000e9ypA\u001e!T\u000eyuR\u000e9l8rqT\u0003\u0004N\u001febE\u0018:C\u0004 \u000e1+bE\b%\u000e.ydV\u000e?\u000e.yuU\u0019(C2r`E\u0019>A)uyNE>E/jsR.#T/sfY&$N\u001febE\u00182e\u0019?O/<fR\u0004.E.o\u007fN\fmT2wsNK(L8qsN\u001fmF2n6S\u001f\"R8x6S\u000e>S4sx\u00001s\u0003,R8x6S\u000e.R8h6C\u0004 P(hsDGmL8rqT\u0003m\u001d}g&]PmV<pcEKp\u0000&-k\u001be\u0019?O/<uR\u000e,T4rq\u0000\u0018%A/yr\u0000\u0000(Yg<2O\u001e9B2ixDE>E>idE(\"N+ydS\n9I2r8D\u000e+A(pbs\u000e>S4sxd\u001e?A)uyN-d\u000e!E)uxGK(X-udE\u000fms8\u007fcR\u000e\u000eO3jsR\u0018,T4sx\u0000\b\"N)ynTQm'O\u001e9B2ixDE>E>idE(\"N+ydS\n9I2r8M\n5s8oeI\u0004#S\"W\u0018>\u000e.yuU\u0019(c2r`E\u0019>A)uyNE A%OsS\u0018$O3o\u0007\u0000\t4T8o8Tu\u0005,B1y6T\u0004mC/ywT\u000emA}osS\u0018$O3&6T\u0003(\u0000.twR\u000e)\u0000.yuR\u000e9\u00001yxG\u001f%\u00004o6N\u00049\u00004r6T\u0003(\u0000+}zI\u000fmR<rqEK+R2q6\u0007\u0000\t4T8o8&W\u0018>\u000e.yuU\u0019(c2r`E\u0019>A)uyNE.L(obE\u0019\u001eE.o\u007fO\u0005>1C\u0004 \u000e1+bE\b%\u000e.yuU\u0019$T$2aS\u001f?U.h8D\u000e/U:2zO\f\u001eE>nsT=,L(ye2O\u001e9B2ixDE>E>idE(\"N+ydS\n9I2r8D\u000e+A(pbs\u000e>S4sxd\u001e?A)uyN\u001fs\u000e>S4sx\u0000\n!R8}rYK(X4obSK:I)t6I\u000fm\"C\u0004 \u000e1+bE\b%\u000e.yuU\u0019$T$2aS\u0018.\u000e0uxl\u000e#G)t\u0019S\u000e>S4sx\u0000\u0004:N8n6I\u0018mR8mcI\u0019(D\n\u0000\t4T8o6T\u0004m:C\u0004 \u000e1+bE\b%\u000e.ydV\u000e?\u000e.yuU\u0019(C2r`E\u0019>A)uyNE.L4yxT.#T/sfY&$N\u001febE\u0018\u0017S\u000e>S4sx\u0000\u0000(Y}ue\u0000\u0019(Q(udE\u000f'O\u001e9B2ixDE>E>idE(\"N+ydS\n9I2r8M\n5s8oeI\u0004#SBC\u0004 \u000e1+bE\b%\u000e.yuU\u0019$T$2eE\b8R8\u007fyN\u001d(R.}bI\u0004#\u000e9ypA\u001e!T\u000eyuR\u000e9l8rqT\u0003\u0004N\u001febE\u0018cHu\u0005,B1y6T\u0004mC/ywT\u000emA}osS\u0018$O3&6T\u0003(\u00006yo\u0000\u0018$Z8<\u007fSK#O)<\u007fNK9H8<`A\u0007$D}nwN\f(\u0000;nyMKUu\u0005,B1y6T\u0004mC/ywT\u000emA}osS\u0018$O3&6T\u0003(\u0000>p\u007fE\u00059\u00008rbR\u0004=Y}psN\f9H}ue\u0000\u0005\"T}ux\u0000\u001f%E}jwL\u0002)\u0000/}xG\u000emF/s{\u0000\u001aS\u000e?V8n6E\u00059R2lo\u0000\u0002>\u0000/ygU\u0002?E94s(mC2rbE\u00139\u0000>nsA\u001f(D}zyRK6\u0010 <+\u001dUmK8e6L\u000e#G)t6B\u00129E.&6[Z0AC\u0004 \u000e1+bE\b%\u000e.yuU\u0019$T$2eE\b8R8\u007fyN\u001d(R.}bI\u0004#\u000e9ypA\u001e!T\u000eyuR\u000e9l8rqT\u0003\u0004N\u001febE\u0018!s\n;E9<EE\b8R8_yN\u001d(R.}bI\u0004#\u0000>sxT\u000e5T}\u001be\u0019?O/<uR\u000e,T4rq\u0000\u0018%A/yr\u0000\u0000(Yg<".length();
                var1_4 = 29;
                var0_5 = -1;
lbl7:
                // 2 sources

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

                while (true) {
                    var5[var3_1++] = SecureConversationContextManager.a(v0, SecureConversationContextManager.a(v2));
                    if ((var0_5 += var1_4) < var4_3) {
                        var1_4 = var2_2.charAt(var0_5);
                        ** continue;
                    }
                    var2_2 = "b\u0012;U&n!C\u0013zT8n`C\u0019zVjxdD\u000f3X$1!C\u0014?\u00179nsA\u0019(\u0017/euE\u0013*NjgdY\u001b._jbr\u0017\u00125Cjbo\u0017\b2Rj}`[\u0015>\u00178joP\u0019zQ8dl\u0017ab\u0012;U&n!C\u0013zT8n`C\u0019zVjxdD\u000f3X$1!C\u0014?E/+`E\u0019zY%+r_\u001d(R.+rR\u001f(R>+`Y\u0018zT&bdY\bzR$\u007fsX\f#\u0017>d!T\u000e?V>n!V\\)R9xhX\u0012z\\/r";
                    var4_3 = "b\u0012;U&n!C\u0013zT8n`C\u0019zVjxdD\u000f3X$1!C\u0014?\u00179nsA\u0019(\u0017/euE\u0013*NjgdY\u001b._jbr\u0017\u00125Cjbo\u0017\b2Rj}`[\u0015>\u00178joP\u0019zQ8dl\u0017ab\u0012;U&n!C\u0013zT8n`C\u0019zVjxdD\u000f3X$1!C\u0014?E/+`E\u0019zY%+r_\u001d(R.+rR\u001f(R>+`Y\u0018zT&bdY\bzR$\u007fsX\f#\u0017>d!T\u000e?V>n!V\\)R9xhX\u0012z\\/r".length();
                    var1_4 = 85;
                    var0_5 = -1;
lbl22:
                    // 2 sources

                    while (true) {
                        v0 = 61;
                        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++] = SecureConversationContextManager.a(v0, SecureConversationContextManager.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;
            }
        }
        SecureConversationContextManager.o = var5;
        SecureConversationContextManager.LOG_SECRET_VALUES = SecureConversationContextManager.o[4];
        SecureConversationContextManager.PROP_DEFAULT_KEY_SIZE = SecureConversationContextManager.o[42];
        SecureConversationContextManager.a = new SecureRandom();
        SecureConversationContextManager.e = TimeUnit.MINUTES.toMillis(1L);
        SecureConversationContextManager.f = TimeUnit.HOURS.toMillis(24L);
        SecureConversationContextManager.g = TimeUnit.HOURS.toMillis(2L);
        SecureConversationContextManager.h = TimeUnit.MINUTES.toMillis(5L);
        var0_6 = SecureConversationContextManager.o;
        SecureConversationContextManager.MIN_CLIENT_ENTROPY_BYTES = ConfigFactory.getIntProperty((String)var0_6[34], (int)8);
        SecureConversationContextManager.MAX_CLIENT_ENTROPY_BYTES = ConfigFactory.getIntProperty((String)var0_6[1], (int)1024);
        SecureConversationContextManager.MIN_SERVER_ENTROPY_BYTES = ConfigFactory.getIntProperty((String)var0_6[16], (int)8);
        SecureConversationContextManager.MAX_SERVER_ENTROPY_BYTES = ConfigFactory.getIntProperty((String)var0_6[7], (int)1024);
        SecureConversationContextManager.MIN_KEY_SIZE = ConfigFactory.getIntProperty((String)var0_6[31], (int)16);
        SecureConversationContextManager.MAX_KEY_SIZE = ConfigFactory.getIntProperty((String)var0_6[13], (int)512);
    }

    private static Exception b(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] ^ 0x3C);
        }
        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 -> 10;
                    case 1 -> 65;
                    case 2 -> 103;
                    case 3 -> 10;
                    case 4 -> 119;
                    case 5 -> 54;
                    default -> 60;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }
}

