package com.l7tech.external.assertions.gatewaymanagement.server;

import com.l7tech.gateway.api.PrivateKeyMO;
import com.l7tech.objectmodel.ObjectModelException;
import com.l7tech.objectmodel.SecurityZone;
import com.l7tech.util.Eithers.E2;
import java.util.Map;

class b4
   implements ResourceFactorySupport.TransactionalCallback<E2<ResourceFactory.ResourceNotFoundException, ResourceFactory.InvalidResourceException, PrivateKeyMO>> {
   final Map val$selectorMap;
   final PrivateKeyMO val$privateKeyResource;
   final SecurityZone val$securityZone;
   final PrivateKeyResourceFactory this$0;
   private static final String[] a;

   b4(PrivateKeyResourceFactory var1, Map var2, PrivateKeyMO var3, SecurityZone var4) {
      this.this$0 = var1;
      this.val$selectorMap = var2;
      this.val$privateKeyResource = var3;
      this.val$securityZone = var4;
   }

   public E2<ResourceFactory.ResourceNotFoundException, ResourceFactory.InvalidResourceException, PrivateKeyMO> execute() throws ObjectModelException {
      // $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:
      // 000: aload 0
      // 001: getfield com/l7tech/external/assertions/gatewaymanagement/server/b4.this$0 Lcom/l7tech/external/assertions/gatewaymanagement/server/PrivateKeyResourceFactory;
      // 004: aload 0
      // 005: getfield com/l7tech/external/assertions/gatewaymanagement/server/b4.val$selectorMap Ljava/util/Map;
      // 008: invokevirtual com/l7tech/external/assertions/gatewaymanagement/server/PrivateKeyResourceFactory.a (Ljava/util/Map;)Lcom/l7tech/util/Pair;
      // 00b: astore 1
      // 00c: aload 0
      // 00d: getfield com/l7tech/external/assertions/gatewaymanagement/server/b4.this$0 Lcom/l7tech/external/assertions/gatewaymanagement/server/PrivateKeyResourceFactory;
      // 010: aload 1
      // 011: invokevirtual com/l7tech/external/assertions/gatewaymanagement/server/PrivateKeyResourceFactory.a (Lcom/l7tech/util/Pair;)Lcom/l7tech/gateway/common/security/keystore/SsgKeyEntry;
      // 014: astore 2
      // 015: aload 0
      // 016: getfield com/l7tech/external/assertions/gatewaymanagement/server/b4.this$0 Lcom/l7tech/external/assertions/gatewaymanagement/server/PrivateKeyResourceFactory;
      // 019: getstatic com/l7tech/gateway/common/security/rbac/OperationType.UPDATE Lcom/l7tech/gateway/common/security/rbac/OperationType;
      // 01c: aconst_null
      // 01d: aload 2
      // 01e: invokevirtual com/l7tech/external/assertions/gatewaymanagement/server/PrivateKeyResourceFactory.checkPermitted (Lcom/l7tech/gateway/common/security/rbac/OperationType;Ljava/lang/String;Lcom/l7tech/objectmodel/Entity;)V
      // 021: aload 0
      // 022: getfield com/l7tech/external/assertions/gatewaymanagement/server/b4.val$privateKeyResource Lcom/l7tech/gateway/api/PrivateKeyMO;
      // 025: invokevirtual com/l7tech/gateway/api/PrivateKeyMO.getCertificateChain ()Ljava/util/List;
      // 028: astore 3
      // 029: aload 3
      // 02a: ifnull 03d
      // 02d: aload 3
      // 02e: invokeinterface java/util/List.isEmpty ()Z 1
      // 033: ifeq 051
      // 036: goto 03d
      // 039: invokestatic com/l7tech/external/assertions/gatewaymanagement/server/b4.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 03c: athrow
      // 03d: new com/l7tech/external/assertions/gatewaymanagement/server/ResourceFactory$InvalidResourceException
      // 040: dup
      // 041: getstatic com/l7tech/external/assertions/gatewaymanagement/server/ResourceFactory$InvalidResourceException$ExceptionType.MISSING_VALUES Lcom/l7tech/external/assertions/gatewaymanagement/server/ResourceFactory$InvalidResourceException$ExceptionType;
      // 044: getstatic com/l7tech/external/assertions/gatewaymanagement/server/b4.a [Ljava/lang/String;
      // 047: bipush 1
      // 048: aaload
      // 049: invokespecial com/l7tech/external/assertions/gatewaymanagement/server/ResourceFactory$InvalidResourceException.<init> (Lcom/l7tech/external/assertions/gatewaymanagement/server/ResourceFactory$InvalidResourceException$ExceptionType;Ljava/lang/String;)V
      // 04c: athrow
      // 04d: invokestatic com/l7tech/external/assertions/gatewaymanagement/server/b4.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 050: athrow
      // 051: aload 0
      // 052: getfield com/l7tech/external/assertions/gatewaymanagement/server/b4.this$0 Lcom/l7tech/external/assertions/gatewaymanagement/server/PrivateKeyResourceFactory;
      // 055: aload 3
      // 056: invokevirtual com/l7tech/external/assertions/gatewaymanagement/server/PrivateKeyResourceFactory.toCertificateArray (Ljava/util/List;)[Ljava/security/cert/X509Certificate;
      // 059: astore 4
      // 05b: aload 0
      // 05c: getfield com/l7tech/external/assertions/gatewaymanagement/server/b4.this$0 Lcom/l7tech/external/assertions/gatewaymanagement/server/PrivateKeyResourceFactory;
      // 05f: invokevirtual com/l7tech/external/assertions/gatewaymanagement/server/PrivateKeyResourceFactory.a ()Lcom/l7tech/server/admin/PrivateKeyAdminHelper;
      // 062: astore 5
      // 064: aload 5
      // 066: aload 2
      // 067: invokevirtual com/l7tech/gateway/common/security/keystore/SsgKeyEntry.getKeystoreId ()Lcom/l7tech/objectmodel/Goid;
      // 06a: aload 2
      // 06b: invokevirtual com/l7tech/gateway/common/security/keystore/SsgKeyEntry.getAlias ()Ljava/lang/String;
      // 06e: aload 4
      // 070: aload 0
      // 071: getfield com/l7tech/external/assertions/gatewaymanagement/server/b4.val$privateKeyResource Lcom/l7tech/gateway/api/PrivateKeyMO;
      // 074: invokevirtual com/l7tech/gateway/api/PrivateKeyMO.isReplaceAllMatchingCertChain ()Z
      // 077: invokevirtual com/l7tech/server/admin/PrivateKeyAdminHelper.doUpdateCertificateChain (Lcom/l7tech/objectmodel/Goid;Ljava/lang/String;[Ljava/security/cert/X509Certificate;Z)V
      // 07a: goto 09d
      // 07d: astore 5
      // 07f: new com/l7tech/objectmodel/UpdateException
      // 082: dup
      // 083: aload 5
      // 085: invokestatic com/l7tech/util/ExceptionUtils.getMessage (Ljava/lang/Throwable;)Ljava/lang/String;
      // 088: getstatic com/l7tech/external/assertions/gatewaymanagement/server/b4.a [Ljava/lang/String;
      // 08b: astore 7
      // 08d: aload 7
      // 08f: bipush 2
      // 090: aaload
      // 091: swap
      // 092: 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" ]
      // 097: aload 5
      // 099: invokespecial com/l7tech/objectmodel/UpdateException.<init> (Ljava/lang/String;Ljava/lang/Throwable;)V
      // 09c: athrow
      // 09d: aconst_null
      // 09e: astore 5
      // 0a0: aload 0
      // 0a1: getfield com/l7tech/external/assertions/gatewaymanagement/server/b4.val$securityZone Lcom/l7tech/objectmodel/SecurityZone;
      // 0a4: ifnull 0bc
      // 0a7: new com/l7tech/gateway/common/security/keystore/SsgKeyMetadata
      // 0aa: dup
      // 0ab: aload 2
      // 0ac: invokevirtual com/l7tech/gateway/common/security/keystore/SsgKeyEntry.getKeystoreId ()Lcom/l7tech/objectmodel/Goid;
      // 0af: aload 2
      // 0b0: invokevirtual com/l7tech/gateway/common/security/keystore/SsgKeyEntry.getAlias ()Ljava/lang/String;
      // 0b3: aload 0
      // 0b4: getfield com/l7tech/external/assertions/gatewaymanagement/server/b4.val$securityZone Lcom/l7tech/objectmodel/SecurityZone;
      // 0b7: invokespecial com/l7tech/gateway/common/security/keystore/SsgKeyMetadata.<init> (Lcom/l7tech/objectmodel/Goid;Ljava/lang/String;Lcom/l7tech/objectmodel/SecurityZone;)V
      // 0ba: astore 5
      // 0bc: aload 0
      // 0bd: getfield com/l7tech/external/assertions/gatewaymanagement/server/b4.this$0 Lcom/l7tech/external/assertions/gatewaymanagement/server/PrivateKeyResourceFactory;
      // 0c0: invokevirtual com/l7tech/external/assertions/gatewaymanagement/server/PrivateKeyResourceFactory.a ()Lcom/l7tech/server/admin/PrivateKeyAdminHelper;
      // 0c3: astore 6
      // 0c5: aload 6
      // 0c7: aload 2
      // 0c8: invokevirtual com/l7tech/gateway/common/security/keystore/SsgKeyEntry.getKeystoreId ()Lcom/l7tech/objectmodel/Goid;
      // 0cb: aload 2
      // 0cc: invokevirtual com/l7tech/gateway/common/security/keystore/SsgKeyEntry.getAlias ()Ljava/lang/String;
      // 0cf: aload 5
      // 0d1: invokevirtual com/l7tech/server/admin/PrivateKeyAdminHelper.doUpdateKeyMetadata (Lcom/l7tech/objectmodel/Goid;Ljava/lang/String;Lcom/l7tech/gateway/common/security/keystore/SsgKeyMetadata;)V
      // 0d4: goto 0f3
      // 0d7: astore 5
      // 0d9: new com/l7tech/objectmodel/UpdateException
      // 0dc: dup
      // 0dd: aload 5
      // 0df: invokestatic com/l7tech/util/ExceptionUtils.getMessage (Ljava/lang/Throwable;)Ljava/lang/String;
      // 0e2: getstatic com/l7tech/external/assertions/gatewaymanagement/server/b4.a [Ljava/lang/String;
      // 0e5: bipush 0
      // 0e6: aaload
      // 0e7: swap
      // 0e8: 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" ]
      // 0ed: aload 5
      // 0ef: invokespecial com/l7tech/objectmodel/UpdateException.<init> (Ljava/lang/String;Ljava/lang/Throwable;)V
      // 0f2: athrow
      // 0f3: aload 0
      // 0f4: getfield com/l7tech/external/assertions/gatewaymanagement/server/b4.this$0 Lcom/l7tech/external/assertions/gatewaymanagement/server/PrivateKeyResourceFactory;
      // 0f7: aload 0
      // 0f8: getfield com/l7tech/external/assertions/gatewaymanagement/server/b4.this$0 Lcom/l7tech/external/assertions/gatewaymanagement/server/PrivateKeyResourceFactory;
      // 0fb: aload 1
      // 0fc: invokevirtual com/l7tech/external/assertions/gatewaymanagement/server/PrivateKeyResourceFactory.a (Lcom/l7tech/util/Pair;)Lcom/l7tech/gateway/common/security/keystore/SsgKeyEntry;
      // 0ff: invokestatic com/l7tech/util/Option.none ()Lcom/l7tech/util/Option;
      // 102: invokevirtual com/l7tech/external/assertions/gatewaymanagement/server/PrivateKeyResourceFactory.a (Lcom/l7tech/gateway/common/security/keystore/SsgKeyEntry;Lcom/l7tech/util/Option;)Lcom/l7tech/gateway/api/PrivateKeyMO;
      // 105: invokestatic com/l7tech/util/Eithers.right2 (Ljava/lang/Object;)Lcom/l7tech/util/Eithers$E2;
      // 108: areturn
      // 109: astore 1
      // 10a: aload 1
      // 10b: invokestatic com/l7tech/util/Eithers.left2_1 (Ljava/lang/Object;)Lcom/l7tech/util/Eithers$E2;
      // 10e: areturn
      // 10f: astore 1
      // 110: aload 1
      // 111: invokestatic com/l7tech/util/Eithers.left2_2 (Ljava/lang/Object;)Lcom/l7tech/util/Eithers$E2;
      // 114: areturn
      // try (23 -> 37): 37 java/lang/Exception
      // try (21 -> 26): 27 java/lang/Exception
      // try (44 -> 58): 59 java/lang/Exception
      // try (74 -> 100): 101 java/lang/Exception
      // try (0 -> 123): 124 com/l7tech/external/assertions/gatewaymanagement/server/ResourceFactory$ResourceNotFoundException
      // try (0 -> 123): 128 com/l7tech/external/assertions/gatewaymanagement/server/ResourceFactory$InvalidResourceException
   }

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

   static {
      String[] var5 = new String[3];
      int var3 = 0;
      String var2 = ",NS\\lk)\u0019X@Gw%;IODPk95\u001dE\u0001Iq%9INDU{99\u0007_D\t>\u0011\nYSGw-5\n]UV>(4\bUO\u0018,NS\\lk/\fHUZp,|\u0007YV\u0013}..\u001d\u0006\u0001";
      int var4 = ",NS\\lk)\u0019X@Gw%;IODPk95\u001dE\u0001Iq%9INDU{99\u0007_D\t>\u0011\nYSGw-5\n]UV>(4\bUO\u0018,NS\\lk/\fHUZp,|\u0007YV\u0013}..\u001d\u0006\u0001"
         .length();
      char var1 = '(';
      int var0 = -1;

      while (true) {
         String var10002 = a(19, 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] ^ 79);
      }

      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 -> 122;
            case 1 -> 47;
            case 2 -> 50;
            case 3 -> 32;
            case 4 -> 13;
            case 5 -> 88;
            default -> 79;
         });
      }

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