package com.l7tech.server.security.keystore.ncipher;

import com.l7tech.server.security.keystore.KeystoreFile;
import com.l7tech.util.Pair;
import com.l7tech.util.Functions.UnaryVoid;
import java.security.KeyStore;
import java.security.KeyStoreException;

class d implements UnaryVoid<KeystoreFile> {
   final NcipherSsgKeyStore this$0;
   private static final String a;

   d(NcipherSsgKeyStore var1) {
      this.this$0 = var1;
   }

   public void call(KeystoreFile var1) {
      try {
         byte[] var2 = var1.getDatabytes();

         Pair var3;
         label25: {
            label24: {
               try {
                  if (var2 == null || var2.length < 1) {
                     break label24;
                  }
               } catch (KeyStoreException var4) {
                  throw a(var4);
               }

               var3 = this.this$0.a(var2);
               break label25;
            }

            var3 = this.this$0.d();
         }

         this.this$0.t = (NcipherKeyStoreData)var3.left;
         this.this$0.s = (KeyStore)var3.right;
         this.this$0.v = System.currentTimeMillis();
         var1.setProperty(a, this.this$0.t.keystoreMetadata);
         var1.setDatabytes(this.this$0.a(this.this$0.t, this.this$0.s));
      } catch (KeyStoreException var5) {
         throw new RuntimeException(var5);
      }
   }

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

   static {
      String var10002 = a(37, a("\n\u001fY?\u0012\u0010((\u0014I8\u000f\u001e6\u00068T"));
      byte var10001 = -1;
      a = var10002;
   }

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

      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 -> 70;
            case 1 -> 84;
            case 2 -> 21;
            case 3 -> 110;
            case 4 -> 94;
            case 5 -> 84;
            default -> 97;
         });
      }

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