/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.l7tech.common.io.XmlUtil
 *  com.l7tech.message.XmlKnob
 *  com.l7tech.policy.assertion.ext.SecurityContext
 *  com.l7tech.policy.assertion.ext.ServiceRequest
 *  com.l7tech.util.ExceptionUtils
 */
package com.l7tech.server.policy.assertion;

import com.l7tech.common.io.XmlUtil;
import com.l7tech.message.XmlKnob;
import com.l7tech.policy.assertion.ext.SecurityContext;
import com.l7tech.policy.assertion.ext.ServiceRequest;
import com.l7tech.server.message.PolicyEnforcementContext;
import com.l7tech.server.policy.assertion.ServerCustomAssertionHolder;
import com.l7tech.server.policy.assertion.n;
import com.l7tech.util.ExceptionUtils;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Map;
import java.util.Vector;
import java.util.logging.Level;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.xml.sax.SAXException;

class m
implements ServiceRequest {
    private final PolicyEnforcementContext a;
    private final Map b;
    private Document c;
    private final SecurityContext d;
    final ServerCustomAssertionHolder this$0;
    private static final String[] e;

    public m(ServerCustomAssertionHolder serverCustomAssertionHolder, PolicyEnforcementContext policyEnforcementContext, Map map) throws IOException, SAXException {
        String[] stringArray;
        this.this$0 = serverCustomAssertionHolder;
        this.a = policyEnforcementContext;
        try {
            this.c = (Document)policyEnforcementContext.getRequest().getXmlKnob().getDocumentReadOnly().cloneNode(true);
        }
        catch (Exception exception) {
            stringArray = e;
            serverCustomAssertionHolder.logger.log(Level.FINE, stringArray[2] + ExceptionUtils.getMessage((Throwable)exception), ExceptionUtils.getDebugException((Throwable)exception));
            this.c = null;
        }
        this.b = map;
        Vector vector = serverCustomAssertionHolder.a(policyEnforcementContext.getRequest().getHttpCookiesKnob().getCookies());
        stringArray = e;
        this.b.put(stringArray[0], vector);
        this.b.put(stringArray[4], Collections.unmodifiableCollection(new ArrayList(vector)));
        this.d = new n(this, serverCustomAssertionHolder);
    }

    public Document getDocument() {
        return this.c;
    }

    public void setDocument(Document document) {
        block6: {
            XmlKnob xmlKnob;
            block5: {
                xmlKnob = (XmlKnob)this.a.getRequest().getKnob(XmlKnob.class);
                try {
                    if (xmlKnob != null) break block5;
                    this.a.getRequest().initialize(document);
                    break block6;
                }
                catch (IOException iOException) {
                    throw m.a(iOException);
                }
            }
            xmlKnob.setDocument(document);
        }
        try {
            if (this.this$0.logger.isLoggable(Level.FINE)) {
                String string = XmlUtil.nodeToString((Node)document);
                String[] stringArray = e;
                this.this$0.logger.fine(stringArray[3] + string);
            }
        }
        catch (IOException iOException) {
            this.this$0.logger.log(Level.WARNING, e[1], iOException);
        }
    }

    public SecurityContext getSecurityContext() {
        return this.d;
    }

    public Map getContext() {
        return this.b;
    }

    public Object getVariable(String string) {
        return this.this$0.a(this.a, string);
    }

    public void setVariable(String string, Object object) {
        this.this$0.a(this.a, string, object);
    }

    private static IOException a(IOException iOException) {
        return iOException;
    }

    /*
     * Unable to fully structure code
     */
    static {
        block10: {
            block9: {
                var5 = new String[5];
                var3_1 = 0;
                var2_2 = "B\u001ai9D+it\u0005b3Y+~\u001ar\u0018\u007f7Bn~C\u0018d6W7k^\u0004jxT!nB\u0007h6D\u001dc\u0002d+\u0010<hF\u001fh+Dn`V\u0013-6_:-U\u000f-\u0000}\u00027\u0017";
                var4_3 = "B\u001ai9D+it\u0005b3Y+~\u001ar\u0018\u007f7Bn~C\u0018d6W7k^\u0004jxT!nB\u0007h6D\u001dc\u0002d+\u0010<hF\u001fh+Dn`V\u0013-6_:-U\u000f-\u0000}\u00027\u0017".length();
                var1_4 = 14;
                var0_5 = -1;
lbl7:
                // 2 sources

                while (true) {
                    v0 = 18;
                    v1 = ++var0_5;
                    v2 = var2_2.substring(v1, v1 + var1_4);
                    v3 = -1;
                    break block9;
                    break;
                }
lbl13:
                // 1 sources

                while (true) {
                    var5[var3_1++] = m.a(v0, m.a(v2));
                    if ((var0_5 += var1_4) < var4_3) {
                        var1_4 = var2_2.charAt(var0_5);
                        ** continue;
                    }
                    var2_2 = "`\u000b}|@\"l\u0013\u001cl-A/zGNm3W?dV\u0000}|@%\u000f\\\u001c`;]$h_-f3_#l@";
                    var4_3 = "`\u000b}|@\"l\u0013\u001cl-A/zGNm3W?dV\u0000}|@%\u000f\\\u001c`;]$h_-f3_#l@".length();
                    var1_4 = 27;
                    var0_5 = -1;
lbl22:
                    // 2 sources

                    while (true) {
                        v0 = 22;
                        v4 = ++var0_5;
                        v2 = var2_2.substring(v4, v4 + var1_4);
                        v3 = 0;
                        break block9;
                        break;
                    }
                    break;
                }
lbl28:
                // 1 sources

                while (true) {
                    var5[var3_1++] = m.a(v0, m.a(v2));
                    if ((var0_5 += var1_4) < var4_3) {
                        var1_4 = var2_2.charAt(var0_5);
                        ** continue;
                    }
                    break block10;
                    break;
                }
            }
            switch (v3) {
                default: {
                    ** continue;
                }
                ** case 0:
lbl39:
                // 1 sources

                ** continue;
            }
        }
        m.e = var5;
    }

    private static char[] a(String string) {
        char[] cArray = string.toCharArray();
        if (cArray.length < 2) {
            cArray = cArray;
            cArray[0] = (char)(cArray[0] ^ 0x1F);
        }
        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 -> 37;
                    case 1 -> 120;
                    case 2 -> 31;
                    case 3 -> 74;
                    case 4 -> 34;
                    case 5 -> 92;
                    default -> 31;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }
}

