package com.l7tech.server.security.keystore;

import com.l7tech.common.io.CertGenParams;
import com.l7tech.common.io.CertificateGeneratorException;
import com.l7tech.common.io.DuplicateAliasException;
import com.l7tech.common.io.KeyGenParams;
import com.l7tech.gateway.common.security.keystore.SsgKeyMetadata;
import com.l7tech.objectmodel.ObjectModelException;
import java.security.GeneralSecurityException;
import java.security.cert.X509Certificate;
import java.util.concurrent.Callable;

class c implements Callable<X509Certificate> {
   final String val$alias;
   final CertGenParams val$certGenParams;
   final KeyGenParams val$keyGenParams;
   final SsgKeyMetadata val$metadata;
   final JdkKeyStoreBackedSsgKeyStore this$0;
   private static final String[] a;

   c(JdkKeyStoreBackedSsgKeyStore var1, String var2, CertGenParams var3, KeyGenParams var4, SsgKeyMetadata var5) {
      this.this$0 = var1;
      this.val$alias = var2;
      this.val$certGenParams = var3;
      this.val$keyGenParams = var4;
      this.val$metadata = var5;
   }

   public X509Certificate call() throws GeneralSecurityException, DuplicateAliasException, CertificateGeneratorException {
      // $VF: Couldn't be decompiled
      // Please report this to the Vineflower issue tracker, at https://github.com/Vineflower/vineflower/issues with a copy of the class file (if you have the rights to distribute it!)
      // java.lang.RuntimeException: parsing failure!
      //   at org.jetbrains.java.decompiler.modules.decompiler.decompose.DomHelper.parseGraph(DomHelper.java:211)
      //   at org.jetbrains.java.decompiler.main.rels.MethodProcessor.codeToJava(MethodProcessor.java:174)
      //
      // Bytecode:
      // 00: aload 0
      // 01: getfield com/l7tech/server/security/keystore/c.this$0 Lcom/l7tech/server/security/keystore/JdkKeyStoreBackedSsgKeyStore;
      // 04: invokevirtual com/l7tech/server/security/keystore/JdkKeyStoreBackedSsgKeyStore.keyStore ()Ljava/security/KeyStore;
      // 07: astore 1
      // 08: aload 1
      // 09: aload 0
      // 0a: getfield com/l7tech/server/security/keystore/c.val$alias Ljava/lang/String;
      // 0d: invokevirtual java/security/KeyStore.containsAlias (Ljava/lang/String;)Z
      // 10: ifeq 2e
      // 13: new com/l7tech/common/io/DuplicateAliasException
      // 16: dup
      // 17: aload 0
      // 18: getfield com/l7tech/server/security/keystore/c.val$alias Ljava/lang/String;
      // 1b: getstatic com/l7tech/server/security/keystore/c.a [Ljava/lang/String;
      // 1e: bipush 0
      // 1f: aaload
      // 20: swap
      // 21: invokedynamic makeConcatWithConstants (Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String; bsm=java/lang/invoke/StringConcatFactory.makeConcatWithConstants (Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/invoke/CallSite; args=[ "\u0001\u0001" ]
      // 26: invokespecial com/l7tech/common/io/DuplicateAliasException.<init> (Ljava/lang/String;)V
      // 29: athrow
      // 2a: invokestatic com/l7tech/server/security/keystore/c.a (Lcom/l7tech/objectmodel/ObjectModelException;)Lcom/l7tech/objectmodel/ObjectModelException;
      // 2d: athrow
      // 2e: aload 0
      // 2f: getfield com/l7tech/server/security/keystore/c.val$certGenParams Lcom/l7tech/common/io/CertGenParams;
      // 32: invokevirtual com/l7tech/common/io/CertGenParams.getSubjectDn ()Ljavax/security/auth/x500/X500Principal;
      // 35: astore 2
      // 36: aload 0
      // 37: getfield com/l7tech/server/security/keystore/c.this$0 Lcom/l7tech/server/security/keystore/JdkKeyStoreBackedSsgKeyStore;
      // 3a: invokevirtual com/l7tech/server/security/keystore/JdkKeyStoreBackedSsgKeyStore.a ()Z
      // 3d: ifne 64
      // 40: aload 0
      // 41: getfield com/l7tech/server/security/keystore/c.this$0 Lcom/l7tech/server/security/keystore/JdkKeyStoreBackedSsgKeyStore;
      // 44: aload 1
      // 45: aload 2
      // 46: invokevirtual com/l7tech/server/security/keystore/JdkKeyStoreBackedSsgKeyStore.a (Ljava/security/KeyStore;Ljavax/security/auth/x500/X500Principal;)Z
      // 49: ifeq 64
      // 4c: goto 53
      // 4f: invokestatic com/l7tech/server/security/keystore/c.a (Lcom/l7tech/objectmodel/ObjectModelException;)Lcom/l7tech/objectmodel/ObjectModelException;
      // 52: athrow
      // 53: new java/security/GeneralSecurityException
      // 56: dup
      // 57: getstatic com/l7tech/server/security/keystore/c.a [Ljava/lang/String;
      // 5a: bipush 2
      // 5b: aaload
      // 5c: invokespecial java/security/GeneralSecurityException.<init> (Ljava/lang/String;)V
      // 5f: athrow
      // 60: invokestatic com/l7tech/server/security/keystore/c.a (Lcom/l7tech/objectmodel/ObjectModelException;)Lcom/l7tech/objectmodel/ObjectModelException;
      // 63: athrow
      // 64: new com/l7tech/security/cert/ParamsKeyGenerator
      // 67: dup
      // 68: aload 0
      // 69: getfield com/l7tech/server/security/keystore/c.val$keyGenParams Lcom/l7tech/common/io/KeyGenParams;
      // 6c: invokespecial com/l7tech/security/cert/ParamsKeyGenerator.<init> (Lcom/l7tech/common/io/KeyGenParams;)V
      // 6f: invokevirtual com/l7tech/security/cert/ParamsKeyGenerator.generateKeyPair ()Ljava/security/KeyPair;
      // 72: astore 3
      // 73: aload 0
      // 74: getfield com/l7tech/server/security/keystore/c.val$certGenParams Lcom/l7tech/common/io/CertGenParams;
      // 77: aload 3
      // 78: invokestatic com/l7tech/security/cert/BouncyCastleCertUtils.generateSelfSignedCertificate (Lcom/l7tech/common/io/CertGenParams;Ljava/security/KeyPair;)Ljava/security/cert/X509Certificate;
      // 7b: astore 4
      // 7d: aload 1
      // 7e: aload 0
      // 7f: getfield com/l7tech/server/security/keystore/c.val$alias Ljava/lang/String;
      // 82: aload 3
      // 83: invokevirtual java/security/KeyPair.getPrivate ()Ljava/security/PrivateKey;
      // 86: aload 0
      // 87: getfield com/l7tech/server/security/keystore/c.this$0 Lcom/l7tech/server/security/keystore/JdkKeyStoreBackedSsgKeyStore;
      // 8a: invokevirtual com/l7tech/server/security/keystore/JdkKeyStoreBackedSsgKeyStore.getEntryPassword ()[C
      // 8d: bipush 1
      // 8e: anewarray 73
      // 91: dup
      // 92: bipush 0
      // 93: aload 4
      // 95: aastore
      // 96: invokevirtual java/security/KeyStore.setKeyEntry (Ljava/lang/String;Ljava/security/Key;[C[Ljava/security/cert/Certificate;)V
      // 99: aload 0
      // 9a: getfield com/l7tech/server/security/keystore/c.this$0 Lcom/l7tech/server/security/keystore/JdkKeyStoreBackedSsgKeyStore;
      // 9d: getfield com/l7tech/server/security/keystore/JdkKeyStoreBackedSsgKeyStore.h Lcom/l7tech/server/security/keystore/SsgKeyMetadataManager;
      // a0: aload 0
      // a1: getfield com/l7tech/server/security/keystore/c.this$0 Lcom/l7tech/server/security/keystore/JdkKeyStoreBackedSsgKeyStore;
      // a4: invokevirtual com/l7tech/server/security/keystore/JdkKeyStoreBackedSsgKeyStore.getGoid ()Lcom/l7tech/objectmodel/Goid;
      // a7: aload 0
      // a8: getfield com/l7tech/server/security/keystore/c.val$alias Ljava/lang/String;
      // ab: aload 0
      // ac: getfield com/l7tech/server/security/keystore/c.val$metadata Lcom/l7tech/gateway/common/security/keystore/SsgKeyMetadata;
      // af: invokeinterface com/l7tech/server/security/keystore/SsgKeyMetadataManager.updateMetadataForKey (Lcom/l7tech/objectmodel/Goid;Ljava/lang/String;Lcom/l7tech/gateway/common/security/keystore/SsgKeyMetadata;)Lcom/l7tech/objectmodel/Goid; 4
      // b4: pop
      // b5: goto d3
      // b8: astore 5
      // ba: new java/security/KeyStoreException
      // bd: dup
      // be: aload 0
      // bf: getfield com/l7tech/server/security/keystore/c.val$alias Ljava/lang/String;
      // c2: getstatic com/l7tech/server/security/keystore/c.a [Ljava/lang/String;
      // c5: bipush 1
      // c6: aaload
      // c7: swap
      // c8: invokedynamic makeConcatWithConstants (Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String; bsm=java/lang/invoke/StringConcatFactory.makeConcatWithConstants (Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/invoke/CallSite; args=[ "\u0001\u0001" ]
      // cd: aload 5
      // cf: invokespecial java/security/KeyStoreException.<init> (Ljava/lang/String;Ljava/lang/Throwable;)V
      // d2: athrow
      // d3: aload 4
      // d5: areturn
      // try (30 -> 46): 46 com/l7tech/objectmodel/ObjectModelException
      // try (26 -> 36): 37 com/l7tech/objectmodel/ObjectModelException
      // try (4 -> 20): 20 com/l7tech/objectmodel/ObjectModelException
      // try (75 -> 87): 88 com/l7tech/objectmodel/ObjectModelException
   }

   private static ObjectModelException a(ObjectModelException var0) {
      return var0;
   }

   static {
      String[] var5 = new String[3];
      int var3 = 0;
      String var2 = "\u0004\u001fJ8\"5k*ZR'$?x+\u0003\u0013(94m.\u0013]8v;u&\u001b@k \u001a\u0014R):?9;\u0015\u001387,|o\u0017V?7>x;\u001b\u0013-9(9$\u001fJk)\u001c\u000fQ!39mo>}k76k*\u001bW2v?a&\tG8v3wo\u000e[.v\u0011|6\tG$$?";
      int var4 = "\u0004\u001fJ8\"5k*ZR'$?x+\u0003\u0013(94m.\u0013]8v;u&\u001b@k \u001a\u0014R):?9;\u0015\u001387,|o\u0017V?7>x;\u001b\u0013-9(9$\u001fJk)\u001c\u000fQ!39mo>}k76k*\u001bW2v?a&\tG8v3wo\u000e[.v\u0011|6\tG$$?"
         .length();
      char var1 = ' ';
      int var0 = -1;

      while (true) {
         String var10002 = a(66, a(var2.substring(++var0, var0 + var1)));
         byte var10001 = -1;
         var5[var3++] = var10002;
         if ((var0 += var1) >= var4) {
            a = var5;
            return;
         }

         var1 = var2.charAt(var0);
      }
   }

   private static char[] a(String var0) {
      char[] var10000 = var0.toCharArray();
      if (var10000.length < 2) {
         var10000[0] = (char)(var10000[0] ^ 91);
      }

      return var10000;
   }

   private static String a(int var0, char[] var1) {
      int var10003 = var1.length;
      int var10002 = var0;
      char[] var10001 = var1;
      int var10000 = var10003;

      for (int var2 = 0; var10000 > var2; var2++) {
         var10001[var2] = (char)(var10001[var2] ^ var10002 ^ switch (var2 % 7) {
            case 0 -> 13;
            case 1 -> 56;
            case 2 -> 113;
            case 3 -> 9;
            case 4 -> 20;
            case 5 -> 24;
            default -> 91;
         });
      }

      return new String(var10001).intern();
   }
}
