/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.l7tech.gateway.common.security.password.SecurePassword
 *  com.l7tech.gateway.common.security.password.SecurePassword$SecurePasswordType
 *  com.l7tech.objectmodel.Goid
 *  com.l7tech.objectmodel.PersistentEntity
 *  com.l7tech.security.keys.PemUtils
 *  com.l7tech.security.prov.JceProvider
 *  com.l7tech.security.prov.ProviderUtil
 */
package com.l7tech.server.admin;

import com.l7tech.gateway.common.security.password.SecurePassword;
import com.l7tech.objectmodel.Goid;
import com.l7tech.objectmodel.PersistentEntity;
import com.l7tech.security.keys.PemUtils;
import com.l7tech.security.prov.JceProvider;
import com.l7tech.security.prov.ProviderUtil;
import com.l7tech.server.admin.TrustedCertAdminImpl;
import java.security.KeyPairGenerator;
import java.security.PrivateKey;
import java.util.concurrent.Callable;

class o
implements Callable<Boolean> {
    final int val$keybits;
    final Goid val$securePasswordGoid;
    final TrustedCertAdminImpl this$0;
    private static final String a = o.a(72, o.a("\u0006T`"));

    /*
     * Ignored method signature, as it can't be verified against descriptor
     */
    o(TrustedCertAdminImpl trustedCertAdminImpl, int n2, Goid goid) {
        this.this$0 = trustedCertAdminImpl;
        this.val$keybits = n2;
        this.val$securePasswordGoid = goid;
    }

    @Override
    public Boolean call() throws Exception {
        KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance(a, ProviderUtil.loadInstalledBCProxy().getBCProvider());
        keyPairGenerator.initialize(this.val$keybits, JceProvider.getInstance().getSecureRandom());
        SecurePassword securePassword = this.this$0.a(this.val$securePasswordGoid, SecurePassword.SecurePasswordType.PEM_PRIVATE_KEY);
        String string = PemUtils.doWriteKeyPair((PrivateKey)keyPairGenerator.genKeyPair().getPrivate());
        securePassword.setEncodedPassword(this.this$0.m.encryptPassword(string.toCharArray()));
        securePassword.setLastUpdate(System.currentTimeMillis());
        this.this$0.m.update((PersistentEntity)securePassword);
        return true;
    }

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

