/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.l7tech.objectmodel.Goid
 *  com.l7tech.objectmodel.UpdateException
 *  com.l7tech.util.MasterPasswordManager
 *  org.hibernate.HibernateException
 *  org.hibernate.LockMode
 *  org.hibernate.Session
 *  org.springframework.orm.hibernate5.HibernateCallback
 */
package com.l7tech.server.security.keystore;

import com.l7tech.objectmodel.Goid;
import com.l7tech.objectmodel.UpdateException;
import com.l7tech.server.security.keystore.KeystoreFile;
import com.l7tech.server.security.keystore.KeystoreFileManagerImpl;
import com.l7tech.util.MasterPasswordManager;
import java.io.Serializable;
import org.hibernate.HibernateException;
import org.hibernate.LockMode;
import org.hibernate.Session;
import org.springframework.orm.hibernate5.HibernateCallback;

class f
implements HibernateCallback<Object> {
    final Goid val$id;
    final MasterPasswordManager val$dbEncrypter;
    final char[] val$password;
    final KeystoreFileManagerImpl this$0;
    private static final String a = f.a(25, f.a("GSDZe^\u0007VAR"));

    f(KeystoreFileManagerImpl keystoreFileManagerImpl, Goid goid, MasterPasswordManager masterPasswordManager, char[] cArray) {
        this.this$0 = keystoreFileManagerImpl;
        this.val$id = goid;
        this.val$dbEncrypter = masterPasswordManager;
        this.val$password = cArray;
    }

    public Object doInHibernate(Session session) throws HibernateException {
        try {
            KeystoreFile keystoreFile = (KeystoreFile)((Object)session.load(KeystoreFile.class, (Serializable)this.val$id, LockMode.UPGRADE));
            keystoreFile.setProperty(a, this.val$dbEncrypter.encryptPassword(this.val$password));
            this.this$0.update(keystoreFile);
            return keystoreFile;
        }
        catch (UpdateException updateException) {
            throw new HibernateException((Throwable)updateException);
        }
    }

    private static char[] a(String string) {
        char[] cArray = string.toCharArray();
        if (cArray.length < 2) {
            cArray = cArray;
            cArray[0] = (char)(cArray[0] ^ 0x6C);
        }
        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 -> 46;
                    case 1 -> 43;
                    case 2 -> 46;
                    case 3 -> 48;
                    case 4 -> 12;
                    case 5 -> 47;
                    default -> 108;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }
}

