/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.l7tech.common.mime.MimeBody
 *  com.l7tech.gateway.common.LicenseException
 *  com.l7tech.gateway.common.LicenseManager
 *  com.l7tech.gateway.common.audit.Audit
 *  com.l7tech.gateway.common.audit.AuditDetailMessage
 *  com.l7tech.gateway.common.audit.AuditDetailMessage$Hint
 *  com.l7tech.gateway.common.audit.MessageProcessingMessages
 *  com.l7tech.gateway.common.service.PublishedService
 *  com.l7tech.gateway.common.service.PublishedService$ServiceException
 *  com.l7tech.gateway.common.service.ServiceStatistics
 *  com.l7tech.objectmodel.Goid
 *  com.l7tech.policy.assertion.AssertionStatus
 *  com.l7tech.policy.assertion.PolicyAssertionException
 *  com.l7tech.policy.assertion.RoutingStatus
 *  com.l7tech.policy.variable.VariableNameSyntaxException
 *  com.l7tech.security.xml.SecurityTokenResolver
 *  com.l7tech.security.xml.decorator.WssDecorator
 *  com.l7tech.security.xml.processor.SecurityContextFinder
 *  com.l7tech.util.Background
 *  com.l7tech.util.Config
 *  com.l7tech.util.ExceptionUtils
 *  com.l7tech.util.InvalidDocumentFormatException
 *  com.l7tech.util.Pair
 *  com.l7tech.util.ResourceUtils
 *  jakarta.inject.Inject
 *  jakarta.inject.Named
 *  javax.wsdl.Binding
 *  javax.wsdl.Operation
 *  javax.wsdl.WSDLException
 *  org.springframework.beans.factory.InitializingBean
 *  org.springframework.context.ApplicationEvent
 *  org.springframework.context.ApplicationEventPublisher
 *  org.springframework.context.support.ApplicationObjectSupport
 */
package com.l7tech.server;

import com.l7tech.common.mime.MimeBody;
import com.l7tech.gateway.common.LicenseException;
import com.l7tech.gateway.common.LicenseManager;
import com.l7tech.gateway.common.audit.Audit;
import com.l7tech.gateway.common.audit.AuditDetailMessage;
import com.l7tech.gateway.common.audit.MessageProcessingMessages;
import com.l7tech.gateway.common.service.PublishedService;
import com.l7tech.gateway.common.service.ServiceStatistics;
import com.l7tech.objectmodel.Goid;
import com.l7tech.policy.assertion.AssertionStatus;
import com.l7tech.policy.assertion.PolicyAssertionException;
import com.l7tech.policy.assertion.RoutingStatus;
import com.l7tech.policy.variable.VariableNameSyntaxException;
import com.l7tech.security.xml.SecurityTokenResolver;
import com.l7tech.security.xml.decorator.WssDecorator;
import com.l7tech.security.xml.processor.SecurityContextFinder;
import com.l7tech.server.MessageProcessingSuspendedException;
import com.l7tech.server.MessageProcessorMediator;
import com.l7tech.server.MessageProcessorMediatorFactory;
import com.l7tech.server.MethodNotAllowedException;
import com.l7tech.server.TrafficMonitor;
import com.l7tech.server.as;
import com.l7tech.server.at;
import com.l7tech.server.au;
import com.l7tech.server.audit.AuditContext;
import com.l7tech.server.audit.AuditContextFactory;
import com.l7tech.server.audit.AuditLogFormatter;
import com.l7tech.server.audit.Auditor;
import com.l7tech.server.audit.MessageSummaryAuditFactory;
import com.l7tech.server.av;
import com.l7tech.server.b6;
import com.l7tech.server.cluster.ServiceUsageManager;
import com.l7tech.server.event.MessageProcessed;
import com.l7tech.server.event.MessageReceived;
import com.l7tech.server.log.TrafficLogger;
import com.l7tech.server.message.PolicyEnforcementContext;
import com.l7tech.server.message.metrics.GatewayMetricsPublisher;
import com.l7tech.server.message.metrics.GatewayMetricsUtils;
import com.l7tech.server.message.metrics.LatencyMetrics;
import com.l7tech.server.messageprocessor.injection.MessageProcessorInjector;
import com.l7tech.server.policy.PolicyCache;
import com.l7tech.server.policy.PolicyVersionException;
import com.l7tech.server.service.ServiceCache;
import com.l7tech.server.service.ServiceMetricsServices;
import com.l7tech.server.service.resolution.ServiceResolutionException;
import com.l7tech.server.stepdebug.DebugManager;
import com.l7tech.server.util.EventChannel;
import com.l7tech.util.Background;
import com.l7tech.util.Config;
import com.l7tech.util.ExceptionUtils;
import com.l7tech.util.InvalidDocumentFormatException;
import com.l7tech.util.Pair;
import com.l7tech.util.ResourceUtils;
import jakarta.inject.Inject;
import jakarta.inject.Named;
import java.io.Closeable;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Set;
import java.util.TimerTask;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.wsdl.Binding;
import javax.wsdl.Operation;
import javax.wsdl.WSDLException;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.support.ApplicationObjectSupport;
import org.xml.sax.SAXException;

public class MessageProcessor
extends ApplicationObjectSupport
implements InitializingBean {
    private static final int a = 7937;
    private static final boolean b = true;
    private final ServiceCache c;
    private final PolicyCache d;
    private final WssDecorator e;
    private final SecurityTokenResolver f;
    private final SecurityContextFinder g;
    private final LicenseManager h;
    private final ServiceMetricsServices i;
    private final MessageProcessorInjector j;
    private final AuditContextFactory k;
    private final MessageSummaryAuditFactory l;
    private final Config m;
    private final TrafficLogger n;
    private final ArrayList<TrafficMonitor> o = new ArrayList();
    private final AtomicReference<av> p = new AtomicReference();
    private final ApplicationEventPublisher q;
    private final AtomicBoolean r = new AtomicBoolean(true);
    private final ServiceUsageManager s;
    private final MessageProcessorMediatorFactory t;
    @Inject
    @Named(value="debugManager")
    DebugManager debugManager;
    @Inject
    @Named(value="gatewayMetricsPublisher")
    GatewayMetricsPublisher gatewayMetricsEventsPublisher;
    private static final Level u;
    private static final AuditDetailMessage.Hint v;
    private static final AuditDetailMessage.Hint w;
    private Auditor x;
    final Logger y = Logger.getLogger(((Object)((Object)this)).getClass().getName());
    private static final String[] z;

    public MessageProcessor(ServiceCache serviceCache, PolicyCache policyCache, WssDecorator wssDecorator, SecurityTokenResolver securityTokenResolver, SecurityContextFinder securityContextFinder, LicenseManager licenseManager, ServiceMetricsServices serviceMetricsServices, AuditContextFactory auditContextFactory, MessageSummaryAuditFactory messageSummaryAuditFactory, MessageProcessorInjector messageProcessorInjector, Config config, TrafficLogger trafficLogger, ServiceUsageManager serviceUsageManager, MessageProcessorMediatorFactory messageProcessorMediatorFactory, ApplicationEventPublisher applicationEventPublisher) throws IllegalArgumentException {
        if (serviceCache == null) {
            String[] stringArray = z;
            throw new IllegalArgumentException(stringArray[16]);
        }
        try {
            if (policyCache == null) {
                throw new IllegalArgumentException(z[20]);
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw MessageProcessor.a(illegalArgumentException);
        }
        try {
            if (wssDecorator == null) {
                throw new IllegalArgumentException(z[25]);
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw MessageProcessor.a(illegalArgumentException);
        }
        try {
            if (licenseManager == null) {
                throw new IllegalArgumentException(z[29]);
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw MessageProcessor.a(illegalArgumentException);
        }
        try {
            if (serviceMetricsServices == null) {
                throw new IllegalArgumentException(z[23]);
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw MessageProcessor.a(illegalArgumentException);
        }
        try {
            if (auditContextFactory == null) {
                throw new IllegalArgumentException(z[1]);
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw MessageProcessor.a(illegalArgumentException);
        }
        try {
            if (config == null) {
                throw new IllegalArgumentException(z[24]);
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw MessageProcessor.a(illegalArgumentException);
        }
        try {
            if (trafficLogger == null) {
                throw new IllegalArgumentException(z[10]);
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw MessageProcessor.a(illegalArgumentException);
        }
        if (applicationEventPublisher == null) {
            applicationEventPublisher = new EventChannel();
        }
        try {
            if (messageProcessorInjector == null) {
                throw new IllegalArgumentException(z[26]);
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw MessageProcessor.a(illegalArgumentException);
        }
        try {
            if (serviceUsageManager == null) {
                throw new IllegalArgumentException(z[31]);
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw MessageProcessor.a(illegalArgumentException);
        }
        try {
            if (messageProcessorMediatorFactory == null) {
                throw new IllegalArgumentException(z[30]);
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw MessageProcessor.a(illegalArgumentException);
        }
        this.c = serviceCache;
        this.d = policyCache;
        this.e = wssDecorator;
        this.f = securityTokenResolver;
        this.g = securityContextFinder;
        this.h = licenseManager;
        this.i = serviceMetricsServices;
        this.k = auditContextFactory;
        this.l = messageSummaryAuditFactory;
        this.j = messageProcessorInjector;
        this.m = config;
        this.n = trafficLogger;
        this.s = serviceUsageManager;
        this.q = applicationEventPublisher;
        this.t = messageProcessorMediatorFactory;
        this.a(7937);
    }

    private void a(int n2) {
        this.b(n2);
        Background.scheduleRepeated((TimerTask)new b6(this, n2), (long)n2, (long)n2);
    }

    private void b(int n2) {
        String[] stringArray = z;
        long l2 = this.m.getLongProperty(stringArray[14], 0x280000L);
        MimeBody.setFirstPartMaxBytes((long)l2);
        this.p.set(new av(this.m.getLongProperty(stringArray[13], 0L), this.m.getBooleanProperty(stringArray[15], true), this.m.getBooleanProperty(stringArray[2], false), this.m.getBooleanProperty(stringArray[7], false), this.m.getBooleanProperty(stringArray[5], true)));
        this.r.set(this.m.getBooleanProperty(stringArray[27], true));
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     * Loose catch block
     */
    public AssertionStatus processMessageNoAudit(PolicyEnforcementContext policyEnforcementContext) throws IOException, PolicyAssertionException, PolicyVersionException, LicenseException, MethodNotAllowedException, MessageProcessingSuspendedException {
        AssertionStatus assertionStatus;
        MessageProcessorMediator messageProcessorMediator;
        AssertionStatus assertionStatus2;
        block10: {
            AuditContext auditContext = AuditContextFactory.getCurrent();
            policyEnforcementContext.setAuditContext(auditContext);
            assertionStatus2 = AssertionStatus.UNDEFINED;
            messageProcessorMediator = this.t.createMessageProcessorMediator();
            messageProcessorMediator.processMessageStart(policyEnforcementContext);
            try {
                assertionStatus2 = this.a(policyEnforcementContext, messageProcessorMediator);
                messageProcessorMediator.processMessagePostReallyProcessMessage(assertionStatus2);
                assertionStatus = assertionStatus2;
                this.a(policyEnforcementContext, assertionStatus2, messageProcessorMediator);
            }
            catch (Throwable throwable) {
                block11: {
                    this.a(policyEnforcementContext, assertionStatus2, messageProcessorMediator);
                    String[] stringArray = AuditLogFormatter.getContextVariablesUsed();
                    try {
                        try {
                            if (stringArray == null || stringArray.length <= 0) break block11;
                        }
                        catch (IOException iOException) {
                            throw MessageProcessor.a(iOException);
                        }
                        auditContext.setContextVariables(policyEnforcementContext.getVariableMap(stringArray, (Audit)this.x));
                    }
                    catch (IOException iOException) {
                        throw MessageProcessor.a(iOException);
                    }
                }
                messageProcessorMediator.processMessageFinally(policyEnforcementContext, assertionStatus2);
                throw throwable;
            }
            String[] stringArray = AuditLogFormatter.getContextVariablesUsed();
            if (stringArray == null) break block10;
            try {
                block12: {
                    if (stringArray.length <= 0) break block10;
                    break block12;
                    catch (IOException iOException) {
                        throw MessageProcessor.a(iOException);
                    }
                }
                auditContext.setContextVariables(policyEnforcementContext.getVariableMap(stringArray, (Audit)this.x));
            }
            catch (IOException iOException) {
                throw MessageProcessor.a(iOException);
            }
        }
        messageProcessorMediator.processMessageFinally(policyEnforcementContext, assertionStatus2);
        return assertionStatus;
    }

    public AssertionStatus processMessage(PolicyEnforcementContext policyEnforcementContext) throws IOException, PolicyAssertionException, PolicyVersionException, LicenseException, MethodNotAllowedException, MessageProcessingSuspendedException {
        MessageProcessorMediator messageProcessorMediator = this.t.createMessageProcessorMediator();
        messageProcessorMediator.processMessageStart(policyEnforcementContext);
        AssertionStatus[] assertionStatusArray = new AssertionStatus[]{AssertionStatus.UNDEFINED};
        try {
            AssertionStatus assertionStatus = this.k.doWithNewAuditContext(new as(this, policyEnforcementContext, assertionStatusArray, messageProcessorMediator), new at(this, policyEnforcementContext, assertionStatusArray));
            return assertionStatus;
        }
        catch (LicenseException | PolicyAssertionException | MessageProcessingSuspendedException | MethodNotAllowedException | PolicyVersionException | IOException | RuntimeException throwable) {
            messageProcessorMediator.handleException((Exception)throwable);
            throw throwable;
        }
        catch (Exception exception) {
            messageProcessorMediator.handleException(exception);
            throw new RuntimeException(exception);
        }
        finally {
            messageProcessorMediator.processMessageFinally(policyEnforcementContext, assertionStatusArray[0]);
        }
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     */
    private AssertionStatus a(PolicyEnforcementContext policyEnforcementContext, MessageProcessorMediator messageProcessorMediator) throws IOException, PolicyAssertionException, PolicyVersionException, LicenseException, MethodNotAllowedException, MessageProcessingSuspendedException {
        GatewayMetricsPublisher gatewayMetricsPublisher;
        PolicyEnforcementContext policyEnforcementContext2;
        try {
            this.a(policyEnforcementContext);
            policyEnforcementContext2 = policyEnforcementContext;
            gatewayMetricsPublisher = this.isRelayGatewayMetricsEnable() ? this.gatewayMetricsEventsPublisher : null;
        }
        catch (PublishedService.ServiceException serviceException) {
            throw MessageProcessor.a((Exception)((Object)serviceException));
        }
        GatewayMetricsUtils.setPublisher(policyEnforcementContext2, gatewayMetricsPublisher);
        au au2 = new au(this, policyEnforcementContext);
        try {
            AssertionStatus assertionStatus = au2.a();
            return assertionStatus;
        }
        catch (PublishedService.ServiceException serviceException) {
            messageProcessorMediator.handleException((Exception)((Object)serviceException));
            this.x.logAndAudit((AuditDetailMessage)MessageProcessingMessages.EXCEPTION_SEVERE_WITH_MORE_INFO, new String[]{ExceptionUtils.getMessage((Throwable)serviceException)}, serviceException);
            policyEnforcementContext.setPolicyResult(AssertionStatus.SERVER_ERROR);
            AssertionStatus assertionStatus = AssertionStatus.SERVER_ERROR;
            return assertionStatus;
        }
        catch (ServiceResolutionException serviceResolutionException) {
            messageProcessorMediator.handleException(serviceResolutionException);
            this.x.logAndAudit((AuditDetailMessage)MessageProcessingMessages.EXCEPTION_SEVERE_WITH_MORE_INFO, new String[]{ExceptionUtils.getMessage((Throwable)serviceResolutionException)}, ExceptionUtils.getDebugException((Throwable)serviceResolutionException));
            policyEnforcementContext.setPolicyResult(AssertionStatus.SERVER_ERROR);
            AssertionStatus assertionStatus = AssertionStatus.SERVER_ERROR;
            return assertionStatus;
        }
        catch (SAXException sAXException) {
            messageProcessorMediator.handleException(sAXException);
            this.x.logAndAudit((AuditDetailMessage)MessageProcessingMessages.EXCEPTION_SEVERE_WITH_MORE_INFO, new String[]{ExceptionUtils.getMessage((Throwable)sAXException)}, sAXException);
            policyEnforcementContext.setPolicyResult(AssertionStatus.SERVER_ERROR);
            AssertionStatus assertionStatus = AssertionStatus.SERVER_ERROR;
            return assertionStatus;
        }
        catch (VariableNameSyntaxException variableNameSyntaxException) {
            messageProcessorMediator.handleException((Exception)((Object)variableNameSyntaxException));
            this.x.logAndAudit((AuditDetailMessage)MessageProcessingMessages.EXCEPTION_SEVERE_WITH_MORE_INFO, new String[]{z[11] + ExceptionUtils.getMessage((Throwable)variableNameSyntaxException)}, ExceptionUtils.getDebugException((Throwable)variableNameSyntaxException));
            policyEnforcementContext.setPolicyResult(AssertionStatus.SERVER_ERROR);
            AssertionStatus assertionStatus = AssertionStatus.SERVER_ERROR;
            return assertionStatus;
        }
        finally {
            ResourceUtils.closeQuietly((Closeable)au2);
        }
    }

    private void a(PolicyEnforcementContext policyEnforcementContext) throws LicenseException, MessageProcessingSuspendedException {
        try {
            policyEnforcementContext.setAuditLevel(u);
            this.h.requireFeature(z[19]);
            if (SuspendStatus.INSTANCE.isSuspended()) {
                this.x.logAndAudit((AuditDetailMessage)MessageProcessingMessages.EXCEPTION_WARNING_WITH_MORE_INFO, new String[]{z[6] + SuspendStatus.INSTANCE.getReason()}, (Throwable)null);
                throw new MessageProcessingSuspendedException(z[28]);
            }
        }
        catch (LicenseException licenseException) {
            throw MessageProcessor.a((Exception)((Object)licenseException));
        }
    }

    private void a(PolicyEnforcementContext policyEnforcementContext, AssertionStatus assertionStatus, MessageProcessorMediator messageProcessorMediator) {
        block13: {
            block14: {
                try {
                    try {
                        policyEnforcementContext.setEndTime();
                        if (!this.a()) break block13;
                        if (!policyEnforcementContext.isAuditSaveRequest()) break block14;
                    }
                    catch (IllegalArgumentException illegalArgumentException) {
                        throw MessageProcessor.a(illegalArgumentException);
                    }
                    if (policyEnforcementContext.isAuditSaveResponse()) break block13;
                }
                catch (IllegalArgumentException illegalArgumentException) {
                    throw MessageProcessor.a(illegalArgumentException);
                }
            }
            Set set = AuditContextFactory.getCurrent().getHints();
            try {
                if (set.contains(v)) {
                    policyEnforcementContext.setAuditSaveRequest(true);
                }
            }
            catch (IllegalArgumentException illegalArgumentException) {
                throw MessageProcessor.a(illegalArgumentException);
            }
            try {
                if (set.contains(w)) {
                    policyEnforcementContext.setAuditSaveResponse(true);
                }
            }
            catch (IllegalArgumentException illegalArgumentException) {
                throw MessageProcessor.a(illegalArgumentException);
            }
        }
        assertionStatus = this.c(policyEnforcementContext, assertionStatus);
        try {
            if (policyEnforcementContext.getPolicyResult() == null) {
                policyEnforcementContext.setPolicyResult(assertionStatus);
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw MessageProcessor.a(illegalArgumentException);
        }
        this.c(policyEnforcementContext);
        messageProcessorMediator.doRequestPostProcessing(policyEnforcementContext, this.f(policyEnforcementContext), this.x);
        this.b(policyEnforcementContext, assertionStatus);
        GatewayMetricsUtils.publishServiceFinish(policyEnforcementContext, new LatencyMetrics(policyEnforcementContext.getStartTime(), policyEnforcementContext.getEndTime()));
        this.a(policyEnforcementContext, assertionStatus);
        this.n.log(policyEnforcementContext);
    }

    private void a(PolicyEnforcementContext policyEnforcementContext, AssertionStatus assertionStatus) {
        try {
            this.q.publishEvent((ApplicationEvent)new MessageProcessed(policyEnforcementContext, assertionStatus, this));
        }
        catch (Throwable throwable) {
            this.x.logAndAudit((AuditDetailMessage)MessageProcessingMessages.EVENT_MANAGER_EXCEPTION, null, throwable);
        }
    }

    private void b(PolicyEnforcementContext policyEnforcementContext) {
        try {
            this.q.publishEvent((ApplicationEvent)new MessageReceived((Object)this, policyEnforcementContext));
        }
        catch (Throwable throwable) {
            this.x.logAndAudit((AuditDetailMessage)MessageProcessingMessages.EVENT_MANAGER_EXCEPTION, null, throwable);
        }
    }

    private void b(PolicyEnforcementContext policyEnforcementContext, AssertionStatus assertionStatus) {
        for (TrafficMonitor trafficMonitor : this.o) {
            trafficMonitor.recordTransactionStatus(policyEnforcementContext, assertionStatus, policyEnforcementContext.getEndTime() - policyEnforcementContext.getStartTime());
        }
    }

    private AssertionStatus c(PolicyEnforcementContext policyEnforcementContext, AssertionStatus assertionStatus) {
        block16: {
            RoutingStatus routingStatus;
            block13: {
                block15: {
                    routingStatus = policyEnforcementContext.getRoutingStatus();
                    try {
                        block14: {
                            try {
                                try {
                                    if (assertionStatus != AssertionStatus.NONE) break block13;
                                    if (routingStatus == RoutingStatus.ROUTED) break block14;
                                }
                                catch (IllegalArgumentException illegalArgumentException) {
                                    throw MessageProcessor.a(illegalArgumentException);
                                }
                                if (routingStatus != RoutingStatus.NONE) break block15;
                            }
                            catch (IllegalArgumentException illegalArgumentException) {
                                throw MessageProcessor.a(illegalArgumentException);
                            }
                        }
                        this.x.logAndAudit((AuditDetailMessage)MessageProcessingMessages.COMPLETION_STATUS, String.valueOf(assertionStatus.getNumeric()), assertionStatus.getMessage());
                        break block16;
                    }
                    catch (IllegalArgumentException illegalArgumentException) {
                        throw MessageProcessor.a(illegalArgumentException);
                    }
                }
                this.x.logAndAudit((AuditDetailMessage)MessageProcessingMessages.SERVER_ERROR);
                assertionStatus = AssertionStatus.SERVER_ERROR;
                break block16;
            }
            if (routingStatus == RoutingStatus.ATTEMPTED) {
                this.x.logAndAudit((AuditDetailMessage)MessageProcessingMessages.ROUTING_FAILED, String.valueOf(assertionStatus.getNumeric()), assertionStatus.getMessage());
                assertionStatus = AssertionStatus.FAILED;
            } else {
                Object object;
                if (this.b()) {
                    object = policyEnforcementContext.getSeenAssertionStatus();
                    Level level = this.a((Set<AssertionStatus>)object);
                    try {
                        if (level.intValue() > policyEnforcementContext.getAuditLevel().intValue()) {
                            policyEnforcementContext.setAuditLevel(level);
                        }
                    }
                    catch (IllegalArgumentException illegalArgumentException) {
                        throw MessageProcessor.a(illegalArgumentException);
                    }
                }
                object = "";
                if (policyEnforcementContext.getService() != null) {
                    object = policyEnforcementContext.getService().getName() + z[32] + String.valueOf(policyEnforcementContext.getService().getGoid()) + "]";
                }
                this.x.logAndAudit((AuditDetailMessage)MessageProcessingMessages.POLICY_EVALUATION_RESULT, new String[]{object, String.valueOf(assertionStatus.getNumeric()), assertionStatus.getMessage()});
            }
        }
        return assertionStatus;
    }

    private void c(PolicyEnforcementContext policyEnforcementContext) {
        this.e(policyEnforcementContext);
        this.d(policyEnforcementContext);
    }

    private void d(PolicyEnforcementContext policyEnforcementContext) {
        block4: {
            Goid goid;
            try {
                if (!policyEnforcementContext.isPolicyExecutionAttempted() || !this.i.isEnabled()) break block4;
            }
            catch (IllegalArgumentException illegalArgumentException) {
                throw MessageProcessor.a(illegalArgumentException);
            }
            int n2 = (int)(policyEnforcementContext.getEndTime() - policyEnforcementContext.getStartTime());
            int n3 = (int)policyEnforcementContext.getRoutingTotalTime();
            try {
                goid = policyEnforcementContext.getService() == null ? PublishedService.DEFAULT_GOID : policyEnforcementContext.getService().getGoid();
            }
            catch (IllegalArgumentException illegalArgumentException) {
                throw MessageProcessor.a(illegalArgumentException);
            }
            Goid goid2 = goid;
            this.i.addRequest(goid2, this.f(policyEnforcementContext), policyEnforcementContext.getDefaultAuthenticationContext().getLastAuthenticatedUser(), policyEnforcementContext.getMappings(), policyEnforcementContext.isAuthorizedRequest(), policyEnforcementContext.isCompletedRequest(), n2, n3);
        }
    }

    private void e(PolicyEnforcementContext policyEnforcementContext) {
        block9: {
            try {
                if (!this.s.isEnabled()) {
                    return;
                }
            }
            catch (IllegalArgumentException illegalArgumentException) {
                throw MessageProcessor.a(illegalArgumentException);
            }
            PublishedService publishedService = policyEnforcementContext.getService();
            try {
                if (publishedService == null || !policyEnforcementContext.isPolicyExecutionAttempted()) break block9;
            }
            catch (IllegalArgumentException illegalArgumentException) {
                throw MessageProcessor.a(illegalArgumentException);
            }
            ServiceStatistics serviceStatistics = this.c.getServiceStatistics(publishedService.getGoid());
            try {
                try {
                    serviceStatistics.attemptedRequest();
                    if (!policyEnforcementContext.isAuthorizedRequest()) break block9;
                    serviceStatistics.authorizedRequest();
                    if (!policyEnforcementContext.isCompletedRequest()) break block9;
                }
                catch (IllegalArgumentException illegalArgumentException) {
                    throw MessageProcessor.a(illegalArgumentException);
                }
                serviceStatistics.completedRequest();
            }
            catch (IllegalArgumentException illegalArgumentException) {
                throw MessageProcessor.a(illegalArgumentException);
            }
        }
    }

    public void registerTrafficMonitorCallback(TrafficMonitor trafficMonitor) {
        try {
            if (!this.o.contains(trafficMonitor)) {
                this.o.add(trafficMonitor);
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw MessageProcessor.a(illegalArgumentException);
        }
    }

    private String f(PolicyEnforcementContext policyEnforcementContext) {
        String string = null;
        try {
            Pair<Binding, Operation> pair = policyEnforcementContext.getBindingAndOperation();
            if (pair != null) {
                Operation operation = (Operation)pair.right;
                string = operation.getName();
            }
        }
        catch (IOException iOException) {
            String[] stringArray = z;
            this.y.log(Level.INFO, stringArray[22] + ExceptionUtils.getMessage((Throwable)iOException) + stringArray[0], ExceptionUtils.getDebugException((Throwable)iOException));
        }
        catch (SAXException sAXException) {
            String[] stringArray = z;
            this.y.log(Level.INFO, stringArray[17] + ExceptionUtils.getMessage((Throwable)sAXException) + stringArray[21], ExceptionUtils.getDebugException((Throwable)sAXException));
        }
        catch (WSDLException wSDLException) {
            String[] stringArray = z;
            this.y.log(Level.INFO, stringArray[17] + ExceptionUtils.getMessage((Throwable)wSDLException) + stringArray[21], ExceptionUtils.getDebugException((Throwable)wSDLException));
        }
        catch (InvalidDocumentFormatException invalidDocumentFormatException) {
            String[] stringArray = z;
            this.y.log(Level.INFO, stringArray[17] + ExceptionUtils.getMessage((Throwable)invalidDocumentFormatException) + stringArray[21], ExceptionUtils.getDebugException((Throwable)invalidDocumentFormatException));
        }
        return string;
    }

    public void afterPropertiesSet() throws Exception {
        try {
            if (this.debugManager == null) {
                throw new IllegalArgumentException(z[8]);
            }
        }
        catch (Exception exception) {
            throw MessageProcessor.a(exception);
        }
        try {
            if (this.gatewayMetricsEventsPublisher == null) {
                throw new IllegalArgumentException(z[3]);
            }
        }
        catch (Exception exception) {
            throw MessageProcessor.a(exception);
        }
        this.x = new Auditor((Object)this, this.getApplicationContext(), this.y);
    }

    private Level a(Set<AssertionStatus> set) {
        Level level = Level.ALL;
        for (AssertionStatus assertionStatus : set) {
            if (assertionStatus.getLevel().intValue() <= level.intValue()) continue;
            level = assertionStatus.getLevel();
        }
        return level;
    }

    private boolean a() {
        return this.m.getBooleanProperty(z[18], false);
    }

    private boolean b() {
        return this.m.getBooleanProperty(z[12], false);
    }

    public boolean isRelayGatewayMetricsEnable() {
        return this.r.get();
    }

    /*
     * Unable to fully structure code
     */
    static {
        block10: {
            block9: {
                var5 = new String[33];
                var3_1 = 0;
                var2_2 = "Vs\u001f\u0010(\u000fBJ2\u0019\u001f)\u000eSJ7\u0017\u0012)\u0004YGQ\u001f\u0002}\u0019NO\u0004\u001f\u00038\u000f.\u0006.\u0018\u0005N\u0003\u0019\u00128\u0018XQ\u0003X\u00101\u0007DI<\u0003\u001d)\u0002[R\u0014\"\u00180\u000eXJ\u0010\u001b\u0001\u000e\u0002LP\u0010\u0002\u0004/\u000eX+6<\u001fNI\u0010\u000f<8\u001fYW\u0012\u0005Q8\u001dNP\u0005\u0005Q-\u001eIR\u0018\u0005\u00198\u0019\u000bW\u0002V\u00038\u001a^W\u0003\u0013\u0015\u001c<8\u0018X_\u0016\u0013!/\u0004H[\u0002\u0005\u001e/EX_\u0007\u0013#8\u001a^[\u0002\u00023\u0006.\u0018\u0005N\u0003\u0019\u00128\u0018XQ\u0003X\u0002)\u0019B]\u0005%\u0018:\u0005JJ\u0004\u0004\u0014\u001e\u0004EX\u0018\u0004\u001c<\u001fBQ\u001f \u00101\u0002O_\u0005\u001f\u001e3\u001e<8\u0018X_\u0016\u0013Q-\u0019D]\u0014\u0005\u00024\u0005L\u001e\u0002\u0003\u0002-\u000eEZ\u0014\u0012K}.\u0006.\u0018\u0005N\u0003\u0019\u00128\u0018XQ\u0003X\u00101\u0007DI$\u0018\u001a3\u0004\\P3\u001f\u001f<\u0019Rm\u0014\u0015\u0004/\u0002_G%\u0019\u001a8\u0005X\u001958\t^YQ;\u00103\nL[\u0003V\u0018.KY[\u0000\u0003\u0018/\u000eO\u001d<8\u0018X_\u0016\u0013!/\u0004H[\u0002\u0005\u001e/EX_\u0007\u0013#8\u0018[Q\u001f\u0005\u0014\u001a%/\nMX\u0018\u0015Q\u0011\u0004LY\u0014\u0004Q4\u0018\u000bL\u0014\u0007\u00044\u0019NZ%<4\u0018XW\u001f\u0011Q2\u0019\u000bW\u001f\u0000\u00101\u0002O\u001e\u0012\u0019\u001f)\u000eSJQ\u0000\u0010/\u0002J\\\u001d\u0013K}\u001b\u0010(\u000fBJ0\u0005\u00028\u0019_W\u001e\u0018\")\n_K\u00023\u001f<\tG[\u0015\u001a\u00182*_J\u0010\u0015\u00190\u000eEJ\"\u001f\u00163\u000eOs\u0010\u000e3$\u001fNM\u0011\u001823FR!\u0017\u0003)&JF3\u000f\u00058\u0018\u0018\u00022\n[l\u0014\u001c\u0014>\u001ffK\u0002\u0002$3\u000fNL\u0002\u0002\u00103\u000f\u0019\"8\u0019]W\u0012\u0013Q\u001e\nHV\u0014V\u0018.KY[\u0000\u0003\u0018/\u000eO$22\u001eGZQ\u0018\u001e)KO[\u0005\u0013\u00030\u0002E[Q\u0005\u001e<\u001b\u000bQ\u0001\u0013\u0003<\u001fBQ\u001fVV\u0013\u0010(\u000fBJ9\u001f\u001f)\u0002EY4\u0018\u0010?\u0007NZ\u0018\u00028\u0019]W\u0012\u0013K\u0010\u000eXM\u0010\u0011\u0014\r\u0019D]\u0014\u0005\u00022\u0019\u0018!2\u0007B]\bV2<\bC[Q\u001f\u0002}\u0019NO\u0004\u001f\u00038\u000f\u0002Vs$22\u001eGZQ\u0018\u001e)KO[\u0005\u0013\u00030\u0002E[Q\u0005\u001e<\u001b\u000bQ\u0001\u0013\u0003<\u001fBQ\u001fVV#\"8\u0019]W\u0012\u0013Q\u0010\u000e_L\u0018\u0015\u0002}&JP\u0010\u0011\u0014/KBMQ\u0004\u0014,\u001eBL\u0014\u0012\u0019\"8\u0019][\u0003V22\u0005MW\u0016V\u0018.KY[\u0000\u0003\u0018/\u000eO\u0019&.\u0018\u000bz\u0014\u0015\u001e/\n_Q\u0003V\u0018.KY[\u0000\u0003\u0018/\u000eO&<8\u0018X_\u0016\u0013Q\r\u0019D]\u0014\u0005\u00022\u0019\u000bw\u001f\u001c\u0014>\u001fDLQ\u001f\u0002}\u0019NO\u0004\u001f\u00038\u000f\u001a\u00038\u0007JG6\u0017\u00058\u001cJG<\u0013\u0005/\u0002HM_\u0013\u001f<\tG[\u001c<8\u0018X_\u0016\u0013Q-\u0019D]\u0014\u0005\u00024\u0005L\u001e\u0002\u0003\u0002-\u000eEZ\u0014\u0012\u001b=4\bNP\u0002\u0013Q\u0010\nE_\u0016\u0013\u0003}\u0002X\u001e\u0003\u0013\u0000(\u0002Y[\u0015&4%\u001fNP\u0002\u001f\u001e3Kf[\u0015\u001f\u0010)\u0004Y\u001e7\u0017\u0012)\u0004YGQ\u001f\u0002}\u0019NO\u0004\u001f\u00038\u000f";
                var4_3 = "Vs\u001f\u0010(\u000fBJ2\u0019\u001f)\u000eSJ7\u0017\u0012)\u0004YGQ\u001f\u0002}\u0019NO\u0004\u001f\u00038\u000f.\u0006.\u0018\u0005N\u0003\u0019\u00128\u0018XQ\u0003X\u00101\u0007DI<\u0003\u001d)\u0002[R\u0014\"\u00180\u000eXJ\u0010\u001b\u0001\u000e\u0002LP\u0010\u0002\u0004/\u000eX+6<\u001fNI\u0010\u000f<8\u001fYW\u0012\u0005Q8\u001dNP\u0005\u0005Q-\u001eIR\u0018\u0005\u00198\u0019\u000bW\u0002V\u00038\u001a^W\u0003\u0013\u0015\u001c<8\u0018X_\u0016\u0013!/\u0004H[\u0002\u0005\u001e/EX_\u0007\u0013#8\u001a^[\u0002\u00023\u0006.\u0018\u0005N\u0003\u0019\u00128\u0018XQ\u0003X\u0002)\u0019B]\u0005%\u0018:\u0005JJ\u0004\u0004\u0014\u001e\u0004EX\u0018\u0004\u001c<\u001fBQ\u001f \u00101\u0002O_\u0005\u001f\u001e3\u001e<8\u0018X_\u0016\u0013Q-\u0019D]\u0014\u0005\u00024\u0005L\u001e\u0002\u0003\u0002-\u000eEZ\u0014\u0012K}.\u0006.\u0018\u0005N\u0003\u0019\u00128\u0018XQ\u0003X\u00101\u0007DI$\u0018\u001a3\u0004\\P3\u001f\u001f<\u0019Rm\u0014\u0015\u0004/\u0002_G%\u0019\u001a8\u0005X\u001958\t^YQ;\u00103\nL[\u0003V\u0018.KY[\u0000\u0003\u0018/\u000eO\u001d<8\u0018X_\u0016\u0013!/\u0004H[\u0002\u0005\u001e/EX_\u0007\u0013#8\u0018[Q\u001f\u0005\u0014\u001a%/\nMX\u0018\u0015Q\u0011\u0004LY\u0014\u0004Q4\u0018\u000bL\u0014\u0007\u00044\u0019NZ%<4\u0018XW\u001f\u0011Q2\u0019\u000bW\u001f\u0000\u00101\u0002O\u001e\u0012\u0019\u001f)\u000eSJQ\u0000\u0010/\u0002J\\\u001d\u0013K}\u001b\u0010(\u000fBJ0\u0005\u00028\u0019_W\u001e\u0018\")\n_K\u00023\u001f<\tG[\u0015\u001a\u00182*_J\u0010\u0015\u00190\u000eEJ\"\u001f\u00163\u000eOs\u0010\u000e3$\u001fNM\u0011\u001823FR!\u0017\u0003)&JF3\u000f\u00058\u0018\u0018\u00022\n[l\u0014\u001c\u0014>\u001ffK\u0002\u0002$3\u000fNL\u0002\u0002\u00103\u000f\u0019\"8\u0019]W\u0012\u0013Q\u001e\nHV\u0014V\u0018.KY[\u0000\u0003\u0018/\u000eO$22\u001eGZQ\u0018\u001e)KO[\u0005\u0013\u00030\u0002E[Q\u0005\u001e<\u001b\u000bQ\u0001\u0013\u0003<\u001fBQ\u001fVV\u0013\u0010(\u000fBJ9\u001f\u001f)\u0002EY4\u0018\u0010?\u0007NZ\u0018\u00028\u0019]W\u0012\u0013K\u0010\u000eXM\u0010\u0011\u0014\r\u0019D]\u0014\u0005\u00022\u0019\u0018!2\u0007B]\bV2<\bC[Q\u001f\u0002}\u0019NO\u0004\u001f\u00038\u000f\u0002Vs$22\u001eGZQ\u0018\u001e)KO[\u0005\u0013\u00030\u0002E[Q\u0005\u001e<\u001b\u000bQ\u0001\u0013\u0003<\u001fBQ\u001fVV#\"8\u0019]W\u0012\u0013Q\u0010\u000e_L\u0018\u0015\u0002}&JP\u0010\u0011\u0014/KBMQ\u0004\u0014,\u001eBL\u0014\u0012\u0019\"8\u0019][\u0003V22\u0005MW\u0016V\u0018.KY[\u0000\u0003\u0018/\u000eO\u0019&.\u0018\u000bz\u0014\u0015\u001e/\n_Q\u0003V\u0018.KY[\u0000\u0003\u0018/\u000eO&<8\u0018X_\u0016\u0013Q\r\u0019D]\u0014\u0005\u00022\u0019\u000bw\u001f\u001c\u0014>\u001fDLQ\u001f\u0002}\u0019NO\u0004\u001f\u00038\u000f\u001a\u00038\u0007JG6\u0017\u00058\u001cJG<\u0013\u0005/\u0002HM_\u0013\u001f<\tG[\u001c<8\u0018X_\u0016\u0013Q-\u0019D]\u0014\u0005\u00024\u0005L\u001e\u0002\u0003\u0002-\u000eEZ\u0014\u0012\u001b=4\bNP\u0002\u0013Q\u0010\nE_\u0016\u0013\u0003}\u0002X\u001e\u0003\u0013\u0000(\u0002Y[\u0015&4%\u001fNP\u0002\u001f\u001e3Kf[\u0015\u001f\u0010)\u0004Y\u001e7\u0017\u0012)\u0004YGQ\u001f\u0002}\u0019NO\u0004\u001f\u00038\u000f".length();
                var1_4 = 2;
                var0_5 = -1;
lbl7:
                // 2 sources

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

                while (true) {
                    var5[var3_1++] = MessageProcessor.a(v0, MessageProcessor.a(v2));
                    if ((var0_5 += var1_4) < var4_3) {
                        var1_4 = var2_2.charAt(var0_5);
                        ** continue;
                    }
                    var2_2 = "\u0000\u001a;\u007fu01s*:h{6t\u001e\u001e'h{6&s\u0016:)n6%&\u0016;lx\u0002s$";
                    var4_3 = "\u0000\u001a;\u007fu01s*:h{6t\u001e\u001e'h{6&s\u0016:)n6%&\u0016;lx\u0002s$".length();
                    var1_4 = 33;
                    var0_5 = -1;
lbl22:
                    // 2 sources

                    while (true) {
                        v0 = 13;
                        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++] = MessageProcessor.a(v0, MessageProcessor.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;
            }
        }
        MessageProcessor.z = var5;
        MessageProcessor.u = Level.INFO;
        var0_6 = MessageProcessor.z;
        MessageProcessor.v = AuditDetailMessage.Hint.getHint((String)var0_6[4]);
        MessageProcessor.w = AuditDetailMessage.Hint.getHint((String)var0_6[9]);
    }

    private static Exception a(Exception exception) {
        return exception;
    }

    private static char[] a(String string) {
        char[] cArray = string.toCharArray();
        if (cArray.length < 2) {
            cArray = cArray;
            cArray[0] = (char)(cArray[0] ^ 0x59);
        }
        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 -> 94;
                    case 1 -> 114;
                    case 2 -> 68;
                    case 3 -> 4;
                    case 4 -> 17;
                    case 5 -> 94;
                    default -> 89;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }

    public static final class SuspendStatus
    extends Enum<SuspendStatus> {
        public static final /* enum */ SuspendStatus INSTANCE;
        private boolean suspended = false;
        private String reason = "";
        private final ReadWriteLock mutex = new ReentrantReadWriteLock(false);
        private static final /* synthetic */ SuspendStatus[] $VALUES;

        public static SuspendStatus[] values() {
            return (SuspendStatus[])$VALUES.clone();
        }

        public static SuspendStatus valueOf(String string) {
            return Enum.valueOf(SuspendStatus.class, string);
        }

        public boolean isSuspended() {
            try {
                this.mutex.readLock().lock();
                boolean bl2 = this.suspended;
                return bl2;
            }
            finally {
                this.mutex.readLock().unlock();
            }
        }

        public void suspend() {
            try {
                this.mutex.writeLock().lock();
                this.suspended = true;
                this.reason = "";
            }
            finally {
                this.mutex.writeLock().unlock();
            }
        }

        public void suspend(String string) {
            try {
                this.mutex.writeLock().lock();
                this.suspended = true;
                this.reason = string;
            }
            finally {
                this.mutex.writeLock().unlock();
            }
        }

        public void resume() {
            try {
                this.mutex.writeLock().lock();
                this.suspended = false;
            }
            finally {
                this.mutex.writeLock().unlock();
            }
        }

        public String getReason() {
            try {
                this.mutex.readLock().lock();
                String string = this.reason;
                return string;
            }
            finally {
                this.mutex.readLock().unlock();
            }
        }

        private static /* synthetic */ SuspendStatus[] $values() {
            return new SuspendStatus[]{INSTANCE};
        }

        /*
         * Enabled aggressive block sorting
         */
        static {
            String string = SuspendStatus.a(43, SuspendStatus.a("\b\u000e;b)P[\u0004"));
            INSTANCE = new SuspendStatus();
            $VALUES = SuspendStatus.$values();
        }

        private static char[] a(String string) {
            char[] cArray = string.toCharArray();
            if (cArray.length < 2) {
                cArray = cArray;
                cArray[0] = (char)(cArray[0] ^ 0x33);
            }
            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 -> 106;
                        case 1 -> 107;
                        case 2 -> 67;
                        case 3 -> 29;
                        case 4 -> 67;
                        case 5 -> 53;
                        default -> 51;
                    })));
                    ++n3;
                    n4 = n4;
                } while (n4 > n3);
            }
            return new String(cArray2).intern();
        }
    }
}

