/*
 * 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.ServiceResponse
 *  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.ServiceResponse;
import com.l7tech.server.message.PolicyEnforcementContext;
import com.l7tech.server.policy.assertion.ServerCustomAssertionHolder;
import com.l7tech.server.policy.assertion.p;
import com.l7tech.util.ExceptionUtils;
import java.io.IOException;
import java.util.Map;
import java.util.logging.Level;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.xml.sax.SAXException;

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

    public o(ServerCustomAssertionHolder serverCustomAssertionHolder, PolicyEnforcementContext policyEnforcementContext, Map map) throws IOException, SAXException {
        this.this$0 = serverCustomAssertionHolder;
        this.a = policyEnforcementContext;
        try {
            this.c = (Document)policyEnforcementContext.getResponse().getXmlKnob().getDocumentReadOnly().cloneNode(true);
        }
        catch (Exception exception) {
            this.c = null;
            String[] stringArray = f;
            serverCustomAssertionHolder.logger.log(Level.FINE, stringArray[1] + ExceptionUtils.getMessage((Throwable)exception), ExceptionUtils.getDebugException((Throwable)exception));
        }
        try {
            this.d = (Document)policyEnforcementContext.getRequest().getXmlKnob().getDocumentReadOnly().cloneNode(true);
        }
        catch (Exception exception) {
            this.d = null;
            serverCustomAssertionHolder.logger.log(Level.FINE, f[2] + ExceptionUtils.getMessage((Throwable)exception), ExceptionUtils.getDebugException((Throwable)exception));
        }
        this.b = map;
        this.e = new p(this, serverCustomAssertionHolder);
    }

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

    public Document getRequestDocument() {
        return this.d;
    }

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

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

    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[4];
                var3_1 = 0;
                var2_2 = "\u0017\nQ%G]{&\nJ$R\u0004n;\u0016DjQ\u0012k'\u0015F$A\u0019\u0011\u0019M$Z\t(5\u001dWjG\u0018{\"\u0017M9P]p?\u0014\u0019j";
                var4_3 = "\u0017\nQ%G]{&\nJ$R\u0004n;\u0016DjQ\u0012k'\u0015F$A\u0019\u0011\u0019M$Z\t(5\u001dWjG\u0018{\"\u0017M9P]p?\u0014\u0019j".length();
                var1_4 = 26;
                var0_5 = -1;
lbl7:
                // 2 sources

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

                while (true) {
                    var5[var3_1++] = o.a(v0, o.a(v2));
                    if ((var0_5 += var1_4) < var4_3) {
                        var1_4 = var2_2.charAt(var0_5);
                        ** continue;
                    }
                    var2_2 = "08l\u0005{(\t\u0014<vKf9Z\u00036l\u0018q|Q\u001e58K\u001c <vK`4LS+g\u0018d3G\u0000<\"\u000f{?\\\u001e<l\u001f4(F";
                    var4_3 = "08l\u0005{(\t\u0014<vKf9Z\u00036l\u0018q|Q\u001e58K\u001c <vK`4LS+g\u0018d3G\u0000<\"\u000f{?\\\u001e<l\u001f4(F".length();
                    var1_4 = 25;
                    var0_5 = -1;
lbl22:
                    // 2 sources

                    while (true) {
                        v0 = 126;
                        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++] = o.a(v0, o.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;
            }
        }
        o.f = var5;
    }

    private static char[] a(String string) {
        char[] cArray = string.toCharArray();
        if (cArray.length < 2) {
            cArray = cArray;
            cArray[0] = (char)(cArray[0] ^ 0x57);
        }
        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 -> 13;
                    case 1 -> 39;
                    case 2 -> 124;
                    case 3 -> 21;
                    case 4 -> 106;
                    case 5 -> 34;
                    default -> 87;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }
}

