/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.l7tech.gateway.common.audit.AuditFactory
 *  com.l7tech.gateway.common.service.PublishedService
 *  com.l7tech.message.Message
 *  com.l7tech.xml.soap.SoapVersion
 */
package com.l7tech.server.service.resolution;

import com.l7tech.gateway.common.audit.AuditFactory;
import com.l7tech.gateway.common.service.PublishedService;
import com.l7tech.message.Message;
import com.l7tech.server.service.resolution.NameValueServiceResolver;
import com.l7tech.server.service.resolution.ServiceResolutionException;
import com.l7tech.xml.soap.SoapVersion;
import java.util.Arrays;
import java.util.List;

public class SoapVersionResolver
extends NameValueServiceResolver<String> {
    private static final String[] b;

    public SoapVersionResolver(AuditFactory auditFactory) {
        super(auditFactory);
    }

    @Override
    protected List<String> buildTargetValues(PublishedService publishedService) throws ServiceResolutionException {
        SoapVersion soapVersion = publishedService.getSoapVersion();
        try {
            if (soapVersion.getContentType() == null) {
                return Arrays.asList(SoapVersion.SOAP_1_1.getContentType(), SoapVersion.SOAP_1_2.getContentType());
            }
        }
        catch (ServiceResolutionException serviceResolutionException) {
            throw SoapVersionResolver.a(serviceResolutionException);
        }
        return Arrays.asList(soapVersion.getContentType());
    }

    @Override
    protected String getRequestValue(Message message) throws ServiceResolutionException {
        try {
            return message.getMimeKnob().getFirstPart().getContentType().getMainValue();
        }
        catch (Exception exception) {
            throw new ServiceResolutionException(b[1], exception);
        }
    }

    @Override
    public boolean isApplicableToMessage(Message message) throws ServiceResolutionException {
        try {
            boolean bl2;
            try {
                bl2 = !SoapVersion.UNKNOWN.equals((Object)SoapVersion.contentTypeToSoapVersion((String)message.getMimeKnob().getFirstPart().getContentType().getMainValue()));
            }
            catch (Exception exception) {
                throw SoapVersionResolver.a(exception);
            }
            return bl2;
        }
        catch (Exception exception) {
            throw new ServiceResolutionException(b[0], exception);
        }
    }

    @Override
    public boolean usesMessageContent() {
        return false;
    }

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

    /*
     * Enabled aggressive block sorting
     */
    static {
        String[] stringArray = new String[2];
        int n2 = 0;
        String string = "\u0017q# \u0001xR6pb&\bi\u00170r+,\b=\u0005*z6*\boR/z11\fz\u0017bj1'\u001e=\u0013bL\r\u0003==\u0011-q6'\u0003iR6f2'/\u0017q# \u0001xR6pb!\u0005x\u0011)?0'\u001ch\u00171kb$\u0004o\u00016?2#\u001fiR!p,6\bs\u0006bk;2\b";
        int n3 = "\u0017q# \u0001xR6pb&\bi\u00170r+,\b=\u0005*z6*\boR/z11\fz\u0017bj1'\u001e=\u0013bL\r\u0003==\u0011-q6'\u0003iR6f2'/\u0017q# \u0001xR6pb!\u0005x\u0011)?0'\u001ch\u00171kb$\u0004o\u00016?2#\u001fiR!p,6\bs\u0006bk;2\b".length();
        int n4 = 60;
        int n5 = -1;
        while (true) {
            int n6 = ++n5;
            stringArray[n2++] = SoapVersionResolver.b(41, SoapVersionResolver.a(string.substring(n6, n6 + n4)));
            if ((n5 += n4) >= n3) {
                b = stringArray;
                return;
            }
            n4 = string.charAt(n5);
        }
    }

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

