/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.l7tech.gateway.common.service.PublishedService
 *  com.l7tech.message.Message
 *  com.l7tech.policy.assertion.AssertionStatus
 *  com.l7tech.policy.variable.NoSuchVariableException
 */
package com.l7tech.server.trace;

import com.l7tech.gateway.common.service.PublishedService;
import com.l7tech.message.Message;
import com.l7tech.policy.assertion.AssertionStatus;
import com.l7tech.policy.variable.NoSuchVariableException;
import com.l7tech.server.message.HasOriginalContext;
import com.l7tech.server.message.PolicyEnforcementContext;
import com.l7tech.server.message.PolicyEnforcementContextFactory;
import com.l7tech.server.message.PolicyEnforcementContextWrapper;
import com.l7tech.server.message.metrics.LatencyMetrics;
import com.l7tech.server.policy.assertion.ServerAssertion;
import java.util.logging.Level;

public class TracePolicyEnforcementContext
extends PolicyEnforcementContextWrapper
implements HasOriginalContext {
    private final PolicyEnforcementContext b;
    private ServerAssertion c;
    private AssertionStatus d;
    private Object e;
    private LatencyMetrics f;
    private static final String h = TracePolicyEnforcementContext.b(29, TracePolicyEnforcementContext.c("40aN1{U\u000e\u0015/N&hX\nY\u007fU8`X\u0016Y\u007fI1|_\u0000T|_&\u007fR\f\u001cR"));

    public TracePolicyEnforcementContext(PolicyEnforcementContext policyEnforcementContext) {
        super(PolicyEnforcementContextFactory.createUnregisteredPolicyEnforcementContext(null, null, true));
        this.b = policyEnforcementContext;
        PublishedService publishedService = new PublishedService();
        publishedService.setName(h);
        publishedService.setSoap(false);
        this.setService(publishedService);
    }

    @Override
    public Message getOriginalRequest() {
        return this.b.getRequest();
    }

    @Override
    public Message getOriginalResponse() {
        return this.b.getResponse();
    }

    @Override
    public Object getOriginalContextVariable(String string) throws NoSuchVariableException {
        return this.b.getVariable(string);
    }

    @Override
    public PolicyEnforcementContext getOriginalContext() {
        return this.b;
    }

    @Override
    public void setAuditLevel(Level level) {
        this.b.setAuditLevel(level);
    }

    @Override
    public Level getAuditLevel() {
        return this.b.getAuditLevel();
    }

    @Override
    public boolean isAuditSaveRequest() {
        return this.b.isAuditSaveRequest();
    }

    @Override
    public void setAuditSaveRequest(boolean bl2) {
        this.b.setAuditSaveRequest(bl2);
    }

    @Override
    public boolean isAuditSaveResponse() {
        return this.b.isAuditSaveResponse();
    }

    @Override
    public void setAuditSaveResponse(boolean bl2) {
        this.b.setAuditSaveResponse(bl2);
    }

    public boolean isFinalInvocation() {
        return this.c != null && this.c.getAssertion() != null && this.b.getAssertionOrdinalPath().isEmpty() && this.c.getAssertion().getParent() == null;
    }

    public ServerAssertion getTracedAssertion() {
        return this.c;
    }

    public void setTracedAssertion(ServerAssertion serverAssertion) {
        this.c = serverAssertion;
    }

    public AssertionStatus getTracedStatus() {
        return this.d;
    }

    public void setTracedStatus(AssertionStatus assertionStatus) {
        this.d = assertionStatus;
    }

    public Object getTraceOut() {
        return this.e;
    }

    public void setTraceOut(Object object) {
        this.e = object;
    }

    public LatencyMetrics getTracedAssertionMetrics() {
        return this.f;
    }

    public void setTracedAssertionMetrics(LatencyMetrics latencyMetrics) {
        this.f = latencyMetrics;
    }

    private static char[] c(String string) {
        char[] cArray = string.toCharArray();
        if (cArray.length < 2) {
            cArray = cArray;
            cArray[0] = (char)(cArray[0] ^ 0x26);
        }
        return cArray;
    }

    /*
     * Handled impossible loop by duplicating code
     * Enabled aggressive block sorting
     */
    private static String b(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 -> 114;
                    case 1 -> 100;
                    case 2 -> 18;
                    case 3 -> 39;
                    case 4 -> 73;
                    case 5 -> 20;
                    default -> 38;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }
}

