package com.l7tech.policy.wsp;

import com.l7tech.policy.assertion.Assertion;
import com.l7tech.security.token.SecurityTokenType;
import com.l7tech.security.token.XmlSecurityToken;
import com.l7tech.util.DomUtils;
import com.l7tech.util.SoapConstants;
import org.w3c.dom.Element;

class l extends BeanTypeMapping {
   protected final SecurityTokenType tokenType;
   private static final t c;
   private static final String[] d;

   public l(Assertion var1, String var2, SecurityTokenType var3) {
      super(var1.getClass(), var2);
      this.tokenType = var3;
   }

   public l() {
      super(XmlSecurityToken.class, d[8]);
      this.tokenType = null;
   }

   protected String getPropertiesElementName(SecurityTokenType param1) {
      // $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: getstatic com/l7tech/security/token/SecurityTokenType.SAML_ASSERTION Lcom/l7tech/security/token/SecurityTokenType;
      // 03: aload 1
      // 04: invokevirtual java/lang/Object.equals (Ljava/lang/Object;)Z
      // 07: ifne 1b
      // 0a: getstatic com/l7tech/security/token/SecurityTokenType.SAML2_ASSERTION Lcom/l7tech/security/token/SecurityTokenType;
      // 0d: aload 1
      // 0e: invokevirtual java/lang/Object.equals (Ljava/lang/Object;)Z
      // 11: ifeq 28
      // 14: goto 1b
      // 17: invokestatic com/l7tech/policy/wsp/l.d (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 1a: athrow
      // 1b: getstatic com/l7tech/policy/wsp/l.d [Ljava/lang/String;
      // 1e: bipush 11
      // 20: aaload
      // 21: goto 2e
      // 24: invokestatic com/l7tech/policy/wsp/l.d (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 27: athrow
      // 28: getstatic com/l7tech/policy/wsp/l.d [Ljava/lang/String;
      // 2b: bipush 10
      // 2d: aaload
      // 2e: areturn
      // try (0 -> 8): 9 com/l7tech/policy/wsp/InvalidPolicyTreeException
      // try (4 -> 15): 15 com/l7tech/policy/wsp/InvalidPolicyTreeException
   }

   @Override
   public Element freeze(WspWriter var1, TypedReference var2, Element var3) {
      try {
         if (this.tokenType == null) {
            throw new InvalidPolicyTreeException(d[0] + this.getMappedClass());
         }
      } catch (InvalidPolicyTreeException var10) {
         throw d(var10);
      }

      String var4 = SoapConstants.SECURITY_NAMESPACE;
      String[] var9 = d;
      String var5 = var9[3];
      Element var6 = DomUtils.createAndAppendElementNS(var3, var9[9], var4, var9[6]);
      c.freeze(var1, new TypedReference(this.tokenType.getClass(), this.tokenType), var6);
      if (var9[9].equals(var6.getLocalName())) {
         String var7 = this.getNsPrefix();
         if (var7.endsWith(":")) {
            var7 = var7.substring(0, var7.length() - 1);
         }

         if (var7.length() < 1) {
            var7 = d[1];
         }

         Element var8 = DomUtils.createAndAppendElementNS(var6, this.getPropertiesElementName(this.tokenType), this.getNsUri(), var7);
         super.populateElement(var1, var8, var2);
      }

      return var6;
   }

   @Override
   public TypedReference thaw(Element param1, WspVisitor param2) throws InvalidPolicyStreamException {
      // $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: getstatic com/l7tech/policy/wsp/l.d [Ljava/lang/String;
      // 003: bipush 9
      // 005: aaload
      // 006: aload 1
      // 007: invokeinterface org/w3c/dom/Element.getLocalName ()Ljava/lang/String; 1
      // 00c: invokevirtual java/lang/String.equals (Ljava/lang/Object;)Z
      // 00f: ifne 01d
      // 012: aload 0
      // 013: aload 1
      // 014: aload 2
      // 015: invokespecial com/l7tech/policy/wsp/BeanTypeMapping.thaw (Lorg/w3c/dom/Element;Lcom/l7tech/policy/wsp/WspVisitor;)Lcom/l7tech/policy/wsp/TypedReference;
      // 018: areturn
      // 019: invokestatic com/l7tech/policy/wsp/l.d (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 01c: athrow
      // 01d: aload 1
      // 01e: aconst_null
      // 01f: checkcast java/lang/String
      // 022: getstatic com/l7tech/policy/wsp/l.d [Ljava/lang/String;
      // 025: astore 8
      // 027: aload 8
      // 029: bipush 4
      // 02a: aaload
      // 02b: invokestatic com/l7tech/util/DomUtils.findFirstChildElementByName (Lorg/w3c/dom/Node;Ljava/lang/String;Ljava/lang/String;)Lorg/w3c/dom/Element;
      // 02e: astore 3
      // 02f: aload 3
      // 030: ifnonnull 044
      // 033: new com/l7tech/policy/wsp/InvalidPolicyStreamException
      // 036: dup
      // 037: aload 8
      // 039: bipush 7
      // 03b: aaload
      // 03c: invokespecial com/l7tech/policy/wsp/InvalidPolicyStreamException.<init> (Ljava/lang/String;)V
      // 03f: athrow
      // 040: invokestatic com/l7tech/policy/wsp/l.d (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 043: athrow
      // 044: getstatic com/l7tech/policy/wsp/l.c Lcom/l7tech/policy/wsp/t;
      // 047: aload 3
      // 048: aload 2
      // 049: invokevirtual com/l7tech/policy/wsp/t.thaw (Lorg/w3c/dom/Element;Lcom/l7tech/policy/wsp/WspVisitor;)Lcom/l7tech/policy/wsp/TypedReference;
      // 04c: astore 4
      // 04e: aload 4
      // 050: ifnull 074
      // 053: aload 4
      // 055: getfield com/l7tech/policy/wsp/TypedReference.target Ljava/lang/Object;
      // 058: ifnull 074
      // 05b: goto 062
      // 05e: invokestatic com/l7tech/policy/wsp/l.d (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 061: athrow
      // 062: aload 4
      // 064: getfield com/l7tech/policy/wsp/TypedReference.target Ljava/lang/Object;
      // 067: instanceof com/l7tech/security/token/SecurityTokenType
      // 06a: ifne 085
      // 06d: goto 074
      // 070: invokestatic com/l7tech/policy/wsp/l.d (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 073: athrow
      // 074: new com/l7tech/policy/wsp/InvalidPolicyStreamException
      // 077: dup
      // 078: getstatic com/l7tech/policy/wsp/l.d [Ljava/lang/String;
      // 07b: bipush 2
      // 07c: aaload
      // 07d: invokespecial com/l7tech/policy/wsp/InvalidPolicyStreamException.<init> (Ljava/lang/String;)V
      // 080: athrow
      // 081: invokestatic com/l7tech/policy/wsp/l.d (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 084: athrow
      // 085: aload 4
      // 087: getfield com/l7tech/policy/wsp/TypedReference.target Ljava/lang/Object;
      // 08a: checkcast com/l7tech/security/token/SecurityTokenType
      // 08d: astore 5
      // 08f: getstatic com/l7tech/security/token/SecurityTokenType.SAML_ASSERTION Lcom/l7tech/security/token/SecurityTokenType;
      // 092: aload 5
      // 094: invokevirtual java/lang/Object.equals (Ljava/lang/Object;)Z
      // 097: ifeq 0af
      // 09a: new com/l7tech/policy/wsp/TypedReference
      // 09d: dup
      // 09e: ldc com/l7tech/policy/assertion/xmlsec/RequireWssSaml
      // 0a0: new com/l7tech/policy/assertion/xmlsec/RequireWssSaml
      // 0a3: dup
      // 0a4: invokespecial com/l7tech/policy/assertion/xmlsec/RequireWssSaml.<init> ()V
      // 0a7: invokespecial com/l7tech/policy/wsp/TypedReference.<init> (Ljava/lang/Class;Ljava/lang/Object;)V
      // 0aa: astore 6
      // 0ac: goto 147
      // 0af: getstatic com/l7tech/security/token/SecurityTokenType.SAML2_ASSERTION Lcom/l7tech/security/token/SecurityTokenType;
      // 0b2: aload 5
      // 0b4: invokevirtual java/lang/Object.equals (Ljava/lang/Object;)Z
      // 0b7: ifeq 0cf
      // 0ba: new com/l7tech/policy/wsp/TypedReference
      // 0bd: dup
      // 0be: ldc com/l7tech/policy/assertion/xmlsec/RequireWssSaml2
      // 0c0: new com/l7tech/policy/assertion/xmlsec/RequireWssSaml2
      // 0c3: dup
      // 0c4: invokespecial com/l7tech/policy/assertion/xmlsec/RequireWssSaml2.<init> ()V
      // 0c7: invokespecial com/l7tech/policy/wsp/TypedReference.<init> (Ljava/lang/Class;Ljava/lang/Object;)V
      // 0ca: astore 6
      // 0cc: goto 147
      // 0cf: getstatic com/l7tech/security/token/SecurityTokenType.WSS_USERNAME Lcom/l7tech/security/token/SecurityTokenType;
      // 0d2: aload 5
      // 0d4: invokevirtual java/lang/Object.equals (Ljava/lang/Object;)Z
      // 0d7: ifeq 0ef
      // 0da: new com/l7tech/policy/wsp/TypedReference
      // 0dd: dup
      // 0de: ldc com/l7tech/policy/assertion/credential/wss/WssBasic
      // 0e0: new com/l7tech/policy/assertion/credential/wss/WssBasic
      // 0e3: dup
      // 0e4: invokespecial com/l7tech/policy/assertion/credential/wss/WssBasic.<init> ()V
      // 0e7: invokespecial com/l7tech/policy/wsp/TypedReference.<init> (Ljava/lang/Class;Ljava/lang/Object;)V
      // 0ea: astore 6
      // 0ec: goto 147
      // 0ef: getstatic com/l7tech/security/token/SecurityTokenType.WSSC_CONTEXT Lcom/l7tech/security/token/SecurityTokenType;
      // 0f2: aload 5
      // 0f4: invokevirtual java/lang/Object.equals (Ljava/lang/Object;)Z
      // 0f7: ifeq 10f
      // 0fa: new com/l7tech/policy/wsp/TypedReference
      // 0fd: dup
      // 0fe: ldc com/l7tech/policy/assertion/xmlsec/SecureConversation
      // 100: new com/l7tech/policy/assertion/xmlsec/SecureConversation
      // 103: dup
      // 104: invokespecial com/l7tech/policy/assertion/xmlsec/SecureConversation.<init> ()V
      // 107: invokespecial com/l7tech/policy/wsp/TypedReference.<init> (Ljava/lang/Class;Ljava/lang/Object;)V
      // 10a: astore 6
      // 10c: goto 147
      // 10f: getstatic com/l7tech/security/token/SecurityTokenType.WSS_X509_BST Lcom/l7tech/security/token/SecurityTokenType;
      // 112: aload 5
      // 114: invokevirtual java/lang/Object.equals (Ljava/lang/Object;)Z
      // 117: ifeq 12f
      // 11a: new com/l7tech/policy/wsp/TypedReference
      // 11d: dup
      // 11e: ldc com/l7tech/policy/assertion/xmlsec/RequireWssX509Cert
      // 120: new com/l7tech/policy/assertion/xmlsec/RequireWssX509Cert
      // 123: dup
      // 124: invokespecial com/l7tech/policy/assertion/xmlsec/RequireWssX509Cert.<init> ()V
      // 127: invokespecial com/l7tech/policy/wsp/TypedReference.<init> (Ljava/lang/Class;Ljava/lang/Object;)V
      // 12a: astore 6
      // 12c: goto 147
      // 12f: new com/l7tech/policy/wsp/InvalidPolicyStreamException
      // 132: dup
      // 133: aload 5
      // 135: invokestatic java/lang/String.valueOf (Ljava/lang/Object;)Ljava/lang/String;
      // 138: getstatic com/l7tech/policy/wsp/l.d [Ljava/lang/String;
      // 13b: bipush 5
      // 13c: aaload
      // 13d: swap
      // 13e: 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" ]
      // 143: invokespecial com/l7tech/policy/wsp/InvalidPolicyStreamException.<init> (Ljava/lang/String;)V
      // 146: athrow
      // 147: aload 1
      // 148: aconst_null
      // 149: checkcast java/lang/String
      // 14c: aload 0
      // 14d: aload 5
      // 14f: invokevirtual com/l7tech/policy/wsp/l.getPropertiesElementName (Lcom/l7tech/security/token/SecurityTokenType;)Ljava/lang/String;
      // 152: invokestatic com/l7tech/util/DomUtils.findFirstChildElementByName (Lorg/w3c/dom/Node;Ljava/lang/String;Ljava/lang/String;)Lorg/w3c/dom/Element;
      // 155: astore 7
      // 157: aload 7
      // 159: ifnull 16c
      // 15c: aload 0
      // 15d: aload 6
      // 15f: aload 7
      // 161: aload 2
      // 162: invokespecial com/l7tech/policy/wsp/BeanTypeMapping.populateObject (Lcom/l7tech/policy/wsp/TypedReference;Lorg/w3c/dom/Element;Lcom/l7tech/policy/wsp/WspVisitor;)V
      // 165: goto 16c
      // 168: invokestatic com/l7tech/policy/wsp/l.d (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 16b: athrow
      // 16c: aload 6
      // 16e: areturn
      // try (0 -> 12): 12 com/l7tech/policy/wsp/InvalidPolicyStreamException
      // try (24 -> 33): 33 com/l7tech/policy/wsp/InvalidPolicyStreamException
      // try (40 -> 45): 46 com/l7tech/policy/wsp/InvalidPolicyStreamException
      // try (42 -> 52): 53 com/l7tech/policy/wsp/InvalidPolicyStreamException
      // try (48 -> 62): 62 com/l7tech/policy/wsp/InvalidPolicyStreamException
      // try (152 -> 159): 160 com/l7tech/policy/wsp/InvalidPolicyStreamException
   }

   static {
      String[] var5 = new String[12];
      int var3 = 0;
      String var2 = "\u00185*\t\u001a6[94k\r\u00046\u001e7>k\u0004\u00149\u001e./k\u0004\u0010s\u000f4+.K\u0003\u0001l;@:(8\u000eL\u0000\u001e..9\u0002\u0002*/\"0.\u0005V6\u0017(6.\u0005\u0002s\u0013,(k\u001e\u0018!\u001e.4,\u0005\u001f)\u001e){\u001f\u0004\u001d6\u0015\u0019\";\u000eV \u000e/>'\u000e\u001b6\u00159\u0004:(8\u000e\t\u00194 \u000e\u0018\u0007\u0002=>)\u001858\u001e\u0006#\u0014?/.\u000fV$\b>>q8\u00130\u000e?2?\u0012\"<\u0010(5k?\u00198\u001e#\u000f2\u001b\u0013s\u0004:(8\u000e6:(8\u000eL\u0000\u001e..9\u0002\u0002*/\"0.\u0005V6\u0017(6.\u0005\u0002s\u0013,(k\u0005\u0019s/\"0.\u0005\"*\u000b({8\u001e\u00146\u0017(6.\u0005\u0002\r\u001e>(\u001e\u0004:\u000f4\u000f$\u0000\u0013=\r\u001e>(\u001e\u0004:\u000f4\u000f$\u0000\u0013=";
      int var4 = "\u00185*\t\u001a6[94k\r\u00046\u001e7>k\u0004\u00149\u001e./k\u0004\u0010s\u000f4+.K\u0003\u0001l;@:(8\u000eL\u0000\u001e..9\u0002\u0002*/\"0.\u0005V6\u0017(6.\u0005\u0002s\u0013,(k\u001e\u0018!\u001e.4,\u0005\u001f)\u001e){\u001f\u0004\u001d6\u0015\u0019\";\u000eV \u000e/>'\u000e\u001b6\u00159\u0004:(8\u000e\t\u00194 \u000e\u0018\u0007\u0002=>)\u001858\u001e\u0006#\u0014?/.\u000fV$\b>>q8\u00130\u000e?2?\u0012\"<\u0010(5k?\u00198\u001e#\u000f2\u001b\u0013s\u0004:(8\u000e6:(8\u000eL\u0000\u001e..9\u0002\u0002*/\"0.\u0005V6\u0017(6.\u0005\u0002s\u0013,(k\u0005\u0019s/\"0.\u0005\"*\u000b({8\u001e\u00146\u0017(6.\u0005\u0002\r\u001e>(\u001e\u0004:\u000f4\u000f$\u0000\u0013=\r\u001e>(\u001e\u0004:\u000f4\u000f$\u0000\u0013="
         .length();
      char var1 = ' ';
      int var7 = -1;

      label24:
      while (true) {
         byte var10000 = 99;
         String var10001 = var2.substring(++var7, var7 + var1);
         byte var10002 = -1;

         while (true) {
            String var8 = d(var10000, a(var10001));
            switch (var10002) {
               case 0:
                  var5[var3++] = var8;
                  if ((var7 += var1) >= var4) {
                     d = var5;
                     c = new t();
                     return;
                  }

                  var1 = var2.charAt(var7);
                  break;
               default:
                  var5[var3++] = var8;
                  if ((var7 += var1) < var4) {
                     var1 = var2.charAt(var7);
                     continue label24;
                  }

                  var2 = "\u0013'*\u0015\u001d/\u0001*06\n\u00104(\t(<\u0007\"86";
                  var4 = "\u0013'*\u0015\u001d/\u0001*06\n\u00104(\t(<\u0007\"86".length();
                  var1 = '\n';
                  var7 = -1;
            }

            var10000 = 109;
            var10001 = var2.substring(++var7, var7 + var1);
            var10002 = 0;
         }
      }
   }

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

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

      return var10000;
   }

   private static String d(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 -> 46;
            case 1 -> 56;
            case 2 -> 40;
            case 3 -> 8;
            case 4 -> 21;
            case 5 -> 48;
            default -> 24;
         });
      }

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